From 494e3ae4f7e867b517ae239d8c89ef28e5bb5a44 Mon Sep 17 00:00:00 2001 From: Patrick Schindelmann Date: Tue, 22 Oct 2019 08:13:08 +0200 Subject: [PATCH] =?UTF-8?q?Celsius=20und=20Fahrenheit=20hinzugef=C3=BCgt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- checks/check_hddtemp.sh | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/checks/check_hddtemp.sh b/checks/check_hddtemp.sh index 5c215dd..3269c20 100755 --- a/checks/check_hddtemp.sh +++ b/checks/check_hddtemp.sh @@ -20,6 +20,7 @@ HDDTEMP="$(type -P hddtemp)" PARAMETER="$*" WARNING="40" CRITICAL="45" +UNIT="c" function hilfetext(){ cat <<- EOF @@ -27,17 +28,20 @@ function hilfetext(){ $(basename "$0") [OPTION...] Options: -d | --device + --fahrenheit + --celsius (default) -w | --warning (default: 40) -c | --critical (default: 50) -p | --perfdata -h | --help + EOF } function ParameterEvaluation(){ - options=$(getopt -o c:d:hpw: --long critical: --long device: --long help --long perfdata --long warning: -- "$@") + options=$(getopt -o c:d:hpw: --long fahrenheit --long celsius --long critical: --long device: --long help --long perfdata --long warning: -- "$@") #Option nicht verfügbar [ "$?" -eq "0" ] || { @@ -52,6 +56,12 @@ function ParameterEvaluation(){ shift; # The arg is next in position args DEVICE="$1" ;; + "--celsius") + UNIT="c" + ;; + "--fahrenheit") + UNIT="f" + ;; "-w"|"--warning") shift; # The arg is next in position args WARNING="$1" @@ -67,7 +77,7 @@ function ParameterEvaluation(){ hilfetext exit 0 ;; - + "--") shift break @@ -96,7 +106,7 @@ ParameterEvaluation "$0" "$@" #Debug #echo -e "WARNING:\t\"$WARNING\"" #echo -e "CRITICAL:\t\"$CRITICAL\"" -#echo -e "DEVICE:\t\t\"$DEVICE\"" +echo -e "DEVICE:\t\t\"$DEVICE\"" #echo -e "HELP\t\t\"$HELP\"" #echo -e "PERFDATA\t\t\"$PERFDATA\"" #echo -e "Alle Args:\t\"$@\"" @@ -115,7 +125,14 @@ then exit 1 fi -RESULT=$($HDDTEMP $DEVICE) +if [ "$UNIT" = "c" ] +then + RESULT=$($HDDTEMP --unit=C $DEVICE) +elif [ "$UNIT" = "f" ] +then + RESULT=$($HDDTEMP --unit=F $DEVICE) +fi + OUTDEV=$(echo "$RESULT" | awk -F: '{print $1}') OUTMODEL=$(echo "$RESULT" | awk -F: '{print $2}' | tr -cd '[:print:]') OUTTEMP=$(echo "$RESULT" | awk -F: '{print $3}')