Build precise queries to find exactly what you need
Press ESC to close
Join our next live webinar: “Advanced Nagios Monitoring Techniques” – Register Now
@amateo
Favorites0
Views
Projects0
I have created a patched version between original version and philippn's one. This patch: * Runs iostat just once. * Avoids the conversion between '.' and ',' by running iostat with LANG=C * Gets actual values not the ones from last reboot. * Runs from bash This is the patch: Index: check_iostat =================================================================== --- check_iostat (revisión: 11002) +++ check_iostat (copia de trabajo) @@ -1,9 +1,20 @@ -#!/bin/sh +#!/bin/bash # # Version 0.0.2 - Jan/2009 # Changes: added device verification +# +# by Thiago Varela - [email protected] # -# by Thiago Varela - [email protected] +# -------------------------------------- +# +# Version 0.0.3 - Dec/2011 +# Changes: +# - changed values from bytes to mbytes +# - fixed bug to get traffic data without comma but point +# - current values are displayed now, not average values (first run of iostat) +# +# by Philipp Niedziela - [email protected] +# iostat=`which iostat 2>/dev/null` bc=`which bc 2>/dev/null` @@ -50,14 +61,19 @@ echo "ERROR: critical levels must be highter than warning levels" && help +# iostat parameters: +# -m: megabytes +# -k: kilobytes +# first run of iostat shows statistics since last reboot, second one shows current vaules of hdd # 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}'` +# We get just 2nd line, which is the actual value +output=$(LANG=C $iostat $disk -d 1 2 | grep $disk | sed -n '2p') +tps=$(echo "$output" | awk '{print $2}') +kbread=$(echo "$output" | awk '{print $3}') +kbwritten=$(echo "$output" | awk '{print $4}') - # Comparing the result and setting the correct level: -if ( [ "`echo "$tps >= $crit_tps" | bc`" == "1" ] || [ "`echo "$kbread >= $crit_read" | bc`" == "1" ] || +if ( [ "`echo "$tps >= $crit_tps" | bc`" == "1" ] || [ "`echo "$kbread >= $crit_read" | bc -q`" == "1" ] || [ "`echo "$kbwritten >= $crit_written" | bc`" == "1" ] ); then msg="CRITICAL" status=2
Reviewed 12 years ago