#!/bin/bash # Syn-3 apc ups checker (C) DatuX if ! STATUS=`apcaccess | grep ^STATUS`; then syn3-state --ignorenew apcupsd ALERT "APC UPS not found!" elif echo $STATUS | grep ONLINE >/dev/null; then syn3-state apcupsd OK "UPS is online." elif echo $STATUS | grep ONBATT >/dev/null; then syn3-state apcupsd ALERT "Power failure! Running on battery!" elif echo $STATUS | grep SHUTTING >/dev/null; then syn3-state apcupsd ALERT "UPS battery almost empty, shutting down system." elif echo $STATUS | grep COMMLOST >/dev/null; then syn3-state --ignorenew apcupsd ALERT "Communication failure! Please check UPS status and cables." elif echo $STATUS | grep REPLACE >/dev/null; then syn3-state apcupsd CAUTION "UPS battery needs to be replaced!" else syn3-state apcupsd ALERT "UPS reports status: $STATUS. Please check UPS status." fi