add dpkg lister script for unix agent

git-svn-id: http://www.observium.org/svn/observer/trunk@2929 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong
2012-03-26 16:04:16 +00:00
parent ee0e0e6f4f
commit c01b6b87b2
3 changed files with 42 additions and 3 deletions

19
scripts/agent-local/dpkg Executable file
View File

@@ -0,0 +1,19 @@
#!/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

View File

@@ -1,6 +1,19 @@
#!/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 /bin/rpm ]; then
DATE=$(date +%s)
FILE=/tmp/observium-agent-rpm
if [ ! -e $FILE ]; then
/bin/rpm -q --all --queryformat '%{N} %{V} %{R} %{ARCH} %{SIZE}\n' > $FILE
fi
FILEMTIME=$(stat -c %Y $FILE)
FILEAGE=$(($DATE-$FILEMTIME))
if [ $FILEAGE -gt 1800 ]; then
/bin/rpm -q --all --queryformat '%{N} %{V} %{R} %{ARCH} %{SIZE}\n' > $FILE
fi
echo "<<<rpm>>>"
/bin/rpm -q --all --queryformat '%{N} %{V} %{R} %{ARCH} %{SIZE}\n'
cat $FILE
fi