Page 1 of 1

[SOLVED] Installing an APC UPS on mageia 2

PostPosted: Nov 25th, '12, 17:58
by Plisgyn
I have just installed an APC CS 650 UPS on mageia 2. The apcupsd 3.14.10 64bit rpm is installed and I get the following results --

Code: Select all
cat /proc/bus/usb/devices


T:  Bus=07 Lev=02 Prnt=06 Port=02 Cnt=02 Dev#= 10 Spd=1.5  MxCh= 0
D:  Ver= 1.10 Cls=00(>ifc ) Sub=00 Prot=00 MxPS= 8 #Cfgs=  1
P:  Vendor=051d ProdID=0002 Rev= 0.06
S:  Manufacturer=American Power Conversion
S:  Product=Back-UPS CS 650 FW:817.v9.I USB FW:v9
S:  SerialNumber=4B1215P08180 
C:* #Ifs= 1 Cfg#= 1 Atr=e0 MxPwr=  0mA
I:* If#= 0 Alt= 0 #EPs= 1 Cls=03(HID  ) Sub=00 Prot=00 Driver=usbhid
E:  Ad=81(I) Atr=03(Int.) MxPS=   6 Ivl=100ms


Code: Select all
ls -l /sys/bus/usb/drivers/usbhid

drwxr-xr-x 2 root root 0 Nov 25 15:06 hub/
drwxr-xr-x 2 root root 0 Nov 25 15:06 usb/
drwxr-xr-x 2 root root 0 Nov 25 15:06 usbfs/
drwxr-xr-x 2 root root 0 Nov 25 15:06 usbhid/
drwxr-xr-x 2 root root 0 Nov 25 15:06 usb-storage/

Code: Select all
ls -al /dev/usb/

drwxr-xr-x  2 root root     80 Nov 25 15:09 ./
drwxr-xr-x 20 root root   4160 Nov 25 15:09 ../
crw-------  1 root root 180, 0 Nov 25 15:08 hiddev0
crw-------  1 root root 180, 1 Nov 25 15:09 hiddev1


So the UPS is being seen on its usb i/f but turning mains power off fails to cause a shutdown, so obviously I need to do some configuration, any assistance will be gratefully received.

Update After another reboot I now get a message "Power Failure Running on Battery" but it still will not shut down.

Re: Installing an APC UPS on mageia 2

PostPosted: Nov 27th, '12, 20:10
by linuxero
Are you sure apcupsd is running? Have you checked it in MCC->System->Services? Maybe it's not running..!

Re: Installing an APC UPS on mageia 2

PostPosted: Nov 27th, '12, 21:01
by Plisgyn
apcupsd is running

Re: Installing an APC UPS on mageia 2

PostPosted: Nov 27th, '12, 21:08
by linuxero
I am not sure but what is the entry of pf in /etc/inittab.

Maybe it's managed by systemd now!

Sorry..just speculating

Re: Installing an APC UPS on mageia 2

PostPosted: Nov 27th, '12, 22:07
by Plisgyn
/etc/inittab pf::powerfail:/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"

Re: Installing an APC UPS on mageia 2

PostPosted: Nov 27th, '12, 23:03
by doktor5000
Have you tried to execute that manually? AFAIR shutdown only supports -F option. Also, is there something in the logs when you disconnect mains power from the UPS?

Re: Installing an APC UPS on mageia 2

PostPosted: Nov 27th, '12, 23:56
by Plisgyn
Thanks doktor500
This was in the log -
Code: Select all
Nov 27 21:33:16 localhost apcupsd[1430]: Power failure.
Nov 27 21:33:22 localhost apcupsd[1430]: Running on UPS batteries.
Nov 27 21:33:22 localhost wall[3553]: wall: user root broadcasted 1 lines (55 chars)

I not quite sure how to run it manually?

Re: Installing an APC UPS on mageia 2

