NUT installation

NUT (Network UPS Tool) is a group of tools to administer Uninterruptible Power Systems which ensure the continuous suply for our equipment.

With this article we install and configure the tool in a Debian etch.

I will configure an UPS BELKIN SurgeMaster of 650 VA. But you can see the compatibility with operating system and NUT, of your UPS, in the URL: http://www.networkupstools.org/compat/stable.html.

I am based en my reference table:

Origin http://www.networkupstools.org/
Repository apt
Package Nut 2.0.4
Documentation (spanish) http://www.servitux.org/view.php/page/sai
Documentation (english) http://www.networkupstools.org/doc/2.0.1/

Install the package:

elite:~# apt-get install nut nut-snmp nut-usb
Leyendo lista de paquetes... Hecho
Creando árbol de dependencias... Hecho
Se instalarán los siguientes paquetes extras:
  libsensors3 libsnmp-base libsnmp9 libsysfs2
Paquetes sugeridos:
  lm-sensors nut-cgi nut-dev
Se instalarán los siguientes paquetes NUEVOS:
  libsensors3 libsnmp-base libsnmp9 libsysfs2 nut nut-snmp nut-usb
0 actualizados, 7 se instalarán, 0 para eliminar y 1 no actualizados.
Se necesita descargar 3122kB/4432kB de archivos.
Se utilizarán 9847kB de espacio de disco adicional después de desempaquetar.

SNMP tools to centralize the network information of the systems, and usb tool to connect the hardware through USB ports.

In the file /etc/default/nut, we write the variables to initialize the servers:

# start upsd
START_UPSD=yes

# start upsmon
START_UPSMON=yes

Add the nut user to the group dialout which controls the serial interfaces:

elite:~#  adduser nut dialout

Create the configuration files:

cp /usr/share/doc/nut/examples/ups.conf /etc/nut/
cp /usr/share/doc/nut/examples/upsd.users /etc/nut/
cp /usr/share/doc/nut/examples/upsd.conf /etc/nut/
cp /usr/share/doc/nut/examples/upsmon.conf.gz /etc/nut/
gzip -d /etc/nut/upsmon.conf.gz

In ups.conf:

[misai]
        driver = megatec
          port = /dev/ttyS0

The upsd.conf leave equal, it is the server daemon configuration.
Theupsd.users is:

[admin]
        password = upssai
        allowfrom = localhost
        actions = SET
        instcmds = ALL

[control]
        password = upssai
        allowfrom = localhost
        upsmon master

[clientes]
        password = upssai
        allowfrom = negro
        upsmon slave

Appears “negro” as SAI client, it is a desktop PC which is connected to the SAI. Really I do not want “negro” monitorice (it is a windows system), but I want previous the server shutdown, the server sends it a shutdown order.

In upsmon.conf add in order:

MONITOR misai@localhost 1 control upssai master

SHUTDOWNCMD "/etc/nut/apagado_sistema.sh"

NOTIFYCMD /etc/nut/mensaje-ups.sh

NOTIFYMSG ONLINE "UPS %s en estado normal"
NOTIFYMSG ONBATT "Alguien ha quitado el cable del SAI %s"
NOTIFYMSG LOWBATT "Bateria demasiado baja"
NOTIFYMSG FSD "Ha llegado el momento de apagar el SAI"
NOTIFYMSG COMMOK "Fiiiuuu, ya puedo volver a hablar con el SAI"
NOTIFYMSG COMMBAD "Otiiaa, que el SAI no me habla"
NOTIFYMSG SHUTDOWN "Apagando!"
NOTIFYMSG REPLBATT "Macho, ves cambiando la bateria"

NOTIFYFLAG ONLINE SYSLOG+EXEC
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG FSD SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+EXEC
NOTIFYFLAG COMMBAD SYSLOG+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+EXEC
NOTIFYFLAG REPLBATT SYSLOG+EXEC

Create the message batch to notify mensaje-ups.sh:

#!/bin/sh

echo "
ATENCION
----------------------

MENSAJE DEL SAI: $NOTIFYTYPE" | mail -s "MENSAJE DEL SAI" admin@lebrijo.com

Create the script with shutdown orders apagado_sistema.sh:

#!/bin/sh

# Apagamos el PC de escritorio (si estuviera encendido)
ssh -i /etc/nut/rsa_ups ups@negro.lebrijo.com "shutdown -s –f"
# Apagamos el servidor elite
/sbin/shutdown -h +0

Change the file permissions to execute them:

chmod 744 /etc/nut/*.sh

In a future entry we will see how to configure a sshd server in Windows to receive the las order.

Leave a Reply

Your email address will not be published. Required fields are marked *