CyberPower UPS

From ArchWiki
Revision as of 10:02, 14 August 2013 by Scarletxfi (Talk | contribs) (Install Procedure)

Jump to: navigation, search

This document describes how to install the CyberPower UPS daemon. The main advantage of using a CyberPower UPS is that it is cheap and it can communicate with your Linux box through either a RS-232 or USB serial connection. In the event of a prolonged power outage, should the CyberPower UPS lose most of its battery capacity, it can tell the Linux box to perform a safe shutdown.

Download and Extract the package

Download the PowerPanel tar.gz package from here: http://www.cpsww.com.au/products/ups_systems/Value_soho/value600ei.htm

tar -zxvf package

Install Procedure

The latest PowerPanel version 1.2.3-0, only include support for rc.d, as such some manual intervention is needed. Using the included install.sh file as template, it needs to be modified for systemd so it should look like this:

 vim install.sh
#!/bin/sh

#
# The PowerPanel for Linux Software Installation
#


#
# copy files
#

# PowerPanel for Linux client program
/bin/cp bin/pwrstat /usr/sbin

# PowerPanel for Linux daemon program 
/bin/cp bin/pwrstatd /usr/sbin

# Script command for event of power failure 
if [ ! -e /etc/pwrstatd-powerfail.sh ]; then    
	/bin/cp script/pwrstatd-powerfail.sh /etc
fi

# Script command for event of battery low 
if [ ! -e /etc/pwrstatd-lowbatt.sh ]; then    
	/bin/cp script/pwrstatd-lowbatt.sh /etc
fi

# Script command for e-mail notification
if [ ! -e /etc/pwrstatd-email.sh ]; then    
	/bin/cp script/pwrstatd-email.sh /etc
fi

# PowerPanel for Linux daemon configuration
if [ ! -e /etc/pwrstatd.conf ]; then   
	/bin/cp conf/pwrstatd.conf /etc
fi

# PowerPanel for Linux client man-page
if [ ! -e /usr/share/man/man8/pwrstat.8.gz ]; then   
	/bin/cp doc/pwrstat.8 /usr/share/man/man8
fi

# PowerPanel for Linux daemon man-page
if [ ! -e /usr/share/man/man8/pwrstatd.8.gz ]; then   
	/bin/cp doc/pwrstatd.8 /usr/share/man/man8
fi

#
# compress the man page file
#

if [ -e /usr/share/man/man8/pwrstat.8 ]; then
	if [ -e /usr/bin/gzip ]; then
		/usr/bin/gzip -9 /usr/share/man/man8/pwrstat.8
	else
		/bin/gzip -9 /usr/share/man/man8/pwrstat.8
	fi
fi

if [ -e /usr/share/man/man8/pwrstatd.8 ]; then
	if [ -e /usr/bin/gzip ]; then
		/usr/bin/gzip -9 /usr/share/man/man8/pwrstatd.8
	else
		/bin/gzip -9 /usr/share/man/man8/pwrstatd.8
	fi
fi


#
# Change the files owner
#

/bin/chown root:root /usr/sbin/pwrstat
/bin/chown root:root /usr/sbin/pwrstatd
/bin/chown root:root /etc/pwrstatd-powerfail.sh
/bin/chown root:root /etc/pwrstatd-lowbatt.sh
/bin/chown root:root /etc/pwrstatd-email.sh
/bin/chown root:root $STRATUP_DIR/$DAEMON
/bin/chown root:root /etc/pwrstatd.conf
/bin/chown root:root /usr/share/man/man8/pwrstat.8.gz
/bin/chown root:root /usr/share/man/man8/pwrstatd.8.gz

#
# Change the files mode
#

/bin/chmod 700 /usr/sbin/pwrstat
/bin/chmod 700 /usr/sbin/pwrstatd   
/bin/chmod 700 /etc/pwrstatd-powerfail.sh
/bin/chmod 700 /etc/pwrstatd-lowbatt.sh
/bin/chmod 700 /etc/pwrstatd-email.sh
/bin/chmod 700 $STRATUP_DIR/$DAEMON    
/bin/chmod 600 /etc/pwrstatd.conf
/bin/chmod 644 /usr/share/man/man8/pwrstat.8.gz
/bin/chmod 644 /usr/share/man/man8/pwrstatd.8.gz

if you try and run /usr/bin/pwrstat you should get "Daemon service is not found." So you need to create a custom service as below

# vim /etc/systemd/system/pwrstatd.service
[Unit]
Description&#61The PowerPanel Service for Linux to monitor CyberPower UPS

[Service]
Type&#61simple
ExecStart&#61/usr/sbin/pwrstatd

[Install]
WantedBy&#61multi-user.target

Run the service

#systemctl start pwrstatd
#systemctl enable pwrstatd

Then run #pwrstat -status

You should get something like this


The UPS information shows as following:

        Properties:
                Model Name...................  Value 1500E
                Firmware Number.............. BFF7104#7N5
                Rating Voltage............... 230 V
                Rating Power................. 900 Watt
 
        Current UPS status:
                State........................ Normal
                Power Supply by.............. Utility Power
                Utility Voltage.............. 230 V
                Output Voltage............... 230 V
                Battery Capacity............. 100 %
                Remaining Runtime............ 61 min.
                Load......................... 126 Watt(14 %)
                Line Interaction............. None
                Test Result.................. Unknown
                Last Power Event............. None