PostPosted: Nov 28th, '12, 07:59
by doktor5000
As root issue:
Code: Select all
/sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"

and wait if the system shuts down after 2 minutes.

Re: Installing an APC UPS on mageia 2

PostPosted: Nov 28th, '12, 08:43
by Plisgyn
I tried that and got the following -

Code: Select all
[root@localhost ~]# /sbin/shutdown -f -h +2 "Power Failure; System Shutting Down"
Unknown option code f
[root@localhost ~]#

Removing the -f option worked shutting down o/k now just to edit inittab to remove it.

UPDATE- Unfortunately editing inittab failed to work any more idea's?

Re: Installing an APC UPS on mageia 2

PostPosted: Nov 29th, '12, 22:19
by doktor5000
Please, try to provide more details in general. What did you change or try to change, to what did you change it, and how did it fail, with what error message?
What does inittab currently contain?

Re: Installing an APC UPS on mageia 2 [Solved]

PostPosted: Nov 30th, '12, 18:25
by Plisgyn
By accident I found out that the UPS was shutting the system down. I had to answer the phone and on my return the system was shutdown.
In /var/log/apcupsd.events was the following -
Code: Select all
2012-11-29 22:42:52 +0000  Power failure.
2012-11-29 22:42:58 +0000  Running on UPS batteries.
2012-11-29 22:50:06 +0000  Reached remaining time percentage limit on batteries.
2012-11-29 22:50:06 +0000  Initiating system shutdown!
2012-11-29 22:50:06 +0000  User logins prohibited
2012-11-29 22:50:06 +0000  apcupsd exiting, signal 15
2012-11-29 22:50:06 +0000  apcupsd shutdown succeeded

This shutdown had taken 8 minutes approx to happen whereas before I was giving up after 4 minutes.
In /etc/apcupsd/apcupsd.conf was -
Code: Select all
# If during a power failure, the UPS has run on batteries for TIMEOUT
# many seconds or longer, apcupsd will initiate a system shutdown.
# A value of 0 disables this timer.
#
#  Note, if you have a Smart UPS, you will most likely want to disable
#    this timer by setting it to zero. That way, you UPS will continue
#    on batteries until either the % charge remaing drops to or below BATTERYLEVEL,
#    or the remaining battery runtime drops to or below MINUTES.  Of course,
#    if you are testing, setting this to 60 causes a quick system shutdown
#    if you pull the power plug.
#  If you have an older dumb UPS, you will want to set this to less than
#    the time you know you can run on batteries.
TIMEOUT 0

Changing this to -
Code: Select all
# If during a power failure, the UPS has run on batteries for TIMEOUT
# many seconds or longer, apcupsd will initiate a system shutdown.
# A value of 0 disables this timer.
#
#  Note, if you have a Smart UPS, you will most likely want to disable
#    this timer by setting it to zero. That way, you UPS will continue
#    on batteries until either the % charge remaing drops to or below BATTERYLEVEL,
#    or the remaining battery runtime drops to or below MINUTES.  Of course,
#    if you are testing, setting this to 60 causes a quick system shutdown
#    if you pull the power plug.
#  If you have an older dumb UPS, you will want to set this to less than
#    the time you know you can run on batteries.
TIMEOUT 180

Now testing mains failure again in /var/log/apcupsd.events
Code: Select all
2012-11-30 14:45:44 +0000  Power failure.
2012-11-30 14:45:50 +0000  Running on UPS batteries.
2012-11-30 14:48:51 +0000  Reached run time limit on batteries.
2012-11-30 14:48:51 +0000  Initiating system shutdown!
2012-11-30 14:48:51 +0000  User logins prohibited
2012-11-30 14:48:52 +0000  apcupsd exiting, signal 15
2012-11-30 14:48:52 +0000  apcupsd shutdown succeeded

It now shutsdown in 3 minutes and I now consider the problem solved. Thanks to everybody who tried to help.