Home Directory

Search Exchange

Search All Sites

Nagios Live Webinars

Let our experts show you how Nagios can help your organization.

Contact Us

Phone: 1-888-NAGIOS-1
Email: sales@nagios.com

Login

Remember Me

Directory

amateo

Reviews(1)
byamateo, June 12, 2013
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 - thiago@iplenix.com
#
-# by Thiago Varela - thiago@iplenix.com
+# --------------------------------------
+#
+# 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 - pn@pn-it.com
+#

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