Port Modules/OAM/oam-librenms.sh. Deploys the check_mk agent and systemd socket for LibreNMS monitoring, along with the local plugins: distro, dmi, dpkg, ntp-client, os-updates, postfixdetailed, and postfix-queues. 🤖 Generated with [Crush](https://github.com/charmassociates/crush) Assisted-by: GLM-5 via Crush <crush@charm.land>
23 lines
791 B
Bash
23 lines
791 B
Bash
#!/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=/var/cache/librenms/agent-local-dpkg
|
|
|
|
[ -d /var/cache/librenms ] || mkdir -p /var/cache/librenms
|
|
|
|
if [ ! -e $FILE ]; then
|
|
dpkg-query -W --showformat='${Status} ${Package} ${Version} ${Architecture} ${Installed-Size}\n'|grep " installed "|cut -d\ -f4- > $FILE
|
|
fi
|
|
FILEMTIME=$(stat -c %Y $FILE)
|
|
FILEAGE=$(($DATE-$FILEMTIME))
|
|
if [ $FILEAGE -gt 1800 ]; then
|
|
dpkg-query -W --showformat='${Status} ${Package} ${Version} ${Architecture} ${Installed-Size}\n'|grep " installed "|cut -d\ -f4- > $FILE
|
|
fi
|
|
echo "<<<dpkg>>>"
|
|
cat $FILE
|
|
fi
|
|
|