[nagiosplug] Made verbose output of check_sensors compilant

"Nagios Plugin Development" <[email protected]> Thu, 15 Aug 2013 09:40:20 +0000
Newsgroups gmane.network.nagios.plugins.cvs
Message-ID <[email protected]>
 Module: nagiosplug
 Branch: master
 Commit: 774647f60ccee69f0cd033b5411e36441f03c84a
 Author: Gabriele Tozzi <[email protected]>
   Date: Sun May 19 03:00:57 2013 +0200
    URL: http://nagiosplug.git.sf.net/git/gitweb.cgi?p=nagiosplug/nagiosplug;a=commit;h=774647f

Made verbose output of check_sensors compilant

---

 plugins-scripts/check_sensors.sh |   33 ++++++++++++++++++---------------
 1 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/plugins-scripts/check_sensors.sh b/plugins-scripts/check_sensors.sh
index ffaa974..874e104 100755
--- a/plugins-scripts/check_sensors.sh
+++ b/plugins-scripts/check_sensors.sh
@@ -44,25 +44,28 @@ case "$1" in
 	*)
 		sensordata=`sensors 2>&1`
 		status=$?
-		if test "$1" = "-v" -o "$1" = "--verbose"; then
-			echo ${sensordata}
-		fi
 		if test ${status} -eq 127; then
-			echo "SENSORS UNKNOWN - command not found (did you install lmsensors?)"
-			exit $STATE_UNKNOWN
+			text="SENSORS UNKNOWN - command not found (did you install lmsensors?)"
+			exit=$STATE_UNKNOWN
 		elif test ${status} -ne 0; then
-			echo "WARNING - sensors returned state $status"
-			exit $STATE_WARNING
-		fi
-		if echo ${sensordata} | egrep ALARM > /dev/null; then
-			echo SENSOR CRITICAL - Sensor alarm detected!
-			exit $STATE_CRITICAL
+			text="WARNING - sensors returned state $status"
+			exit=$STATE_WARNING
+		elif echo ${sensordata} | egrep ALARM > /dev/null; then
+			text="SENSOR CRITICAL - Sensor alarm detected!"
+			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 $STATE_UNKNOWN
+			text="SENSOR UNKNOWN - Sensor reported fault"
+			exit=$STATE_UNKNOWN
+		else
+			text="SENSORS OK"
+			exit=$STATE_OK
 		fi
-		echo sensor ok
-		exit $STATE_OK
+
+		echo "$text"
+		if test "$1" = "-v" -o "$1" = "--verbose"; then
+			echo ${sensordata}
+		fi
+		exit $exit
 		;;
 esac


------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead. 
Download for free and get started troubleshooting in minutes. 
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk