Securing power to the Server (UPS)

Power is very reliable in the Netherlands. As the server is now continually use for storage of the dat at home it is required to make sure this is done right. Power outage may lead to damage of the data. Therefor good shutdown of power is arranged for with a UPS>

We will use NUT as our software for managing the UPS:

sudo apt install nut

Check the NUT Hardware Compatibility List to figure out which driver will work for your UPS. For my APC UPS, the correct driver is “usbhid-ups”. It is also required to indentify the port at which the ups is connected therefore do:

sudo apt install nut

Check the NUT Hardware Compatibility List to figure out which driver will work for your UPS. For my APC UPS, the correct driver is “usbhid-ups”. It is also required to indentify the port at which the ups is connected therefore do:

lsusb

Expected output is:

Bus 003 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 007 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 005 Device 002: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 004 Device 003: ID 17ef:602e Lenovo
Bus 004 Device 002: ID 17ef:602d Lenovo
Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub

Find the line where the UPS is mentioned. Note the name of the UPS and device/0002 combination for the USB port that is used. The device gets identified by /dev/bus/usb/005/002 what is required in the next step.

Edit the configuration file:

sudo nano /etc/nut/ups.conf

Add at the end of the file the following lines:

maxretry = 3
[ups]
        driver = usbhid-ups
        port = /dev/bus/usb/005/002
        desc = "APC CS350VA"

Save the file.

sudo cp /lib/udev/rules.d/50-udev-default.rules /etc/udev/rules.d/

After this reboot the system:

sudo reboot

Set up /var/run/nut:

sudo mkdir /var/run/nut

Notice that the directory may exist. Adjust he ownership and rights anyway:

sudo chown root:nut /var/run/nut
sudo chmod 770 /var/run/nut
sudo chown root:nut /etc/nut/upsd.conf /etc/nut/upsd.users /etc/nut/hosts.conf
sudo chmod 0640 /etc/nut/upsd.conf /etc/nut/upsd.users /etc/nut/hosts.conf

Edit de NUT deamon configuration file:

sudo nano /etc/nut/upsd.conf

Add line at the bottom:

LISTEN testserver
ACCEPT testserver

Test the ups.conf file:

sudo upsdrvctl start

Normal output:

Network UPS Tools - UPS driver controller 2.6.3
Network UPS Tools - Generic HID driver 0.35 (2.6.3)
USB communication driver 0.31
Using subdriver: CyberPower HID 0.3

Reload the deamon:
sudo upsd -c reload

Create a new user in ubuntu with the name and password the same as created in etc/nut/upsd.users. WebMin can be used to get this done. Make sure this user (monuser) belongs to the group of ‘root’

Next, we need to setup some users to access the info and make changes.

sudo nano /etc/nut/upsd.users

Insert at the end the following text:

#
#upsmon master
[monuser]
	password = paswoord
	actions = SET FSD
	instcmds = ALL
	upsmon master
# or upsmon slave
[monuserslave]
	password = paswoord
	upsmon slave

Save the file and open the UPS Monitor configuration file:

sudo nano /etc/nut/upsmon.conf

At the following line at the correct place:

MONITOR ups@testserver:3493 1 monuser paswoord master

Save the file. Now we need to setup NUT to run in standalone mode, open file:

sudo nano /etc/nut/nut.conf

And put this at the and of the file:

MODE=standalone

Close the file and start NUT:

sudo service nut-client reload

Now see its working By:

sudo upsc ups@testserver:3493

Normal output will be:

Init SSL without certificate database
battery.charge: 100
battery.charge.low: 10
battery.charge.warning: 50

And so on so on so on……………….

Install grafical web display for status of the UPS:

To monitor the status of the UPS it is possible to view a web page with relevant information. Install the software for this feature:

sudo apt install nut-cgi
Then modify the configuration file:
sudo nano /etc/nut/hosts.conf
Insert the following line:

MONITOR ups@testserver:3493 'APC UPS on Hover'

Save the file. Now update apache2
sudo a2enmod cgi
sudo service apache2 restart
Then show the values at:
http://192.168.1.100/cgi-bin/nut/upsstats.cgi

Sending commands to the UPS

It is possible to send commands to the ups. See the following list of possible commands:
Show the available commands:
sudo upscmd -l ups@testserver:3493

beeper.disable - Disable the UPS beeper
beeper.enable - Enable the UPS beeper
beeper.mute - Temporarily mute the UPS beeper
beeper.off - Obsolete (use beeper.disable or beeper.mute)
beeper.on - Obsolete (use beeper.enable)
load.off - Turn off the load immediately
load.off.delay - Turn off the load with a delay (seconds)
load.on - Turn on the load immediately
load.on.delay - Turn on the load with a delay (seconds)
shutdown.reboot - Shut down the load briefly while rebooting the UPS
shutdown.return - Turn off the load and return when power is back
shutdown.stayoff - Turn off the load and remain off
shutdown.stop - Stop a shutdown in progress
test.battery.start.deep - Start a deep battery test
test.battery.start.quick - Start a quick battery test
test.battery.stop - Stop the battery test
test.panel.start - Start testing the UPS panel
test.panel.stop - Stop a UPS panel test

it is possible to switch of the beeper in the UPS:
sudo upscmd ups@testserver:3493 beeper.disable

Notice that “ups@testserver:3493” is the full address to access the UPS. A username “monuser”and passwoord “paswoord” will need to be specified.
This looks like this

system@testserver:~$ sudo upscmd ups@testserver:3493 beeper.disable
Username (root): monuser
Password:
OK
system@testserver:~$

or, if you want in one go on the command line:

sudo upscmd -u monuser -p paswoord ups@testserver:3493 beeper.disable

Changing values in the UPS

upsrw allows you to view and change the read/write variables inside your UPS. It sends commands via the server upsd to your driver, which configures the hardware for you.

sudo upsrw ups@testserver:3493

The output will look like:

[battery.charge.low]
Remaining battery level when UPS switches to LB (percent)
Type: STRING
Maximum length: 10
Value: 10

[battery.runtime.low]
Remaining battery runtime when UPS switches to LB (seconds)
Type: STRING
Maximum length: 10
Value: 120

[input.sensitivity]
Input power sensitivity
Type: STRING
Maximum length: 10
Value: medium

[input.transfer.high]
High voltage transfer point (V)
Type: STRING
Maximum length: 10
Value: 266

[input.transfer.low]
Low voltage transfer point (V)
Type: STRING
Maximum length: 10
Value: 180

[ups.delay.shutdown]
Interval to wait after shutdown with delay command (seconds)
Type: STRING
Maximum length: 10
Value: 20

[ups.delay.start]
Interval to wait before (re)starting the load (seconds)
Type: STRING
Maximum length: 10
Value: 30

Changing values within the UPS:

sudo upsrw -u monuser -p paswoord -s input.transfer.high=266 ups@testserver:3493

The response of this command should be OK. If there is no response the value cannot be changed.

Laatst bijgewerkt op 25 september 2018

Geef een reactie

Het e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *