Celsius und Fahrenheit hinzugefügt
This commit is contained in:
parent
74cd82923c
commit
494e3ae4f7
@ -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}')
|
||||
|
Loading…
Reference in New Issue
Block a user