#! /bin/sh

#  Copyright (c) 1998 by Martin Schulze <joey@infodrom.north.de>
#  Released under the terms of the GNU General Public Licence v2 or higher

conf=/etc/apcd.conf

test -f $conf || exit 0

if grep '^#!Unconfigured!' $conf >/dev/null; then
   echo "APC daemon unconfigured."
   exit 0
fi

set -- `grep ^LOGFILENAME $conf`
logfile=$2

test -n "$logfile" || exit 0

if [ -f $logfile ]; then
   set -- `tail -1 $logfile`

   # Remove the date
   date="$1 $2 $3 $4 $5"
   shift;shift;shift;shift;shift;shift;

   echo "Battery load ..: ${1}%"
   echo "UPS load. .....: ${4}"
   echo "UPS temperature: ${8}"
   echo "Battery voltage: ${9}V"
   echo "Line voltage ..: ${6}V (${2}V - ${3}V)"
   echo "Output voltage.: ${7}V"
   echo "Line frequency : ${5}Hz"
   echo "Status from ...: $date"

fi
