From 55216418613a3a499f553893464dc7fca1c4fd67 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Sat, 7 Oct 2023 21:33:16 -0500 Subject: [PATCH] Add pacman packages support --- agent-local/pacman | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 agent-local/pacman diff --git a/agent-local/pacman b/agent-local/pacman new file mode 100755 index 000000000..d0b4f4ae0 --- /dev/null +++ b/agent-local/pacman @@ -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 "<<>>" + cat $FILE +fi +