ONLINE-USV Check

Leider ist das verwendete upsmon sehr, sehr langsam.

Lokaler Check, kopieren nach: /usr/lib/check_mk_agent/local/onlineusv

#!/bin/bash
#
# 08/2011 Matthias Henze
# Lizenz: GPL v2
#
# Check für ONLINE USVs auf Basis der mitgeliefereten Software "upsman"

if [ ! -x /usr/ups/upsmon ]; then
  exit 0
fi

PASSWORD=passwort # upsman Passwort
CRIT=5            # Minuten f. Status CRITICAL
WARN=1            # Minuten f. Status WARNING
MAX=40            # Maximale Minuten f. Performancedaten

read -a USV_STATUS <<< $(/usr/ups/upsmon -v $PASSWORD | grep "UPS-Status:")
read -a USV_CTIME <<< $(/usr/ups/upsmon -i autonom $PASSWORD | grep "ups answer:")
read -d "." -a USV_TIME <<< $(echo ${USV_CTIME[2]})

#echo ${USV_STATUS[1]}
#echo ${USV_CTIME[2]}
#echo ${USV_TIME[0]}

case ${USV_STATUS[1]} in
  "ok")
	STATUS=0
	TEXT="OK, autonomy time: "${USV_TIME[0]}" minutes"
	;;
  "powerfail")
	TEXT="PROBLEM: Poerfail, time remaining "${USV_TIME[0]}" minutes"
	if [ ${USV_TIME[0]} -lt $CRIT ]; then
		STATUS=1
	elif [ ${USV_TIME[0]} -lt $WARN ]; then
		STATUS=1
	fi
	;;
  *)
	STATUS=3
	TEXT="UNKNOWN"
	;;
esac


echo $STATUS" ONLINE-USV time=${USV_TIME[0]};$WARN;$CRIT;0;$MAX "$TEXT