Dzahn has uploaded a new change for review. https://gerrit.wikimedia.org/r/199915
Change subject: add check_iostat nagios plugin ...................................................................... add check_iostat nagios plugin Add a nagios/icinga plugin to check I/O stats to monitor sodium. Took this from Nagios exchange. http://exchange.nagios.org/directory/Plugins/Operating-Systems/Linux/check_iostat--2D-I-2FO-statistics/details example on my local machine: ./check_iostat -d sda -w 4,10,20 -c 10,20,30 WARNING - I/O stats tps=4.50 KB_read/s=11.05 KB_written/s=17.87 | 'tps'=4.50; 'KB_read/s'=11.05; 'KB_written/s'=17.87; Bug:T93783 Change-Id: Ibb576e6cb738a45b5a2497c00356dcd938939d04 --- A files/icinga/check_iostat 1 file changed, 78 insertions(+), 0 deletions(-) git pull ssh://gerrit.wikimedia.org:29418/operations/puppet refs/changes/15/199915/1 diff --git a/files/icinga/check_iostat b/files/icinga/check_iostat new file mode 100755 index 0000000..f605c8e --- /dev/null +++ b/files/icinga/check_iostat @@ -0,0 +1,78 @@ +#!/bin/bash +# +# Version 0.0.2 - Jan/2009 +# Changes: added device verification +# +# by Thiago Varela - [email protected] + +iostat=`which iostat 2>/dev/null` +bc=`which bc 2>/dev/null` + +function help { +echo -e "\n\tThis plugin shows the I/O usage of the specified disk, using the iostat external program.\n\tIt prints three statistics: Transactions per second (tps), Kilobytes per second\n\tread from the disk (KB_read/s) and and written to the disk (KB_written/s)\n\n$0:\n\t-d <disk>\t\tDevice to be checked (without the full path, eg. sda)\n\t-c <tps>,<read>,<wrtn>\tSets the CRITICAL level for tps, KB_read/s and KB_written/s, respectively\n\t-w <tps>,<read>,<wrtn>\tSets the WARNING level for tps, KB_read/s and KB_written/s, respectively\n" + exit -1 +} + +# Ensuring we have the needed tools: +( [ ! -f $iostat ] || [ ! -f $bc ] ) && \ + ( echo "ERROR: You must have iostat and bc installed in order to run this plugin" && exit -1 ) + +# Getting parameters: +while getopts "d:w:c:h" OPT; do + case $OPT in + "d") disk=$OPTARG;; + "w") warning=$OPTARG;; + "c") critical=$OPTARG;; + "h") help;; + esac +done + +# Adjusting the three warn and crit levels: +crit_tps=`echo $critical | cut -d, -f1` +crit_read=`echo $critical | cut -d, -f2` +crit_written=`echo $critical | cut -d, -f3` + +warn_tps=`echo $warning | cut -d, -f1` +warn_read=`echo $warning | cut -d, -f2` +warn_written=`echo $warning | cut -d, -f3` + + +# Checking parameters: +[ ! -b "/dev/$disk" ] && echo "ERROR: Device incorrectly specified" && help + +( [ "$warn_tps" == "" ] || [ "$warn_read" == "" ] || [ "$warn_written" == "" ] || \ + [ "$crit_tps" == "" ] || [ "$crit_read" == "" ] || [ "$crit_written" == "" ] ) && + echo "ERROR: You must specify all warning and critical levels" && help + +( [[ "$warn_tps" -ge "$crit_tps" ]] || \ + [[ "$warn_read" -ge "$crit_read" ]] || \ + [[ "$warn_written" -ge "$crit_written" ]] ) && \ + echo "ERROR: critical levels must be highter than warning levels" && help + + +# Doing the actual check: +tps=`$iostat $disk | grep $disk | awk '{print $2}'` +kbread=`$iostat $disk | grep $disk | awk '{print $3}'` +kbwritten=`$iostat $disk | grep $disk | awk '{print $4}'` + + +# Comparing the result and setting the correct level: +if ( [ "`echo "$tps >= $crit_tps" | bc`" == "1" ] || [ "`echo "$kbread >= $crit_read" | bc`" == "1" ] || \ + [ "`echo "$kbwritten >= $crit_written" | bc`" == "1" ] ); then + msg="CRITICAL" + status=2 +else if ( [ "`echo "$tps >= $warn_tps" | bc`" == "1" ] || [ "`echo "$kbread >= $warn_read" | bc`" == "1" ] || \ + [ "`echo "$kbwritten >= $warn_written" | bc`" == "1" ] ); then + msg="WARNING" + status=1 + else + msg="OK" + status=0 + fi +fi + +# Printing the results: +echo "$msg - I/O stats tps=$tps KB_read/s=$kbread KB_written/s=$kbwritten | 'tps'=$tps; 'KB_read/s'=$kbread; 'KB_written/s'=$kbwritten;" + +# Bye! +exit $status -- To view, visit https://gerrit.wikimedia.org/r/199915 To unsubscribe, visit https://gerrit.wikimedia.org/r/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ibb576e6cb738a45b5a2497c00356dcd938939d04 Gerrit-PatchSet: 1 Gerrit-Project: operations/puppet Gerrit-Branch: production Gerrit-Owner: Dzahn <[email protected]> _______________________________________________ MediaWiki-commits mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits
