Successfully tested on Ubuntu Server 10.04 LTS 64-bit
Running a Linux server without taking care of possible power failures is not a good idea. A power outage can be disastrous for your valuable data if the server is not connected to an emergency power system, notified of the outage and able to properly shutdown the system while on battery power. With an Ubuntu home server, this kind of situations can be handled using a UPS (Uninterruptible Power Supply) and Network UPS Tools (NUT).
First, install NUT:
apt-get install nut
Next, declare your UPS in /etc/nut/ups.conf
(I use an MGE Protection Center 675 so don’t forget to modify the driver value according to your own UPS model, as found in NUT documentation):
[ups]
driver = usbhid-ups
port = auto
desc = "MGE UPS SYSTEMS Protection Center 675"
In /etc/nut/nut.conf
, set NUT daemon to run in standalone mode. It’s the mode to use on the machine to which the UPS is connected and when this same machine also monitors the UPS:
MODE = standalone
In /etc/nut/upsd.conf
, bind a listening port to the LAN interface if you want to allow other LAN hosts to monitor the UPS through upsd, the UPS network daemon. If not, just keep the first line:
LISTEN 127.0.0.1
LISTEN 192.168.253.2
Set the permissions for upsd in /etc/nut/upsd.users
. Only the users (one section = one user) listed in this file will be allowed to read the UPS state:
[upsmonitor]
password = password1
upsmon master
[monuser]
password = password2
upsmon slave
(the [monuser]
section is optional and only added here to allow a LAN host to monitor the UPS state over the network)
Now, configure the upsmon daemon. Its role is to communicate with upsd to know the UPS status and send specific commands when some events occur. Modify /etc/nut/upsmon.conf
as follows:
MONITOR ups@localhost 1 upsmonitor password1 master
Finally, make sure to modify the permissions of all NUT configuration files:
chown root:nut /etc/nut/*
chmod 640 /etc/nut/*
Now that everything is setup, let see some useful commands.
To start NUT manually (upsd and upsmon daemons simultaneously):
service nut start
To check both daemons status:
service nut status
To launch the UPS driver:
upsdrvctl start
To know the UPS status:
upsc ups
(modify ups
according to the section name you used in /etc/nut/ups.conf
)
To test the server behavior in case of power outage, use the following command:
upsmon -c fsd
If the UPS is connected to mains, the server will stop and then restart (don’t forget to set your BIOS power management to “Always on”). If the UPS is unplugged, the server will restart only after reconnection to mains.
One last thing: If you have a “BUS= will be removed in a future udev version” error at system boot, see https://bugs.launchpad.net/ubuntu/+source/nut/+bug/692171 for a solution.
That’s all Folks!
For further reading, see NUT website.
Jul 08, 2016 @ 17:47:02
Hola.
Tengo una UPS Powest de 1000VA.
Uso GNU/Linux Ubuntu 14.04.
La UPS trae un instalador llamado WinPower. Lo bajé de Internet. Pero no me reconoce el USB. Por eso instalé NUT.
Pero NUT no inicia el servicio cuando le doy: service nut start
Al instalar NUT me sale:
sudo apt-get install nut
Leyendo lista de paquetes… Hecho
Creando árbol de dependencias
Leyendo la información de estado… Hecho
nut ya está en su versión más reciente.
Los paquetes indicados a continuación se instalaron de forma automática y ya no son necesarios.
ca-certificates-java default-jre-headless libgconf2-4 libhdb9-heimdal
libkdc2-heimdal libntdb1 libvncclient0 linux-image-3.19.0-39-generic
linux-image-extra-3.19.0-39-generic linux-signed-image-3.19.0-39-generic
openjdk-7-jre-headless python-ntdb tzdata-java vlc-plugin-pulse
Use ‘apt-get autoremove’ to remove them.
0 actualizados, 0 se instalarán, 0 para eliminar y 9 no actualizados.
Los archivos de configuración que indicas en este tutorial si aparecen.
Cuando ejecuto el UPSDRVCTL me sale:
upsdrvctl start
Network UPS Tools – UPS driver controller 2.7.1
Network UPS Tools – Generic HID driver 0.38 (2.7.1)
USB communication driver 0.32
Fatal error: ‘maxretry’ is not a valid variable name for this driver.
Look in the man page or call this driver with -h for a list of
valid variable names and flags.
En el archivo ups.conf coloqué:
[myups]
driver = usbhid-ups #mydriver
port = auto
# cable = 1234
desc = “UPS Powest” #”Something descriptive”
Agradezco tú ayuda.
Jul 09, 2016 @ 11:30:38
Hola,
First, unless I’m wrong, your UPS is not listed in the compatible devices list on NUT website. This means it might not work at all, whatever you’ll try…
As regards the fatal error, I believe it’s because you placed the global directive “maxretry” inside a UPS section in ups.conf. Make sure your “maxretry” line is placed before any UPS section.