Skip to content

Commit

Permalink
Add pacman packages support
Browse files Browse the repository at this point in the history
  • Loading branch information
murrant committed Oct 8, 2023
1 parent 6a7c04e commit 5521641
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions agent-local/pacman
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/bin/bash
# Cache the file for 30 minutes
# If you want to override this, put the command in cron.
# We cache because it is a 1sec delay, which is painful for the poller
if [ -x /usr/bin/pacman ]; then
DATE=$(date +%s)
FILE=/var/cache/librenms/agent-local-pacman

[ -d /var/cache/librenms ] || mkdir -p /var/cache/librenms

if [ ! -e $FILE ]; then
pacman -Qi | awk '/^Name/{name=$3} /^Version/{version=$3} /^Architecture/{arch=$3} /^Installed Size/{print name, version, arch, $4$5}' > $FILE
fi
FILEMTIME=$(stat -c %Y $FILE)
FILEAGE=$(($DATE-$FILEMTIME))
if [ $FILEAGE -gt 1800 ]; then
pacman -Qi | awk '/^Name/{name=$3} /^Version/{version=$3} /^Architecture/{arch=$3} /^Installed Size/{print name, version, arch, $4$5}' > $FILE
fi
echo "<<<pacman>>>"
cat $FILE
fi

0 comments on commit 5521641

Please sign in to comment.