Because of this sumer heat wave, I finally decided to install an Uninterrupted Power Supply for my debian server.
See full list on linux.die.net. Cannot retrieve contributors at this time. 1570 lines (1388 sloc) 64 KB Raw Blame /. mge-hid.c - data to monitor Eaton / MGE HID (USB and serial) devices. Click here to see reports of other supported models from MGE UPS SYSTEMS. When a user reports that a variable/command is not right then it will be highlighted by a red underline. Bad values/ranges/etc will get a red dashed outline or red solid left border.
So I decided to buy a Eaton 3S550 UPS. This small UPS is designed like a big strip, it handles 550 VA and it provides a USB connection.
Thanks to Network UPS Tools, this UPS is very easy to manage when connected to a Debian server.
Installation procedure in a non GUI environment is quite simple, but it involves a certain number of steps that should be carefully followed.
So, this article explains a step-by-step installation procedure of a Eaton UPS connected to a Debian Jessie headless server. If followed carefully, you should get your UPS fully integrated to your server, with an automatic shutdown when your UPS battery is becoming too low during a power cut.
This procedure should be applicable to any Ubuntu or Debian-based server.
1. Installation
First step is to install Network UPS Tools package :
2. Connect your UPS
Once your UPS is powered and connected to a USB port of your server, it should be detected :
Bus 004 Device 010: ID 0463:ffff MGE UPS Systems UPS
We can notice that UPS is from MGE, former name of Eaton.
This command has given us the Vendor ID and Device ID of your USB connected UPS.
- Vendor ID : 0463
- Device ID : ffff
These important values will be used later in the installation procedure.
3. Configuration
Its now time to declare the Eaton UPS to nut daemon.
As the UPS is connected via USB, we wil use the USB driver.
This is done by adding a new section to /etc/nut/ups.conf to declare your UPS.
[eaton]
driver = usbhid-ups
port = auto
desc = 'Eaton 3S 550'
4. Start USB driver
Now that your UPS is declared to nut, it's time to start the USB UPS driver upsdrvctl :
Network UPS Tools - UPS driver controller 2.6.4
Network UPS Tools - Generic HID driver 0.37 (2.6.4)
USB communication driver 0.32
Can't claim USB device [0463:ffff]: could not detach kernel driver from interface 0: Operation not permitted
Driver failed to start (exit status=1)
This doesn't look good.
Error comes from the fact that nut daemon is running as nut user, which is not allowed to access USB interface (accessible only by root).
The best way to allow nut user to access the UPS USB device, is to declare a new udev rules.
The udev rule will use the Vendor ID and Device ID of your USB UPS.
Il will allow accounts from nut group to access the USB device with 660 permission rather than 666, since that should be sufficient and more secure.
To declare the rule, you just have to create /etc/udev/rules.d/90-nut-ups.rules :
ACTION'add', SUBSYSTEM'usb', ATTR{idVendor}'0463', ATTR{idProduct}'ffff', MODE='0660', GROUP='nut'
You now need to restart udev for the rule to become operational :
Mge Ups Pulsar
You need to disconnect and reconnect the USB cable to remount it with the new udev rule.
You should now be able to start upsdrvctl UPS driver without error.
Network UPS Tools - UPS driver controller 2.6.4
Network UPS Tools - Generic HID driver 0.37 (2.6.4)
USB communication driver 0.32
Using subdriver: MGE HID 1.31
5. Configure NUT mode
Drivers Mge Ups System
nut can run in different mode according to your configuration :
- none (default)
- standalone
- netserver
- netclient
We must configure nut in standalone mode as it will address a local only configuration, with 1 UPS protecting the local system. This will start the 3 nut layers (driver, upsd and upsmon).
This standalone mode is declared in /etc/nut/nut.conf :
MODE=standalone
Next step is to configure upsd and upsmon :
- upsd communicates with the UPS driver that we just started
- upsmon communicates with upsd and actually shuts down the machine in the event of a power failure.
Why this extra level of indirection ?
Just because multiple instances of upsmon can be started on different machines and communicate with a single uspd in charge of the physical UPS device.
6. Configure UPS daemon
As upsd will be used locally on the server, we will configure it to listen on localhost and default port 3493. Configuration will be done for IPv4 and IPv6.
Edit or create configuration file /etc/nut/upsd.conf :
# LISTEN <address> [<port>]
LISTEN 127.0.0.1 3493
LISTEN ::1 3493
...
Next, we should create a local upsmonitor user for upsd.
It will be used by upsmon to interact with upsd.
This local user is declared in /etc/nut/upsd.users :
password = YOUR_PASSWORD
upsmon master
Replace YOUR_PASSWORD with a real password.
7. Configure UPS monitor
Once user has been declared in upsd, it should be declared to upsmon.
This declaration is done thru /etc/nut/upsmon.conf :
MONITOR eaton@localhost 1 upsmonitor YOUR_PASSWORD master
POWERDOWNFLAG /etc/killpower
SHUTDOWNCMD '/sbin/shutdown -h now'
eaton is the name you've given to your UPS in /etc/nut/ups.conf and YOUR_PASSWORD with the password you set in /etc/nut/upsd.users.
If you want, you can also change the shutdown command that will be used when the UPS battery will go below a minimum level.
8. Secure configuration
Since these UPS configuration files contain sensitive data (you can shutdown the server …), we should fix the permissions to allow only root user and nut group to access them.
# chmod 640 /etc/nut/*
9. Test connection
Everything should now be in place to test your UPS connectivity.
To test it, you just need to start upsd daemon and to inquire your UPS status with upsc client.
Network UPS Tools upsd 2.6.4
fopen /var/run/nut/upsd.pid: No such file or directory
listening on ::1 port 3493
listening on 127.0.0.1 port 3493
Connected to UPS [eaton]: usbhid-ups-eaton
# upsc eaton@localhost
battery.charge: 89
battery.charge.low: 20
...
Now that service is running, you can reboot your debian computer.
After next reboot, service nut-server should have been started.
You should be able to access your UPS data.
battery.charge: 89
battery.charge.low: 20
...
Your Debian server is now protected.
As soon as your UPS charge will go under 20%, a shutdown signal will be issued to your server.
Hope it helps !
In addition to the extensive features already included in LanSafe v. 5, the new v. 6 release introduces support for new Operating System platforms such as Windows Server 2008, VMware and Linux systems. In addition v. 6 supports both Powerware and Pulsar (formerly MGE Office Protection Systems) product series.LanSafe v. 6 delivers comprehensive power management capabilities including graceful, remote shutdown of UPS systems and network monitoring tools via serial, USB, and network connectivity options.
Experience LanSafe without downloading the software by viewing the LanSafe Explorer demonstration software, available now!
Features & Benefits
- Sequential shutdown of UPS powered computers and applications prevents data loss and corruption in case of prolonged power failure
- Exclusive Stealth Mode Operation enables LanSafe v. 6 to run in the background without visual traces
- 3-D PowerScope and ControlRoom views eliminate the guesswork from UPS metering and status information
- History View provides around-the-clock visual representation of the system event log in calendar format
- Automatic Regional Settings Detection enables date, time, temperature and UPS receptacle graphics to be automatically selected according to the operating system's regional settings
Product Summary |
Supported Operating Systems (pdf) |
Download Software |
Download LanSafe WebView v. 1 |
Product Literature |
Online Help |