Multidevice hinzugefügt
This commit is contained in:
parent
5e2e85d481
commit
7c86451e5f
@ -63,7 +63,7 @@ function ParameterEvaluation(){
|
||||
case "$1" in
|
||||
"-d"|"--device")
|
||||
shift; # The arg is next in position args
|
||||
DEVICE="$1"
|
||||
DEVICES+=("$1")
|
||||
;;
|
||||
"--celsius")
|
||||
UNIT="c"
|
||||
@ -115,7 +115,10 @@ ParameterEvaluation "$0" "$@"
|
||||
#Debug
|
||||
#echo -e "WARNING:\t\"$WARNING\""
|
||||
#echo -e "CRITICAL:\t\"$CRITICAL\""
|
||||
#echo -e "DEVICE:\t\t\"$DEVICE\""
|
||||
#for device in ${DEVICES[@]}
|
||||
#do
|
||||
# echo -e "device: \"$device\""
|
||||
#done
|
||||
#echo -e "HELP\t\t\"$HELP\""
|
||||
#echo -e "PERFDATA\t\t\"$PERFDATA\""
|
||||
#echo -e "Alle Args:\t\"$@\""
|
||||
@ -128,70 +131,118 @@ then
|
||||
fi
|
||||
|
||||
#Check, if device is a block-device
|
||||
if [ ! -b "$DEVICE" ]
|
||||
for device in ${DEVICES[@]}
|
||||
do
|
||||
if [ ! -b "$device" ]
|
||||
then
|
||||
echo "Device $device does not exist or is not a block-Device"
|
||||
exitvar=1
|
||||
fi
|
||||
done
|
||||
if [ "$exitvar" = "1" ]
|
||||
then
|
||||
echo "Device $DEVICE does not exist or is not a block-Device"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
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}')
|
||||
OUTTEMPCLEAN=$(echo "$OUTTEMP" | tr -dc '0-9')
|
||||
for device in ${DEVICES[@]}
|
||||
do
|
||||
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}')
|
||||
OUTTEMPCLEAN=$(echo "$OUTTEMP" | tr -dc '0-9')
|
||||
|
||||
#Debug
|
||||
#echo -e "OUTDEV:\t$OUTDEV"
|
||||
#echo -e "OUTDEVmodel:\t$OUTDEVmodel"
|
||||
#echo -e "OUTTEMP:\t$OUTTEMP"
|
||||
#echo -e "OUTTEMPCLEAN:\t$OUTTEMPCLEAN"
|
||||
|
||||
#Erstellen des Perfdata-Results
|
||||
if [ -n "$PERFDATA" ]
|
||||
then
|
||||
#perfdata: temperatur=<temperatur>;<warn>;<crit>
|
||||
PERFRESULT+=" $(echo "$OUTDEV" | awk -F "/" '{print $NF}')=$OUTTEMPCLEAN;$WARNING;$CRITICAL"
|
||||
fi
|
||||
|
||||
#initialisierung der Varible
|
||||
exitausgabe="0"
|
||||
#Auswertung der Temperaturen
|
||||
if [ "$OUTTEMPCLEAN" -lt "$WARNING" ]
|
||||
then
|
||||
# OK - Status
|
||||
ausgabe+="$OUTMODEL on $OUTDEV is $OUTTEMP "
|
||||
if [ "$exitausgabe" -gt "0" ]
|
||||
then
|
||||
echo do nothing
|
||||
else
|
||||
exitausgabe="0"
|
||||
fi
|
||||
elif [ "$OUTTEMPCLEAN" -ge "$WARNING" ] && [ "$OUTTEMPCLEAN" -lt "$CRITICAL" ]
|
||||
then
|
||||
# WARNING - Status
|
||||
ausgabe+="$OUTMODEL on $OUTDEV is $OUTTEMP "
|
||||
if [ "$exitausgabe" -gt "1" ]
|
||||
then
|
||||
echo do nothing
|
||||
else
|
||||
exitausgabe="1"
|
||||
fi
|
||||
elif [ "$OUTTEMPCLEAN" -ge "$CRITICAL" ]
|
||||
then
|
||||
#CRITICAL - Status
|
||||
ausgabe+="$OUTMODEL on $OUTDEV is $OUTTEMP "
|
||||
if [ "$exitausgabe" -gt "2" ]
|
||||
then
|
||||
echo do nothing
|
||||
else
|
||||
exitausgabe="2"
|
||||
fi
|
||||
else
|
||||
#UNKNOWN - Status
|
||||
ausgabe+="$OUTMODEL on $OUTDEV is $OUTTEMP "
|
||||
if [ "$exitausgabe" -gt "3" ]
|
||||
then
|
||||
echo do nothing
|
||||
else
|
||||
exitausgabe="3"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
#Debug
|
||||
#echo -e "OUTDEV:\t$OUTDEV"
|
||||
#echo -e "OUTDEVmodel:\t$OUTDEVmodel"
|
||||
#echo -e "OUTTEMP:\t$OUTTEMP"
|
||||
#echo -e "OUTTEMPCLEAN:\t$OUTTEMPCLEAN"
|
||||
#echo -e "Ausgabe:\t$ausgabe"
|
||||
#echo -e "PERFRESULT:\t$PERFRESULT"
|
||||
#echo -e "exitausgbe:\t$exitausgabe"
|
||||
|
||||
#Erstellen des Perfdata-Results
|
||||
if [ -n "$PERFDATA" ]
|
||||
then
|
||||
#perfdata: temperatur=<temperatur>;<warn>;<crit>
|
||||
PERFRESULT="| $(echo "$OUTDEV" | awk -F "/" '{print $NF}')=$OUTTEMPCLEAN;$WARNING;$CRITICAL"
|
||||
fi
|
||||
case $exitausgabe in
|
||||
"0")
|
||||
echo -e "OK - $ausgabe |$PERFRESULT"
|
||||
exit 0
|
||||
;;
|
||||
"1")
|
||||
echo -e "WARNING - $ausgabe |$PERFRESULT"
|
||||
exit 1
|
||||
;;
|
||||
"2")
|
||||
echo -e "CRITICAL - $ausgabe |$PERFRESULT"
|
||||
exit 2
|
||||
;;
|
||||
"3")
|
||||
echo -e "UNKNOWN - $ausgabe |$PERFRESULT"
|
||||
exit 3
|
||||
;;
|
||||
*)
|
||||
echo -e "UNKNOWN - Error"
|
||||
exit 3
|
||||
|
||||
#Auswertung der Temperaturen
|
||||
if [ "$OUTTEMPCLEAN" -lt "$WARNING" ]
|
||||
then
|
||||
echo "OK - $OUTMODEL on $OUTDEV is $OUTTEMP $PERFRESULT"
|
||||
exit 0
|
||||
elif [ "$OUTTEMPCLEAN" -ge "$WARNING" ] && [ "$OUTTEMPCLEAN" -lt "$CRITICAL" ]
|
||||
then
|
||||
echo "WARNING - $OUTMODEL on $OUTDEV is $OUTTEMP $PERFRESULT"
|
||||
exit 1
|
||||
elif [ "$OUTTEMPCLEAN" -ge "$CRITICAL" ]
|
||||
then
|
||||
echo "CRITICAL - $OUTMODEL on $OUTDEV is $OUTTEMP $PERFRESULT"
|
||||
exit 2
|
||||
else
|
||||
echo "UNKNOWN - $OUTMODEL on $OUTDEV is $OUTTEMP $PERFRESULT"
|
||||
exit 3
|
||||
fi
|
||||
esac
|
||||
|
||||
|
||||
|
||||
if [ -z "$WARNING" ] && [ -z "$CRITICAL" ]
|
||||
then
|
||||
#Debug
|
||||
echo "WARNING and CRITICAL are zero"
|
||||
|
||||
echo "OK - $OUTMODEL on $OUTDEV is $OUTTEMP"
|
||||
exit 0
|
||||
|
||||
elif [ -n "$WARNING" ] && [ -n "$CRITICAL" ]]
|
||||
then
|
||||
#Debug
|
||||
echo "WARNING is non-zero and CRITICAL is non-zero"
|
||||
echo
|
||||
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user