Created
May 22, 2013 14:32
-
-
Save phoolish/5627988 to your computer and use it in GitHub Desktop.
Very basic collectd exec plugin that checks yum for updates and security updates and returns the count
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
#!/bin/bash | |
# | |
# Checks yum for updates and passes the count to collectd. | |
# | |
# Requriments: | |
# - collectd_exec_plugin | |
# - yum-plugin-security package | |
# | |
# <Plugin exec> | |
# Exec "nobody" "/path/to/yum_update.sh" | |
# </Plugin> | |
# | |
# Or to define the interval. | |
# <Plugin exec> | |
# Exec "nobody" "/path/to/yum_update.sh" "-i" "60000" | |
# </Plugin> | |
# | |
HOSTNAME="${COLLECTD_HOSTNAME:-`hostname -f`}" | |
# run every 12 hours | |
INTERVAL="43200" | |
while getopts "i:" c; do | |
case $c in | |
i) INTERVAL=$OPTARG;; | |
*) echo "Usage: $0 [-i <interval in seconds>]";; | |
esac | |
done | |
while [ $? -eq 0 ]; do | |
updates=$(yum check-update -q | sed "1 d" | wc -l) | |
security_updates=$(yum check-update -q --security | sed "1 d" | wc -l) | |
echo "PUTVAL $HOSTNAME/yum/updates interval=$INTERVAL N:$updates" | |
echo "PUTVAL $HOSTNAME/yum/security_updates interval=$INTERVAL N:$security_updates" | |
sleep "$INTERVAL" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment