From 276c5b98bf619eabd8b0bd5fc3ff60c0a59489a7 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Wed, 7 Sep 2011 13:55:53 +0200 Subject: check_sensors: Detect FAULT status Return an UNKNOWN status if a faulty sensor is detected. This can be suppressed with the new "--ignore-fault" option. (Fixes Debian bug #615133, patch suggested by Jan Wagner.) --- plugins-scripts/check_sensors.sh | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'plugins-scripts') diff --git a/plugins-scripts/check_sensors.sh b/plugins-scripts/check_sensors.sh index ae80fc44..d108bcc8 100755 --- a/plugins-scripts/check_sensors.sh +++ b/plugins-scripts/check_sensors.sh @@ -10,7 +10,7 @@ REVISION="@NP_VERSION@" print_usage() { - echo "Usage: $PROGNAME" + echo "Usage: $PROGNAME" [--ignore-fault] } print_help() { @@ -57,9 +57,12 @@ case "$1" in if echo ${sensordata} | egrep ALARM > /dev/null; then echo SENSOR CRITICAL - Sensor alarm detected! exit 2 - else - echo sensor ok - exit 0 + elif echo ${sensordata} | egrep FAULT > /dev/null \ + && test "$1" != "-i" -a "$1" != "--ignore-fault"; then + echo SENSOR UNKNOWN - Sensor reported fault + exit 3 fi + echo sensor ok + exit 0 ;; esac -- cgit v1.2.3-74-g34f1 From f720f4a3c002c939858afe6bdcdf4bc08929652b Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Wed, 7 Sep 2011 13:57:38 +0200 Subject: check_sensors: Minor whitespace fixes --- plugins-scripts/check_sensors.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'plugins-scripts') diff --git a/plugins-scripts/check_sensors.sh b/plugins-scripts/check_sensors.sh index d108bcc8..660b7210 100755 --- a/plugins-scripts/check_sensors.sh +++ b/plugins-scripts/check_sensors.sh @@ -34,7 +34,7 @@ case "$1" in exit 0 ;; --version) - print_revision $PROGNAME $REVISION + print_revision $PROGNAME $REVISION exit 0 ;; -V) @@ -50,7 +50,7 @@ case "$1" in if test ${status} -eq 127; then echo "SENSORS UNKNOWN - command not found (did you install lmsensors?)" exit -1 - elif test ${status} -ne 0 ; then + elif test ${status} -ne 0; then echo "WARNING - sensors returned state $status" exit 1 fi -- cgit v1.2.3-74-g34f1 From 5532dbe48a485edb7f75c5058a2aac87090f66d3 Mon Sep 17 00:00:00 2001 From: Holger Weiss Date: Wed, 7 Sep 2011 14:04:01 +0200 Subject: check_sensors: Use symbolic exit codes Specify the exit codes by using the constants from utils.sh. --- plugins-scripts/check_sensors.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'plugins-scripts') diff --git a/plugins-scripts/check_sensors.sh b/plugins-scripts/check_sensors.sh index 660b7210..ffaa9748 100755 --- a/plugins-scripts/check_sensors.sh +++ b/plugins-scripts/check_sensors.sh @@ -21,25 +21,25 @@ print_help() { echo "This plugin checks hardware status using the lm_sensors package." echo "" support - exit 0 + exit $STATE_OK } case "$1" in --help) print_help - exit 0 + exit $STATE_OK ;; -h) print_help - exit 0 + exit $STATE_OK ;; --version) print_revision $PROGNAME $REVISION - exit 0 + exit $STATE_OK ;; -V) print_revision $PROGNAME $REVISION - exit 0 + exit $STATE_OK ;; *) sensordata=`sensors 2>&1` @@ -49,20 +49,20 @@ case "$1" in fi if test ${status} -eq 127; then echo "SENSORS UNKNOWN - command not found (did you install lmsensors?)" - exit -1 + exit $STATE_UNKNOWN elif test ${status} -ne 0; then echo "WARNING - sensors returned state $status" - exit 1 + exit $STATE_WARNING fi if echo ${sensordata} | egrep ALARM > /dev/null; then echo SENSOR CRITICAL - Sensor alarm detected! - exit 2 + exit $STATE_CRITICAL elif echo ${sensordata} | egrep FAULT > /dev/null \ && test "$1" != "-i" -a "$1" != "--ignore-fault"; then echo SENSOR UNKNOWN - Sensor reported fault - exit 3 + exit $STATE_UNKNOWN fi echo sensor ok - exit 0 + exit $STATE_OK ;; esac -- cgit v1.2.3-74-g34f1