Al fin pude meterle mano a la UPS APC, la tarea simplemente consiste en conectarla mediante el cable USB a un equipo con debian y desde el cual logré apagar correctamente todos los servidores antes de que se quede sin bateria.
# apt-get install apcupsd
Luego editar el /etc/default/apcupsd y configurar en ISCONFIGURED en yes
#vim /etc/default/apcupsd
ISCONFIGURED=yes
Verifico que la UPS este visible en el servidor
#lsusb
Bus 004 Device 002: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
OK con el paso anterior procedo con la configuración del apcupsd
# vim /etc/apcupsd/apcupsd.conf
Como siempre, estos son solo algunos de los parámetros que se pueden modificar, hay muchos más y cada uno tiene su descripción. Con modificar estos a mi me quedo andando.
Nombre de la UPSUPSNAME UPS1
Típo de conexiónUPSCABLE usb
DEVICE
Tiempo en segundos desde que un fallo de alimentación se detecta hasta que reaccionamos con un evento en la batería, por default esta en 6ONBATTERYDELAY 6
Si durante un corte de energía, el porcentaje restante de la batería (según lo informado por el SAI) es inferior o igual al nivel de la batería, apcupsd iniciará un apagado del sistema LinuxBATTERYLEVEL 5
Si durante un corte de energía, el tiempo de ejecución restante en minutos (según lo calculado internamente por el SAI) es inferior o igual a minutos, apcupsd, iniciará un apagado del sistema. MINUTES 10
Si sobra bateria para muchos TIMEOUT más, apcupsd iniciará un apagado del sistema.TIMEOUT 0
Para utilizar el apcupsd para proporcionar informacion a porgramas CGI, colocar en OFFNETSERVER off
Accesible solo desdeNISIP 127.0.0.1
Puerto NISPORT 3551
Soluciona el error “Error contacting apcupsd @ localhost:3551: Connection refused”
STATTIME 1
LOGSTATS on
DATATIME 1
Testeando la conectividad con la UPS
# apctest 2016-07-11 15:22:21 apctest 3.14.10 (13 September 2011) debian Checking configuration ... Attached to driver: usb sharenet.type = Network & ShareUPS Disabled cable.type = USB Cable mode.type = USB UPS Driver Setting up the port ... Doing prep_device() ... You are using a USB cable type, so I'm entering USB test mode Hello, this is the apcupsd Cable Test program. This part of apctest is for testing USB UPSes. Getting UPS capabilities...SUCCESS Please select the function you want to perform. 1) Test kill UPS power 2) Perform self-test 3) Read last self-test result 4) View/Change battery date 5) View manufacturing date 6) View/Change alarm behavior 7) View/Change sensitivity 8) View/Change low transfer voltage 9) View/Change high transfer voltage 10) Perform battery calibration 11) Test alarm 12) View/Change self-test interval Q) Quit Select function number:
Si llegue hasta acá y por ejemplo el test 11 dio exitoso puemos estar algo contento, aunque aun falta
Inicio el demonio de apcupsd
#service apcupsd start
Verifico la conectividad con la UPS
#apcaccess
Ejemplo de salida:
APC : 001,043,xxxx DATE : 2016-07-11 15:28:09 -0300 HOSTNAME : xxxxx VERSION : 3.14.10 (13 September 2011) debian UPSNAME : SMART3000 CABLE : USB Cable DRIVER : USB UPS Driver UPSMODE : Stand Alone STARTTIME: 2016-07-11 15:25:35 -0300 MODEL : Smart-UPS 3000 XL STATUS : ONLINE LINEV : 217.4 Volts LOADPCT : 22.7 Percent Load Capacity BCHARGE : 100.0 Percent TIMELEFT : 41.0 Minutes MBATTCHG : 5 Percent MINTIMEL : 10 Minutes MAXTIME : 0 Seconds OUTPUTV : 217.4 Volts SENSE : Low DWAKE : -01 Seconds DSHUTD : 180 Seconds LOTRANS : 200.0 Volts HITRANS : 253.0 Volts RETPCT : 015.0 Percent ITEMP : 19.3 C Internal ALARMDEL : 30 seconds BATTV : 55.1 Volts LINEFREQ : 50.0 Hz LASTXFER : No transfers since turnon NUMXFERS : 0 TONBATT : 0 seconds CUMONBATT: 0 seconds XOFFBATT : N/A SELFTEST : NO STESTI : 14 days STATFLAG : 0x07000008 Status Flag MANDATE : 2013-11-30 SERIALNO : xxxxxxxxxxx BATTDATE : 2014-08-01 NOMOUTV : 220 Volts NOMBATTV : 48.0 Volts FIRMWARE : 691.19.I USB FW:7.4 END APC : 2016-07-11 15:28:10 -0300
Verificado y probado todo, ya es hora de apagar los servidores
#apt-get install putty
Editar el script de apagado y agregar los equipos que queremos apagar + alguna notificacion por correo
# vim /etc/apcupsd/killpower
En mi caso el script quedo algo asi
plink -ssh -2 -pw clave123 root@192.168.1.2 '/sbin/poweroff' plink -ssh -2 -pw clave123 root@192.168.1.3 '/sbin/poweroff' plink -ssh -2 -pw clave123 root@192.168.1.4 '/sbin/poweroff'
Desde luego que esta es la base y sobre la misma se pueden realizar muchas modificaciones acorde a las necesidades y preferencias de cada uno.
Mas informacion en: http://www.apcupsd.org/manual/manual.html#apcupsd-notification-and-events