From 6a32351b893816ed710c8c8beedd33f2892ca3a3 Mon Sep 17 00:00:00 2001 From: Peter Eriksson <pen@lysator.liu.se> Date: Thu, 11 Jan 2007 13:40:57 +0000 Subject: [PATCH] Updated to ignore CD and DVD devices and some other stuff... --- check_iostatE | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/check_iostatE b/check_iostatE index a138db7..a03acbc 100755 --- a/check_iostatE +++ b/check_iostatE @@ -1,6 +1,6 @@ #!/bin/ksh -PATH=/opt/lysator/bin:/usr/bin:/usr/sbin +PATH=/usr/bin:/usr/sbin:/opt/lysator/bin:/ifm/sbin:/pkg/gnu/bin export PATH RSH=ssh @@ -16,8 +16,8 @@ HCRIT=4 TWARN=1 TCRIT=3 -SWARN=5 -SCRIT=10 +SWARN=8 +SCRIT=20 while [ "$1" != "" ]; do case "$1" in @@ -105,7 +105,8 @@ exec $CMD | $GAWK -vverbose=$VERBOSE \ '\ BEGIN { gtotal=0; ndisks=0; disks=""; ncrit=0; nwarn=0; crits=""; warns="" } \ /^c[0-9][0-9]*t[0-9][0-9]*d[0-9][0-9]*/ { dev=$1; serr[dev]=$4; herr[dev]=$7; terr[dev]=$10; vendor[dev]=""; pfa[dev]="" } \ - /^Vendor:/ { vendor[dev]=$2; product[dev]=$4; rev[dev]=$6; serial[dev]=$9 } \ + /^Vendor:/ { vendor[dev]=$2" "; if ($6 ==" Revision:") { product[dev]=$4" "$5; rev[dev]=$7; serial[dev]=$10 } else \ + { product[dev]=$4; rev[dev]=$6; serial[dev]=$9 }} \ /^Model:/ { vendor[dev]=""; product[dev]=$2; rev[dev]=$4; serial[dev]=$7 } \ /^Size:/ { size[dev]=$2 } \ /^Media/ { merr[dev]=$3; dnrerr[dev]=$7; nderr[dev]=$10; rerr[dev]=$12 } \ @@ -113,22 +114,31 @@ exec $CMD | $GAWK -vverbose=$VERBOSE \ irerr[dev]=$3; pfa[dev]=$7; \ total[dev]=serr[dev]+herr[dev]+terr[dev]; if (verbose) \ - print dev, "(" product[dev], rev[dev] ")", ":", total[dev], ":", serr[dev], herr[dev], terr[dev], ":", merr[dev], dnrerr[dev], nderr[dev], rerr[dev], irerr[dev], pfa[dev];\ - gtotal += total[dev]; \ + print dev, "(" vendor[dev]""product[dev], rev[dev] ")", ":", total[dev], ":", serr[dev], herr[dev], terr[dev], ":", merr[dev], dnrerr[dev], nderr[dev], rerr[dev], irerr[dev], pfa[dev];\ + if ( product[dev] !~ /^CD/ && product[dev] !~ /^DVD/ ) { \ + gtotal += total[dev]; \ ndisks++; disks=disks " " dev; \ nsoft+=serr[dev]; nhard+=herr[dev]; ntran+=terr[dev]; \ - if (herr[dev] >= hcrit || terr[dev] >= tcrit || serr[dev] >= scrit) { \ + if (herr[dev] >= hcrit) { \ ncrit++; crits=crits " " dev; \ - } else if (herr[dev] >= hwarn || terr[dev] >= twarn || serr[dev] >= swarn) { \ + } else if (herr[dev] >= hwarn) { \ nwarn++; warns=warns " " dev; \ - } } \ + } else if (terr[dev] >= tcrit) { \ + ncrit++; crits=crits " " dev; \ + } else if (terr[dev] >= twarn) { \ + nwarn++; warns=warns " " dev; \ + } else if (serr[dev] >= scrit) { \ + ncrit++; crits=crits " " dev; \ + } else if (serr[dev] >= swarn) { \ + nwarn++; warns=warns " " dev; \ + } } } \ END { \ if (ncrit > 0) { \ print "CRITICAL -", ncrit+nwarn "/" ndisks, "disks with errors (" nsoft, "soft", nhard, "hard", ntran, "transport):" crits warns; exit 2 \ } else if (nwarn > 0) { \ print "WARNING -", ncrit+nwarn "/" ndisks, "disks with errors (" nsoft, "soft", nhard, "hard", ntran, "transport):" crits warns; exit 1 \ } else { \ - print "OK -", ndisks, "disks checked with", gtotal, "errors (" nsoft, "soft", nhard, "hard", ntran, "transport)" }} \ + print "OK -", ndisks, "disks checked with", gtotal, "errors (" nsoft, "soft", nhard, "hard", ntran, "transport):" disks}} \ ' -- GitLab