tools: Remove Drupal/SourceForge scripts
[monitoring-plugins.git] / plugins-scripts / check_sensors.sh
blob874e10496d6719a1fe7a1027aa3f4a185a51ba5c
1 #!/bin/sh
3 PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
5 PROGNAME=`basename $0`
6 PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
7 REVISION="@NP_VERSION@"
9 . $PROGPATH/utils.sh
12 print_usage() {
13 echo "Usage: $PROGNAME" [--ignore-fault]
16 print_help() {
17 print_revision $PROGNAME $REVISION
18 echo ""
19 print_usage
20 echo ""
21 echo "This plugin checks hardware status using the lm_sensors package."
22 echo ""
23 support
24 exit $STATE_OK
27 case "$1" in
28 --help)
29 print_help
30 exit $STATE_OK
32 -h)
33 print_help
34 exit $STATE_OK
36 --version)
37 print_revision $PROGNAME $REVISION
38 exit $STATE_OK
40 -V)
41 print_revision $PROGNAME $REVISION
42 exit $STATE_OK
45 sensordata=`sensors 2>&1`
46 status=$?
47 if test ${status} -eq 127; then
48 text="SENSORS UNKNOWN - command not found (did you install lmsensors?)"
49 exit=$STATE_UNKNOWN
50 elif test ${status} -ne 0; then
51 text="WARNING - sensors returned state $status"
52 exit=$STATE_WARNING
53 elif echo ${sensordata} | egrep ALARM > /dev/null; then
54 text="SENSOR CRITICAL - Sensor alarm detected!"
55 exit=$STATE_CRITICAL
56 elif echo ${sensordata} | egrep FAULT > /dev/null \
57 && test "$1" != "-i" -a "$1" != "--ignore-fault"; then
58 text="SENSOR UNKNOWN - Sensor reported fault"
59 exit=$STATE_UNKNOWN
60 else
61 text="SENSORS OK"
62 exit=$STATE_OK
65 echo "$text"
66 if test "$1" = "-v" -o "$1" = "--verbose"; then
67 echo ${sensordata}
69 exit $exit
71 esac