Created
May 22, 2013 14:32
Revisions
-
phoolish created this gist
May 22, 2013 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,37 @@ #!/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