Ausgabe verbessert

This commit is contained in:
root 2019-10-22 22:40:55 +02:00
parent ddf6514b41
commit 1bc7e243c0

View File

@ -144,6 +144,12 @@ then
exit 1 exit 1
fi fi
#Vorbereitung für das Perfdata-Result
if [ -n "$PERFDATA" ]
then
PERFRESULT="|"
fi
for device in ${DEVICES[@]} for device in ${DEVICES[@]}
do do
@ -156,13 +162,13 @@ do
fi fi
OUTDEV=$(echo "$RESULT" | awk -F: '{print $1}') OUTDEV=$(echo "$RESULT" | awk -F: '{print $1}')
OUTMODEL=$(echo "$RESULT" | awk -F: '{print $2}' | tr -cd '[:print:]' | tr -s ' ' ' ' ) OUTMODEL=$(echo "$RESULT" | awk -F: '{print $2}' | tr -cd '[:print:]' | tr -s ' ' ' ' | sed -e 's/^ //')
OUTTEMP=$(echo "$RESULT" | awk -F: '{print $3}') OUTTEMP=$(echo "$RESULT" | awk -F: '{print $3}')
OUTTEMPCLEAN=$(echo "$OUTTEMP" | tr -dc '0-9') OUTTEMPCLEAN=$(echo "$OUTTEMP" | tr -dc '0-9')
#Debug #Debug
#echo -e "OUTDEV:\t$\"OUTDEV\"" #echo -e "OUTDEV:\t$\"$OUTDEV\""
#echo -e "OUTMODEL:\t$OUTMODEL\"" #echo -e "OUTMODEL:\t\"$OUTMODEL\""
#echo -e "OUTTEMP:\t\"$OUTTEMP\"" #echo -e "OUTTEMP:\t\"$OUTTEMP\""
#echo -e "OUTTEMPCLEAN:\t\"$OUTTEMPCLEAN\"" #echo -e "OUTTEMPCLEAN:\t\"$OUTTEMPCLEAN\""
@ -187,7 +193,7 @@ do
if [ "$OUTTEMPCLEAN" -lt "$WARNING" ] if [ "$OUTTEMPCLEAN" -lt "$WARNING" ]
then then
# OK - Status # OK - Status
ausgabe+="$OUTMODEL on $OUTDEV is $OUTTEMP " ausgabe+="\n$OUTMODEL on $OUTDEV is $OUTTEMP "
if [ "$exitausgabe" -gt "0" ] if [ "$exitausgabe" -gt "0" ]
then then
echo do nothing echo do nothing
@ -197,7 +203,7 @@ do
elif [ "$OUTTEMPCLEAN" -ge "$WARNING" ] && [ "$OUTTEMPCLEAN" -lt "$CRITICAL" ] elif [ "$OUTTEMPCLEAN" -ge "$WARNING" ] && [ "$OUTTEMPCLEAN" -lt "$CRITICAL" ]
then then
# WARNING - Status # WARNING - Status
ausgabe+="$OUTMODEL on $OUTDEV is $OUTTEMP " ausgabe+="\n$OUTMODEL on $OUTDEV is $OUTTEMP "
if [ "$exitausgabe" -gt "1" ] if [ "$exitausgabe" -gt "1" ]
then then
echo do nothing echo do nothing
@ -207,7 +213,7 @@ do
elif [ "$OUTTEMPCLEAN" = "999" ] elif [ "$OUTTEMPCLEAN" = "999" ]
then then
#CRITICAL - Status (kein S.M.A.R.T. verfügbar) #CRITICAL - Status (kein S.M.A.R.T. verfügbar)
ausgabe+="$OUTMODEL on $OUTDEV - no S.M.A.R.T.-Status " ausgabe+="\n$OUTMODEL on $OUTDEV - no S.M.A.R.T.-Status "
if [ "$exitausgabe" -gt "2" ] if [ "$exitausgabe" -gt "2" ]
then then
echo do nothing echo do nothing
@ -217,7 +223,7 @@ do
elif [ "$OUTTEMPCLEAN" -ge "$CRITICAL" ] elif [ "$OUTTEMPCLEAN" -ge "$CRITICAL" ]
then then
#CRITICAL - Status #CRITICAL - Status
ausgabe+="$OUTMODEL on $OUTDEV is $OUTTEMP " ausgabe+="\n$OUTMODEL on $OUTDEV is $OUTTEMP "
if [ "$exitausgabe" -gt "2" ] if [ "$exitausgabe" -gt "2" ]
then then
echo do nothing echo do nothing
@ -226,7 +232,7 @@ do
fi fi
else else
#UNKNOWN - Status #UNKNOWN - Status
ausgabe+="$OUTMODEL on $OUTDEV is $OUTTEMP " ausgabe+="\n$OUTMODEL on $OUTDEV is $OUTTEMP "
if [ "$exitausgabe" -gt "3" ] if [ "$exitausgabe" -gt "3" ]
then then
echo do nothing echo do nothing
@ -243,19 +249,19 @@ done
case $exitausgabe in case $exitausgabe in
"0") "0")
echo -e "OK - $ausgabe |$PERFRESULT" echo -e "OK $ausgabe $PERFRESULT"
exit 0 exit 0
;; ;;
"1") "1")
echo -e "WARNING - $ausgabe |$PERFRESULT" echo -e "WARNING $ausgabe $PERFRESULT"
exit 1 exit 1
;; ;;
"2") "2")
echo -e "CRITICAL - $ausgabe |$PERFRESULT" echo -e "CRITICAL $ausgabe $PERFRESULT"
exit 2 exit 2
;; ;;
"3") "3")
echo -e "UNKNOWN - $ausgabe |$PERFRESULT" echo -e "UNKNOWN $ausgabe $PERFRESULT"
exit 3 exit 3
;; ;;
*) *)