martes, junio 01, 2010

FreeBSD + APCUPSD

Requerimientos:

FreeBSD instalado
UPS APC con tarjeta AP9619 conectada al servidor

Manuales:
/usr/local/share/doc/apcupsd/apcupsd.pdf
http://www.apcupsd.com/manual/manual.pdf
http://www.apcupsd.com/
http://www.freebsddiary.org/apcupsd.php
http://www.packetwatch.net/documents/guides/2010031301.php

Instrucciones:

1) Instalar el port apcupsd-3.14.8
# whereis apcupsd
apcupsd: /usr/ports/sysutils/apcupsd
# cd /usr/ports/sysutils/apcupsd
# make config
[X] APCSMART_DRV Compile APC SmartUPS serial driver
[X] APCDUMB_DRV Compile dumb UPS driver
[ ] CLIENT_ONLY Only NIS client (no network server or drivers)
[X] CGI Compile with CGI programs to show status
[X] PCNET_DRV Compile PowerChute Network Shutdown driver
[X] USB Compile with USB Support driver
[X] SNMP_DRV Compile with SNMP driver
[ ] SNMP_DRV_OLD Compile with old SNMP driver
[X] TCP_WRAPPERS Compile with TCP_WRAPPERS support
[ ] TEST_DRV Compile TEST driver
[ ] GAPCMON Build GTK GUI front-end

[ OK ]

# make install clean
---
**********************************************************************
Read the manual

/usr/local/share/doc/apcupsd/apcupsd.pdf

to do site specific configuration assigenments! Especially have a
detailed look into the chapter describing the shutdown procedure.

Sample files are installed in /usr/local/etc/apcupsd. These files
must be copied and/or configured for a proper working apcupsd.
You need to modify /usr/local/etc/apcupsd/apcupsd.conf as follows:

For serial cable: DEVICE /dev/cuadX (or /dev/cuaaX for [45.]x)
For USB cable: DEVICE (yes, leave it blank after DEVICE)

NOTE that for USB cable you must comment out the line

device uhid # "Human Interface Devices"

in your kernel configuration file and recompile the kernel.
Your keyboard and mouse will still work.

WARNING USB support on FreeBSD is still considered BETA!

Add apcupsd_enable=YES to your /etc/rc.conf[.local] to have apcupsd
starting up at boot time.

**********************************************************************
---

2) Configurar APCUPSD
# cd /usr/local/etc/apcupsd
# ls
apccontrol apcupsd.conf.sample apcupsd.css.sample changeme commok
hosts.conf.sample multimon.conf.sample onbattery apcupsd.conf
apcupsd.css cgi commfailure hosts.conf multimon.conf offbattery
# cp apcupsd.conf apcupsd.conf.sample
# cp apccontrol apccontrol.sample
# edit apcupsd.conf

# egrep -v '#|^ *$' apcupsd.conf
---
UPSNAME SURT10000XLT-1TF10K
UPSCABLE ether
UPSTYPE snmp
DEVICE 192.168.1.187:161:APC:private
POLLTIME 60
LOCKFILE /var/spool/lock
SCRIPTDIR /usr/local/etc/apcupsd
PWRFAILDIR /var/run
NOLOGINDIR /var/run
ONBATTERYDELAY 6
BATTERYLEVEL 5
MINUTES 3
TIMEOUT 0
ANNOY 300
ANNOYDELAY 60
NOLOGON disable
KILLDELAY 0
NETSERVER on
NISIP 0.0.0.0
NISPORT 3551
EVENTSFILE /var/log/apcupsd.events
EVENTSFILEMAX 10
UPSCLASS standalone
UPSMODE disable
STATTIME 0
STATFILE /var/log/apcupsd.status
LOGSTATS off
DATATIME 0
---

# touch /var/log/apcupsd.events
# touch /var/log/apcupsd.status

# edit hosts.conf
# egrep -v '#|^ *$' hosts.conf
---
MONITOR 127.0.0.1 "SURT10000XLT-1TF10K"
---

# edit multimon.conf
# egrep -v '#|^ *$' multimon.conf
---
TEMPC
FIELD SYSTEM "System" ""
FIELD MODEL "Model" ""
FIELD STATUS "Status" ""
FIELD battpct "Battery Chg" "%"
FIELD utility "Utility" "VAC"
FIELD loadpct "UPS Load" "%"
FIELD UPSTEMP "UPS Temp" ""
FIELD runtime "Batt. Run Time" "min."
FIELD DATA "Data" "All data"
---

3) Verificar que en el firewall se pueda acceder al puerto TCP 3551 del servidor desde la LAN

4) Editar el archivo /etc/rc.conf para agregar las lineas de APCUPSD para que inicie con el equipo

# edit /etc/rc.conf
---
# Activamos apcupsd (Si tengo una UPS marca APC)
apcupsd_enable="YES"
---

