Was /etc/nut/upssched-cmd automatically installed?
I don't have it on my raspberry pi. :-(
On 2019-04-03 1:54 p.m., Mike wrote:
I figured this out and it is working now. This fix seems strange to me
and is possibly a bug. I'm sharing in case it might help others.
I had to uncomment all of the NOTIFYFLAG statements whether I was
changing them or not. Previously, I had a mixture of commented and
uncommented, assuming the commented ones used default values.
$ grep -Ev "^(#|\s*$)" /etc/nut/upsmon.conf
RUN_AS_USER nut
MONITOR myups1@localhost:3493 1 nutmaster pass master
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown --poweroff +1"
NOTIFYCMD /sbin/upssched
POLLFREQ 10
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/nut/killpower
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG FSD SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+WALL
NOTIFYFLAG COMMBAD SYSLOG+WALL
NOTIFYFLAG SHUTDOWN SYSLOG+WALL
NOTIFYFLAG REPLBATT SYSLOG+WALL
NOTIFYFLAG NOCOMM SYSLOG+WALL
NOTIFYFLAG NOPARENT SYSLOG+WALL
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 60
CERTVERIFY 0
FORCESSL 0
Another thing worth noting, and probably unrelated to this specific
scenario, is somehow I have a "nut" user and a "nutuser" user. I don't
know how that happened. On my Debian setup (details in previous
message), user "nutuser" does not work, where the "nut" user does work.
Perhaps this happened during one of the incremental updates over the
years and I thought I'd point that out as well as it is confusing.
I have to say that I'm surprised that I got no responses at all. It
would have been nice to get "I don't know" and perhaps had a useful
exchange, or "We're tired of this topic". Given my discovery to make it
working, I don't consider that an obvious fix and did not come across it
in any documentation or previous threads.
Thanks,
-MikeD
------------------------------------------------------------------------
*Date:* Saturday, March 30, 2019, at 04:13:12 PM PDT (GMT/UMT -0700)
*From:* Mike <[email protected]>
*To:* Nut Users <[email protected]>
*Subject:* [Nut-upsuser] upssched Not Running
Hello,
I have a problem with upssched working in my NUT setup. upssched is not
executing at all while running on battery. I'm trying to execute some
shell scripts before the shutdown begins. I have 3 computers connected
to a single UPS. There is a Debian (testing) connected to the UPS via
USB, and NUT was installed using a standard Debian repo using apt-get.
The two other boxes are Windows 10 Pro with no data connections to the
UPS. I have cygwin installed on the Windows boxes and I've written a
shell script to shell in and shutdown the Windows boxes. I had problems
getting Windows NUT to work so I gave up and went with this model (was a
netserver/netclient setup, now I'm standalone with upssched). It seems
I'm really close but I need to figure out the upssched issue. I
appreciate the support and patience as I see many variances of this
problem come up on the mailing list. I don't see my particular issue
and I've checked the other threads and confirmed those particular fixes
are implemented in my setup.
I saw one thread discussing SELinux. I do not have SELinux but I do
have AppArmor running. I don't see any indication in /var/log/syslog
that AppArmor is blocking execution. I also don't see any NUT specific
config for AppArmor. I run a pretty standard, out-of-the-box AppArmor
setup.
I see nothing in /var/log/syslog when the low battery condition hits and
we just go straight to a shutdown of the Debian box while nothing
happens on the windows boxes, which tells me that it's completely
skipping upssched. /etc/nut/upssched-cmd runs as expected when called
via sudo manually. Below are my NUT config files and some other
(hopefully) useful information.
NUT version:
$ upsd -V
Network UPS Tools upsd 2.7.4
nut.conf:
$ grep -Ev "^(#|\s*$)" /etc/nut/nut.conf
MODE=standalone
ups.conf:
$ grep -Ev "^(#|\s*$)" /etc/nut/ups.conf
[myups1]
driver = usbhid-ups
port = auto
vendorid = 0764
desc = "CyberPower 1350VA/CP1500AVR/CST135XLU on rockenfield"
pollinterval = 10
ignorelb
override.battery.charge.low = 80
override.battery.charge.warning = 90
override.battery.runtime.low = 900
upsd.conf:
$ grep -Ev "^(#|\s*$)" /etc/nut/upsd.conf
LISTEN 192.168.123.1 3493
LISTEN 127.0.0.1 3493
upsd.users:
$ grep -Ev "^(#|\s*$)" /etc/nut/upsd.users
[nutmaster]
password = pass
upsmon master
[nutslave]
password = pass
upsmon slave
upsmon.conf:
$ grep -Ev "^(#|\s*$)" /etc/nut/upsmon.conf
RUN_AS_USER nut
MONITOR myups1@localhost:3493 1 nutmaster pass master
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown --poweroff +0"
NOTIFYCMD /sbin/upssched
POLLFREQ 10
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 30
CERTVERIFY 0
FORCESSL 0
-----
upssched.conf:
$ grep -Ev "^(#|\s*$)" /etc/nut/upssched.conf
CMDSCRIPT /etc/nut/upssched-cmd
PIPEFN /etc/nut/upssched.pipe
LOCKFN /etc/nut/upssched.lock
AT ONBATT myups1 EXECUTE onbatt
AT LOWBATT myups1 EXECUTE lowbatt
-----
upssched-cmd:
$ cat /etc/nut/upssched-cmd
#!/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.
OPTION="$1"
SCRIPT="$0"
logger -t $SCRIPT "Script called with arg $OPTION"
case $OPTION in
lowbatt)
logger -t $SCRIPT "UPS Low Battery: Begin shutting down clients"
/root/bin/remote-shutdown-nas
sleep 1
/root/bin/remote-shutdown-win 192.168.123.2
sleep 1
/root/bin/remote-shutdown-win 192.168.123.3
sleep 20
;;
onbatt)
logger -t $SCRIPT "UPS on battery"
;;
upsgone)
logger -t $SCRIPT "The UPS has been gone for awhile"
;;
*)
logger -t $SCRIPT "Unrecognized arg: $OPTION"
;;
esac
exit 0
UPS communications are working:
$ upsc myups1
Init SSL without certificate database
battery.charge: 100
battery.charge.low: 80
battery.charge.warning: 90
battery.mfr.date: CPS
battery.runtime: 1350
battery.runtime.low: 900
battery.type: PbAcid
battery.voltage: 24.0
battery.voltage.nominal: 24
device.mfr: CPS
device.model: CST135XLU
device.serial: CR7GT2000910
device.type: ups
driver.flag.ignorelb: enabled
driver.name: usbhid-ups
driver.parameter.pollfreq: 30
driver.parameter.pollinterval: 10
driver.parameter.port: auto
driver.parameter.synchronous: no
driver.parameter.vendorid: 0764
driver.version: 2.7.4
driver.version.data: CyberPower HID 0.4
driver.version.internal: 0.41
input.voltage: 119.0
input.voltage.nominal: 120
output.voltage: 136.0
ups.beeper.status: enabled
ups.delay.shutdown: 20
ups.delay.start: 30
ups.load: 26
ups.mfr: CPS
ups.model: CST135XLU
ups.productid: 0501
ups.realpower.nominal: 810
ups.serial: CR7GT2000910
ups.status: OL
ups.test.result: No test initiated
ups.timer.shutdown: -60
ups.timer.start: -60
ups.vendorid: 0764
Show file access:
$ ll /etc/nut/
total 53,248
-rw-r----- 1 root nut 1,573 Mar 29 16:00 nut.conf
-rw-r----- 1 root nut 4,892 Mar 29 15:47 ups.conf
-rw-r----- 1 root nut 4,644 Dec 7 2017 upsd.conf
-rw-r----- 1 root nut 2,234 Mar 28 14:55 upsd.users
-rw-r----- 1 root nut 15,352 Mar 29 21:32 upsmon.conf
-rw-r----- 1 root nut 4,099 Mar 30 08:45 upssched.conf
-rwxr-x--- 1 root nut 986 Mar 30 14:58 upssched-cmd*
Verify nut user can write to the dir:
$ sudo --user nut touch /etc/nut/test
$ ll /etc/nut/
total 53,248
-rw-r----- 1 root nut 1,573 Mar 29 16:00 nut.conf
-rw-r--r-- 1 nut nut 0 Mar 30 15:49 test
-rw-r----- 1 root nut 4,892 Mar 29 15:47 ups.conf
-rw-r----- 1 root nut 4,644 Dec 7 2017 upsd.conf
-rw-r----- 1 root nut 2,234 Mar 28 14:55 upsd.users
-rw-r----- 1 root nut 15,352 Mar 29 21:32 upsmon.conf
-rw-r----- 1 root nut 4,099 Mar 30 08:45 upssched.conf
-rwxr-x--- 1 root nut 986 Mar 30 14:58 upssched-cmd*
Verify shell script executes as nut user:
$ date; sudo --user nut /etc/nut/upssched-cmd dude
Sat 30 Mar 2019 03:50:56 PM PDT
$ grep upssched /var/log/syslog | tail -2
Mar 30 15:50:56 rockenfield /etc/nut/upssched-cmd: Script called with
arg dude
Mar 30 15:50:56 rockenfield /etc/nut/upssched-cmd: Unrecognized arg: dude
Any help is greatly appreciated. Thanks a lot!
-MikeD
_______________________________________________
Nut-upsuser mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser
_______________________________________________
Nut-upsuser mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser
_______________________________________________
Nut-upsuser mailing list
[email protected]
https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser