[SOLVED] Install UPS, Configure NUT, notes

This forum is dedicated to advanced help and support :

Ask here your questions about advanced usage of Mageia. For example you may post here all your questions about network and automated installs, complex server configurations, kernel tuning, creating your own Mageia mirrors, and all tasks likely to be touchy even for skilled users.

[SOLVED] Install UPS, Configure NUT, notes

Postby hankivy » May 8th, '15, 21:40

I may not have it working right. Testing needs to move up on the priority list. These are my notes of the configuration, and symptoms. Unfortunately, there are almost ten files involved in the configuration.

I have a simple physical configuration, one UPS, one Tower (w/ CPU, disk, etc.), and one Monitor.
There are three cooperating system services: nut-driver, nut-monitor, and nut-server. I should have all three running.

File Permissions in /etc/ups/.

Code: Select all
[hank@HIvyTower ups]$ pwd ;ls -ld ups*.[uc]*
/etc/ups
-rw-r--r-- 1 root root  3766 Feb  9 16:57 ups.conf
-rw-r----- 1 root ups   2767 Feb  9 22:30 upsd.conf
-rw-r----- 1 root ups   2178 Feb 11 01:26 upsd.users
-rw-r----- 1 root ups  12151 Feb 11 01:31 upsmon.conf
-rw-r----- 1 root ups   4089 Oct 21  2013 upssched.conf
-rw-r--r-- 1 root root  1408 Oct 21  2013 upsset.conf
[hank@HIvyTower ups]


Relevant file contents:
ups.conf
Code: Select all
[HbiLinTower]
driver = usbhid-ups
port = /dev/ups
desc = "CP685AVR-G on my linux tower at home"

upsd.conf
Code: Select all
# Network UPS Tools: example upsd configuration file
# This file contains access control data, you should keep it secure.
# It should only be readable by the user that upsd becomes.  See the FAQ.
LISTEN 127.0.0.1 3493

upsd.users
Code: Select all
[upsmon]
        password = Y0mJre1o
        upsmon master

upsmon.conf -- other lines,
Code: Select all
RUN_AS_USER ups
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +0"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5
MONITOR HbiLinTower@localhost 1 upsmon Y0mJrelo master

upssched.conf
Code: Select all
CMDSCRIPT /usr/bin/upssched-cmd

upsset.conf
Code: Select all
# Assuming you have all this done (and it works), then you may uncomment
# the line below and start using upsset.cgi through your web browser.
#

I_HAVE_SECURED_MY_CGI_DIRECTORY

/usr/bin/upssched-cmd
Code: Select all
#! /bin/sh
#
# This script should be called by upssched via the CMDSCRIPT directive.
 Here is a quick example to show how to handle a bunch of possible
# timer names with the help of the case structure.
# This script may be replaced with another program without harm.
# The first argument passed to your CMDSCRIPT is the name of the timer
# from your AT lines.

case $1 in
        upsgone)
                logger -t upssched-cmd "The UPS has been gone for awhile"
                ;;
        *)
                logger -t upssched-cmd "Unrecognized command: $1"
                ;;
esac


Devices
Code: Select all
[hank@HIvyTower bin]$ ls -ld /dev/ups /dev/hidraw0
crw-rw---- 1 root ups  251, 0 Apr 29 21:35 /dev/hidraw0
lrwxrwxrwx 1 root root      7 Apr 29 21:35 /dev/ups -> hidraw0
[hank@HIvyTower bin]
Users and groups
Code: Select all
[hank@HIvyTower ~]$ grep -i -e nut -e ups /etc/passwd /etc/group
/etc/passwd:ups:x:490:481:system user for nut:/var/state/ups:/bin/false
/etc/group:tty:x:5:ups
/etc/group:usb:x:43:ups,saned
/etc/group:dialout:x:83:ups
/etc/group:ups:x:481:
[hank@HIvyTower ~]$


Notes on Mageia control center - System Services - for UPS/NUT:
There are three services nut-driver, nut-monitor, and nut-server. There are interdependencies. If I start, or stop one service that triggers another start, or stop of another service, the System Services window does not seem to reflect the true status of the other service.

