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]
- 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"