-
Notifications
You must be signed in to change notification settings - Fork 189
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|