5) Crear el sitio en APACHE para monitorear la UPS remotamente por WWW ([X] CGI) agregando unas lineas
# edit /usr/local/etc/apache22/httpd.conf
---
# Modificacion para APCUPSD inicio
<Directory /usr/local/etc/apcupsd>
AllowOverride Options FileInfo
Order deny,allow
Allow from all
</Directory>
<Directory /usr/local/etc/apcupsd/cgi>
Options ExecCGI
</Directory>
ScriptAlias /apcupsd/cgi/ /usr/local/etc/apcupsd/cgi/
Alias /apcupsd /usr/local/etc/apcupsd/
# Modificacion para APCUPSD fin
---

Re-iniciar APACHE
# /usr/local/etc/rc.d/apache22 restart

6) Ajustar los parametros de la UPS
PARAMETROS DE LA UPS
IP Address: 192.168.1.187
Mask: 255.255.255.0
Gateway: 192.168.1.1

Tarjeta AP9619 S/N:
MAC Address 00:C0:B7:80:CA:D1

Enviarle la IP a la tarjeta desde FreeBSD
# arp -s 192.168.1.187 00:C0:B7:80:CA:D1
# ping 192.168.1.187 -s 113

Entrar por telnet a la ip de la tarjeta
# telnet 192.168.1.187

Login: apc
Passwd: apc

7) Iniciar el servicio
# /usr/local/etc/rc.d/apcupsd start

8) Monitorear la UPS via WWW, entrar a:
http://ipdemiserver/apcupsd/cgi/multimon.cgi

9) apcaccess Test
# apcaccess status
---
APC : 001,048,1167
DATE : 2010-09-01 07:36:10 -0500
HOSTNAME : alpha.company.com
VERSION : 3.14.8 (16 January 2010) freebsd
UPSNAME : UPS_IDEN
CABLE : Ethernet Link
MODEL : SNMP UPS Driver
UPSMODE : Stand Alone
STARTTIME: 2010-08-31 06:34:22 -0500
STATUS : ONLINE
LINEV : 205.0 Volts
LOADPCT : 38.0 Percent Load Capacity
BCHARGE : 100.0 Percent
TIMELEFT : 19.0 Minutes
MBATTCHG : 5 Percent
MINTIMEL : 3 Minutes
MAXTIME : 0 Seconds
MAXLINEV : 205.0 Volts
MINLINEV : 204.0 Volts
OUTPUTV : 207.0 Volts
SENSE : Unknown
DWAKE : 000 Seconds
DSHUTD : 020 Seconds
DLOWBATT : 02 Minutes
LOTRANS : 146.0 Volts
HITRANS : 229.0 Volts
RETPCT : 000.0 Percent
ITEMP : 34.0 C Internal
ALARMDEL : 5 seconds
BATTV : 214.0 Volts
LINEFREQ : 59.0 Hz
LASTXFER : Unacceptable line voltage changes
NUMXFERS : 0
TONBATT : 0 seconds
CUMONBATT: 0 seconds
XOFFBATT : N/A
SELFTEST : OK
STESTI : 336
STATFLAG : 0x07000008 Status Flag
MANDATE : 07/19/06
SERIALNO : NS0630013487
BATTDATE : 07/19/06
NOMOUTV : 208 Volts
NOMBATTV : 4294967295.0 Volts
EXTBATTS : 1
BADBATTS : -1
FIRMWARE : 476.17.W
APCMODEL : Smart-UPS RT 10000
END APC : 2010-09-01 07:37:10 -0500
---

10) APCUPSD SLAVE:
Se instala y configura en modo slave, estos son equipos que aunque reciben
energia de la UPS no estan conectados directamente a ella.

Nota:
La ip del servidor que corre APCUPSD en modo MASTER es 192.168.1.1

Parametros para los SLAVE en apcupsd.conf
UPSCABLE ether
UPSTYPE net
DEVICE 192.168.1.1:3551

WINDOWS
Cliente http://sourceforge.net/projects/apcupsd/files/win-binaries%20-%20Stable/
C:\apcupsd\etc\apcupsd\apcupsd.conf
Log
C:\apcupsd\etc\apcupsd\apcupsd.events

GNU/LINUX UBUNTU
$ sudo su
[sudo] password for angel:
# gedit /etc/apcupsd/apcupsd.conf
# gedit /etc/default/apcupsd
cambiar
ISCONFIGURED=no
por
ISCONFIGURED=yes

GNU/LINUX SUSE
YaST / Software / Software Management
apcupsd
# gedit /etc/apcupsd/apcupsd.conf
YaST / System / System Services (Runlevel)
apcupsd
Enable

MAC OS X
Configurar
sudo vi /private/etc/apcupsd/apcupsd.conf

Desinstalar
sudo /sbin/apcupsd-uninstall

FreeBSD
Configurar
# edit /usr/local/etc/apcupsd/apcupsd.conf
# edit /etc/rc.conf
apcupsd_enable="YES"
# /usr/local/etc/rc.d/apcupsd start
# exit