Parameter "--bad-output-only" ergänzt

This commit is contained in:
Patrick Schindelmann 2022-02-11 11:10:10 +00:00
parent e9a65fbbd6
commit 934adecce2

View File

@ -34,6 +34,7 @@ function hilfetext(){
--fahrenheit Display all temperatures in degree fahrenheit --fahrenheit Display all temperatures in degree fahrenheit
--sensor_hex Output of the Hex-Sensors (default) --sensor_hex Output of the Hex-Sensors (default)
--sensor_nr Output of the Sensor-Numbers --sensor_nr Output of the Sensor-Numbers
--bad-output-only List only the warning and critical values
-p | --perfdata show Performancedata -p | --perfdata show Performancedata
-h | --help Print this Help -h | --help Print this Help
@ -42,7 +43,7 @@ function hilfetext(){
function ParameterEvaluation(){ function ParameterEvaluation(){
options=$(getopt -o s:S:w:c:lph --long config: --long sensor: --long warn: --long crit: --long list --long celsius --long fahrenheit --long sensor_hex --long sensor_nr --long perfdata --long help -- "$@") options=$(getopt -o s:S:w:c:lph --long config: --long sensor: --long warn: --long crit: --long list --long celsius --long fahrenheit --long sensor_hex --long sensor_nr --long perfdata --long help --long bad-output-only -- "$@")
#Option nicht verfügbar #Option nicht verfügbar
[ "$?" -eq "0" ] || { [ "$?" -eq "0" ] || {
@ -92,6 +93,10 @@ function ParameterEvaluation(){
"--sensor_nr") "--sensor_nr")
DISPLAY_SENSOR_NR="1" DISPLAY_SENSOR_NR="1"
;; ;;
"--bad-output-only")
DISPLAY_BAD_OUTPUT_ONLY="1"
;;
"-p"|"--perfdata") "-p"|"--perfdata")
PERFDATA="1" PERFDATA="1"
;; ;;
@ -245,12 +250,32 @@ do
fi fi
if [ "$DISPLAY_SENSOR_HEX" = "1" ] if [ "$DISPLAY_SENSOR_HEX" = "1" ]
then
if [ "$DISPLAY_BAD_OUTPUT_ONLY" = "1" ] && [ "$celsius" -ge "$CRITICAL" ]
then then
OUTPUT+=" Sensor $sensor_hex is ${celsius}°C;" OUTPUT+=" Sensor $sensor_hex is ${celsius}°C;"
elif [ "$DISPLAY_BAD_OUTPUT_ONLY" = "1" ] && [ "$celsius" -ge "$WARNING" ]
then
OUTPUT+=" Sensor $sensor_hex is ${celsius}°C;"
elif [ ! "$DISPLAY_BAD_OUTPUT_ONLY" = "1" ]
then
OUTPUT+=" Sensor $sensor_hex is ${celsius}°C;"
fi
OUTPUT_PERFDATA+="Sensor $sensor_hex=$celsius;$WARNING;$CRITICAL " OUTPUT_PERFDATA+="Sensor $sensor_hex=$celsius;$WARNING;$CRITICAL "
elif [ "$DISPLAY_SENSOR_NR" = "1" ] elif [ "$DISPLAY_SENSOR_NR" = "1" ]
then
if [ "$DISPLAY_BAD_OUTPUT_ONLY" = "1" ] && [ "$celsius" -ge "$CRITICAL" ]
then then
OUTPUT+=" Sensor $sensor_id is ${celsius}°C;" OUTPUT+=" Sensor $sensor_id is ${celsius}°C;"
elif [ "$DISPLAY_BAD_OUTPUT_ONLY" = "1" ] && [ "$celsius" -ge "$WARNING" ]
then
OUTPUT+=" Sensor $sensor_id is ${celsius}°C;"
elif [ ! "$DISPLAY_BAD_OUTPUT_ONLY" = "1" ]
then
OUTPUT+=" Sensor $sensor_id is ${celsius}°C;"
fi
OUTPUT_PERFDATA+="Sensor $sensor_id=$celsius;$WARNING;$CRITICAL " OUTPUT_PERFDATA+="Sensor $sensor_id=$celsius;$WARNING;$CRITICAL "
fi fi
@ -273,12 +298,32 @@ do
fi fi
if [ "$DISPLAY_SENSOR_HEX" = "1" ] if [ "$DISPLAY_SENSOR_HEX" = "1" ]
then
if [ "$DISPLAY_BAD_OUTPUT_ONLY" = "1" ] && [ "$fahrenheit" -ge "$CRITICAL" ]
then then
OUTPUT+=" Sensor $sensor_hex is ${fahrenheit}°F;" OUTPUT+=" Sensor $sensor_hex is ${fahrenheit}°F;"
elif [ "$DISPLAY_BAD_OUTPUT_ONLY" = "1" ] && [ "$fahrenheit" -ge "$WARNING" ]
then
OUTPUT+=" Sensor $sensor_hex is ${fahrenheit}°F;"
elif [ ! "$DISPLAY_BAD_OUTPUT_ONLY" = "1" ]
then
OUTPUT+=" Sensor $sensor_hex is ${fahrenheit}°F;"
fi
OUTPUT_PERFDATA+="Sensor $sensor_hex=$fahrenheit;$WARNING;$CRITICAL " OUTPUT_PERFDATA+="Sensor $sensor_hex=$fahrenheit;$WARNING;$CRITICAL "
elif [ "$DISPLAY_SENSOR_NR" = "1" ] elif [ "$DISPLAY_SENSOR_NR" = "1" ]
then
if [ "$DISPLAY_BAD_OUTPUT_ONLY" = "1" ] && [ "$fahrenheit" -ge "$CRITICAL" ]
then then
OUTPUT+=" Sensor $sensor_id is ${fahrenheit}°F;" OUTPUT+=" Sensor $sensor_id is ${fahrenheit}°F;"
elif [ "$DISPLAY_BAD_OUTPUT_ONLY" = "1" ] && [ "$fahrenheit" -ge "$WARNING" ]
then
OUTPUT+=" Sensor $sensor_id is ${fahrenheit}°F;"
elif [ ! "$DISPLAY_BAD_OUTPUT_ONLY" = "1" ]
then
OUTPUT+=" Sensor $sensor_id is ${fahrenheit}°F;"
fi
OUTPUT_PERFDATA+="Sensor $sensor_id=$fahrenheit;$WARNING;$CRITICAL " OUTPUT_PERFDATA+="Sensor $sensor_id=$fahrenheit;$WARNING;$CRITICAL "
fi fi