mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
20 lines
627 B
Plaintext
20 lines
627 B
Plaintext
|
#!/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/dpkg-query ]; then
|
||
|
DATE=$(date +%s)
|
||
|
FILE=/tmp/observium-agent-dpkg
|
||
|
if [ ! -e $FILE ]; then
|
||
|
dpkg-query -W --showformat='${Package} ${Version} ${Architecture} ${Installed-Size}\n' > $FILE
|
||
|
fi
|
||
|
FILEMTIME=$(stat -c %Y $FILE)
|
||
|
FILEAGE=$(($DATE-$FILEMTIME))
|
||
|
if [ $FILEAGE -gt 1800 ]; then
|
||
|
dpkg-query -W --showformat='${Package} ${Version} ${Architecture} ${Installed-Size}\n' > $FILE
|
||
|
fi
|
||
|
echo "<<<dpkg>>>"
|
||
|
cat $FILE
|
||
|
fi
|
||
|
|