Просмотр исходного кода

check_sensors.sh: fix some shellcheck warnings SC2039 and SC2143

Mario Trangoni 9 лет назад
Родитель
Сommit
aa60e932bd
1 измененных файлов с 8 добавлено и 6 удалено
  1. 8 6
      plugins-scripts/check_sensors.sh

+ 8 - 6
plugins-scripts/check_sensors.sh

@@ -44,19 +44,21 @@ case "$1" in
 	*)
 		sensordata=$(sensors 2>&1)
 		status=$?
-		if [ "$status" == 127 ] ; then
+		if [ $status -eq 127 ] ; then
 			text="SENSORS UNKNOWN - command not found (did you install lmsensors?)"
 			exit=$STATE_UNKNOWN
 		elif [ "$status" != 0 ] ; then
 			text="WARNING - sensors returned state $status"
 			exit=$STATE_WARNING
-		elif [ "$(echo "${sensordata}" | egrep ALARM > /dev/null)" ] ; then
+		elif echo "${sensordata}" | egrep -q ALARM > /dev/null ; then
 			text="SENSOR CRITICAL - Sensor alarm detected!"
 			exit=$STATE_CRITICAL
-		elif [ \( "$(echo "${sensordata}" | egrep FAULT  > /dev/null)" \) -a\
-			\( "$(test "$1")" != "-i" -a "$1" != "--ignore-fault" \) ] ; then
-			text="SENSOR UNKNOWN - Sensor reported fault"
-			exit=$STATE_UNKNOWN
+		elif echo "${sensordata}" | egrep -q FAULT  > /dev/null -a; then
+			if [ "$(test "$1")" != "-i" -a \
+				"$1" != "--ignore-fault" ] ; then
+				text="SENSOR UNKNOWN - Sensor reported fault"
+				exit=$STATE_UNKNOWN
+			fi
 		else
 			text="SENSORS OK"
 			exit=$STATE_OK