Notes on using the systemctl command:
Notes on the systemd unit files for the three UPS services.
(nut-driver, nut-monitor, and nut-server)
nut-driver says to Stop When Un Needed, so it should never be started first.
[At least it should not be started first by itself.]
[It would just start, and might stop before one of the others is started.]
nut-monitor says it needs nut-server running already.
[So it should not be started first.]
nut-server says it needs nut-driver, in both the "After" and "Requires" clauses.
nut-server says it should be "Before" nut-monitor.
[So it should not be started first.]

It looks like these unit files imply that all three services should be started in the following order: nut-driver, nut-server, and nut-monitor. Based on the documentation at
http://www.networkupstools.org/docs/user-manual.chunked/ar01s03.html#_monitoring_diagrams
all three should be running together for the simple case of one UPS, and one CPU.

[As a side note, the slave systems in more complex configurations only need the monitor.]

All three use "Type=forking", but only nut-monitor has a PIDFile entry as recommended
in the "man 5 systemd.service" documentation.

None of the three have any controls on the order of shutdown, for a consistent shutdown.

The command systemctl start nut-monitor only starts the upsmon processes.
:upsmon parent (It's parent's process id is 1.)
:upsmon child (It's pid is in /run/nut/upsmon.pid. It's parent's process is the process above.)
Then the command systemctl start nut-server starts
:upsd, and puts it's pid in /var/state/ups/upsd.pid
:usbhid-ups, and puts it's pid in /var/state/ups/usbhid-ups-HbiLinTower.pid
:creates a socket /var/state/ups/usbhid-ups-HbiLinTower

Next I stopped all three services with sudo systemctl stop nut... commands.
The socket and all three pid files were deleted. All of the processes were terminated.

The command systemctl start nut-server started the driver, usbhid-ups; and the server, upsd.
But not the nut-monitor.

Notes on the device for my UPS. /etc/udev/rules.d/01-CyberPower-685AVR.rules
Code: Select all
# rule file for Cyber Power 685AVR Uninterruptible Power Supply

# Unplugging and pluging in the USB cable
#   added the following lines to the output of the dmesg command.

#[ 1330.360494] usb 1-1.4: USB disconnect, device number 8
#[ 1350.530100] usb 1-1.4: new low-speed USB device number 9 using ehci-pci
#[ 1350.630052] usb 1-1.4: New USB device found, idVendor=0764, idProduct=0501
#[ 1350.630055] usb 1-1.4: New USB device strings: Mfr=3, Product=1, SerialNumber=0
#[ 1350.630057] usb 1-1.4: Product: CP685AVR-G
#[ 1350.630058] usb 1-1.4: Manufacturer: CPS
#[ 1350.681520] hid-generic 0003:0764:0501.0008: hiddev0,hidraw3: USB HID v1.10 Device [CPS CP685AVR-G] on usb-0000:00:1a.0-1.4/input0

# The following creates a symbolic link /dev/ups pointing to the usb device for the CPS CP685AVR-G.

SUBSYSTEMS=="usb",ATTRS{idVendor}=="0764", ATTRS{idProduct}=="0501", SYMLINK+="ups", GROUP="ups"
Last edited by hankivy on Aug 5th, '17, 18:44, edited 1 time in total.
hankivy
 
Posts: 128
Joined: May 19th, '14, 20:36

Re: Install UPS, Configure NUT, notes

Postby marja » May 29th, '15, 22:40

Hi Hankivy,

Thanks for your feedback 8-)

Documentation Team never managed to write http://doc.mageia.org/mcc/5/en/content/drakups.html, because no one in our team owns a UPS.
(And we never wrote http://doc.mageia.org/mcc/5/en/content/drakxservices.html either :oops: )

I understand you didn't try or manage to use drakups? (Can be found at the bottom of the "Hardware" tab in MCC, or started from the command line by typing "drakups" as root)

Cheers,
Marja
User avatar
marja
 
Posts: 541
Joined: Aug 22nd, '11, 20:50


Return to Advanced support

Who is online

Users browsing this forum: No registered users and 1 guest