<html>
<head>
<meta http-equiv="content-type" content="text/html;
charset=windows-1252">
</head>
<body smarttemplateinserted="true">
<div id="smartTemplate4-template"><font
size="2" face="Verdana">Hello,<br>
<br>
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.<br>
<br>
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.<br>
<br>
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.<br>
<br>
NUT version:<br>
</font><font size="2"><tt>$ upsd
-V</tt><tt><br>
</tt><tt>Network UPS Tools upsd
2.7.4</tt></font><font size="2"
face="Verdana"><br>
<br>
nut.conf:<br>
</font><font size="2"><tt>$ grep -Ev
"^(#|\s*$)" /etc/nut/nut.conf</tt><tt><br>
</tt><tt>MODE=standalone</tt></font><font
size="2"
face="Verdana"><br>
<br>
ups.conf:<br>
</font><font size="2"><tt>$ grep -Ev
"^(#|\s*$)" /etc/nut/ups.conf</tt><tt><br>
</tt><tt>[myups1]</tt><tt><br>
</tt><tt> driver =
usbhid-ups</tt><tt><br>
</tt><tt> port = auto</tt><tt><br>
</tt><tt> vendorid = 0764</tt><tt><br>
</tt><tt> desc = "CyberPower
1350VA/CP1500AVR/CST135XLU
on rockenfield"</tt><tt><br>
</tt><tt> pollinterval =
10</tt><tt><br>
</tt><tt> ignorelb</tt><tt><br>
</tt><tt> override.battery.charge.low =
80</tt><tt><br>
</tt><tt> override.battery.charge.warning =
90</tt><tt><br>
</tt><tt> override.battery.runtime.low =
900</tt></font><font
size="2" face="Verdana"><br>
<br>
upsd.conf:<br>
</font><font size="2"><tt>$ grep -Ev
"^(#|\s*$)"
/etc/nut/upsd.conf</tt><tt><br>
</tt><tt>LISTEN 192.168.123.1
3493</tt><tt><br>
</tt><tt>LISTEN 127.0.0.1
3493</tt></font><font size="2"
face="Verdana"><br>
<br>
upsd.users:<br>
</font><font size="2"><tt>$ grep -Ev
"^(#|\s*$)"
/etc/nut/upsd.users</tt><tt><br>
</tt><tt>[nutmaster]</tt><tt><br>
</tt><tt> password = pass</tt><tt><br>
</tt><tt> upsmon master</tt><tt><br>
</tt><tt>[nutslave]</tt><tt><br>
</tt><tt> password = pass</tt><tt><br>
</tt><tt> upsmon slave</tt></font><font
size="2"
face="Verdana"><br>
<br>
upsmon.conf:<br>
</font><font size="2"><tt>$ grep -Ev
"^(#|\s*$)"
/etc/nut/upsmon.conf</tt><tt><br>
</tt><tt>RUN_AS_USER nut</tt><tt><br>
</tt><tt>MONITOR myups1@localhost:3493 1 nutmaster pass
master</tt><tt><br>
</tt><tt>MINSUPPLIES 1</tt><tt><br>
</tt><tt>SHUTDOWNCMD "/sbin/shutdown --poweroff
+0"</tt><tt><br>
</tt><tt>NOTIFYCMD
/sbin/upssched</tt><tt><br>
</tt><tt>POLLFREQ 10</tt><tt><br>
</tt><tt>POLLFREQALERT 5</tt><tt><br>
</tt><tt>HOSTSYNC 15</tt><tt><br>
</tt><tt>DEADTIME 15</tt><tt><br>
</tt><tt>POWERDOWNFLAG
/etc/killpower</tt><tt><br>
</tt><tt>NOTIFYFLAG LOWBATT
SYSLOG+WALL+EXEC</tt><tt><br>
</tt><tt>RBWARNTIME 43200</tt><tt><br>
</tt><tt>NOCOMMWARNTIME 300</tt><tt><br>
</tt><tt>FINALDELAY 30</tt><tt><br>
</tt><tt>CERTVERIFY 0</tt><tt><br>
</tt><tt>FORCESSL 0</tt></font><font
size="2" face="Verdana"><br>
<br>
-----<br>
upssched.conf:<br>
</font><font size="2"><tt>$ grep -Ev
"^(#|\s*$)"
/etc/nut/upssched.conf</tt><tt><br>
</tt><tt>CMDSCRIPT
/etc/nut/upssched-cmd</tt><tt><br>
</tt><tt>PIPEFN
/etc/nut/upssched.pipe</tt><tt><br>
</tt><tt>LOCKFN
/etc/nut/upssched.lock</tt><tt><br>
</tt><tt>AT ONBATT myups1 EXECUTE
onbatt</tt><tt><br>
</tt><tt>AT LOWBATT myups1 EXECUTE
lowbatt</tt></font><font
size="2" face="Verdana"><br>
<br>
-----<br>
upssched-cmd:<br>
</font><tt><font size="2">$ cat
/etc/nut/upssched-cmd<br>
#!/bin/sh<br>
#<br>
# This script should be called by upssched via the CMDSCRIPT
directive.<br>
#<br>
# Here is a quick example to show how to handle a bunch of
possible<br>
# timer names with the help of the case structure.<br>
#<br>
# This script may be replaced with another program without
harm.<br>
#<br>
# The first argument passed to your CMDSCRIPT is the name of
the timer<br>
# from your AT lines.<br>
OPTION="$1"<br>
SCRIPT="$0"<br>
<br>
logger -t $SCRIPT "Script called with arg $OPTION"<br>
<br>
case $OPTION in<br>
lowbatt)<br>
logger -t $SCRIPT "UPS Low Battery: Begin shutting
down clients"<br>
/root/bin/remote-shutdown-nas<br>
sleep 1<br>
/root/bin/remote-shutdown-win 192.168.123.2<br>
sleep 1<br>
/root/bin/remote-shutdown-win 192.168.123.3<br>
sleep 20<br>
;;<br>
onbatt)<br>
logger -t $SCRIPT "UPS on battery"<br>
;;<br>
upsgone)<br>
logger -t $SCRIPT "The UPS has been gone for
awhile"<br>
;;<br>
*)<br>
logger -t $SCRIPT "Unrecognized arg:
$OPTION"<br>
;;<br>
esac<br>
<br>
exit 0</font></tt><font size="2"
face="Verdana"><br>
<br>
UPS communications are working:<br>
</font><font size="2"><tt>$ upsc
myups1</tt><tt><br>
</tt><tt>Init SSL without certificate
database</tt><tt><br>
</tt><tt>battery.charge: 100</tt><tt><br>
</tt><tt>battery.charge.low:
80</tt><tt><br>
</tt><tt>battery.charge.warning:
90</tt><tt><br>
</tt><tt>battery.mfr.date:
CPS</tt><tt><br>
</tt><tt>battery.runtime:
1350</tt><tt><br>
</tt><tt>battery.runtime.low:
900</tt><tt><br>
</tt><tt>battery.type: PbAcid</tt><tt><br>
</tt><tt>battery.voltage:
24.0</tt><tt><br>
</tt><tt>battery.voltage.nominal:
24</tt><tt><br>
</tt><tt>device.mfr: CPS</tt><tt><br>
</tt><tt>device.model:
CST135XLU</tt><tt><br>
</tt><tt>device.serial:
CR7GT2000910</tt><tt><br>
</tt><tt>device.type: ups</tt><tt><br>
</tt><tt>driver.flag.ignorelb:
enabled</tt><tt><br>
</tt><tt>driver.name:
usbhid-ups</tt><tt><br>
</tt><tt>driver.parameter.pollfreq:
30</tt><tt><br>
</tt><tt>driver.parameter.pollinterval:
10</tt><tt><br>
</tt><tt>driver.parameter.port:
auto</tt><tt><br>
</tt><tt>driver.parameter.synchronous:
no</tt><tt><br>
</tt><tt>driver.parameter.vendorid:
0764</tt><tt><br>
</tt><tt>driver.version:
2.7.4</tt><tt><br>
</tt><tt>driver.version.data: CyberPower HID
0.4</tt><tt><br>
</tt><tt>driver.version.internal:
0.41</tt><tt><br>
</tt><tt>input.voltage: 119.0</tt><tt><br>
</tt><tt>input.voltage.nominal:
120</tt><tt><br>
</tt><tt>output.voltage:
136.0</tt><tt><br>
</tt><tt>ups.beeper.status:
enabled</tt><tt><br>
</tt><tt>ups.delay.shutdown:
20</tt><tt><br>
</tt><tt>ups.delay.start: 30</tt><tt><br>
</tt><tt>ups.load: 26</tt><tt><br>
</tt><tt>ups.mfr: CPS</tt><tt><br>
</tt><tt>ups.model: CST135XLU</tt><tt><br>
</tt><tt>ups.productid: 0501</tt><tt><br>
</tt><tt>ups.realpower.nominal:
810</tt><tt><br>
</tt><tt>ups.serial:
CR7GT2000910</tt><tt><br>
</tt><tt>ups.status: OL</tt><tt><br>
</tt><tt>ups.test.result: No test
initiated</tt><tt><br>
</tt><tt>ups.timer.shutdown:
-60</tt><tt><br>
</tt><tt>ups.timer.start: -60</tt><tt><br>
</tt><tt>ups.vendorid: 0764</tt></font><font
size="2"
face="Verdana"><br>
<br>
Show file access:<br>
</font><font size="2"><tt>$ ll
/etc/nut/</tt><tt><br>
</tt><tt>total 53,248</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 1,573 Mar 29 16:00
nut.conf</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 4,892 Mar 29 15:47
ups.conf</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 4,644 Dec 7 2017
upsd.conf</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 2,234 Mar 28 14:55
upsd.users</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 15,352 Mar 29 21:32
upsmon.conf</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 4,099 Mar 30 08:45
upssched.conf</tt><tt><br>
</tt><tt>-rwxr-x--- 1 root nut 986 Mar 30 14:58
upssched-cmd*</tt></font><font size="2"
face="Verdana"><br>
<br>
Verify nut user can write to the dir:<br>
</font><font size="2"><tt>$ sudo --user nut
touch /etc/nut/test</tt><tt><br>
</tt><tt>$ ll /etc/nut/</tt><tt><br>
</tt><tt>total 53,248</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 1,573 Mar 29 16:00
nut.conf</tt><tt><br>
</tt><tt>-rw-r--r-- 1 nut nut 0 Mar 30 15:49
test</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 4,892 Mar 29 15:47
ups.conf</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 4,644 Dec 7 2017
upsd.conf</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 2,234 Mar 28 14:55
upsd.users</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 15,352 Mar 29 21:32
upsmon.conf</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 4,099 Mar 30 08:45
upssched.conf</tt><tt><br>
</tt><tt>-rwxr-x--- 1 root nut 986 Mar 30 14:58
upssched-cmd*</tt></font><font size="2"
face="Verdana"><br>
<br>
Verify shell script executes as nut user:<br>
</font><font size="2"><tt>$ date; sudo --user
nut
/etc/nut/upssched-cmd dude</tt><tt><br>
</tt><tt>Sat 30 Mar 2019 03:50:56 PM
PDT</tt><tt><br>
</tt><tt>$ grep upssched /var/log/syslog | tail
-2</tt><tt><br>
</tt><tt>Mar 30 15:50:56 rockenfield /etc/nut/upssched-cmd:
Script called with arg dude</tt><tt><br>
</tt><tt>Mar 30 15:50:56 rockenfield /etc/nut/upssched-cmd:
Unrecognized arg: dude</tt></font><font
size="2"
face="Verdana"><br>
<br>
Any help is greatly appreciated. Thanks a lot!<br>
<br>
-MikeD</font><br>
</div>
</body>
</html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;
charset=windows-1252">
</head>
<body smarttemplateinserted="true">
<div id="smartTemplate4-template"><font
size="2" face="Verdana">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.<br>
<br>
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.<br>
<br>
</font><font size="2"><tt>$ grep -Ev
"^(#|\s*$)"
/etc/nut/upsmon.conf</tt><tt><br>
</tt><tt>RUN_AS_USER nut</tt><tt><br>
</tt><tt>MONITOR myups1@localhost:3493 1 nutmaster pass
master</tt><tt><br>
</tt><tt>MINSUPPLIES 1</tt><tt><br>
</tt><tt>SHUTDOWNCMD "/sbin/shutdown --poweroff
+1"</tt><tt><br>
</tt><tt>NOTIFYCMD
/sbin/upssched</tt><tt><br>
</tt><tt>POLLFREQ 10</tt><tt><br>
</tt><tt>POLLFREQALERT 5</tt><tt><br>
</tt><tt>HOSTSYNC 15</tt><tt><br>
</tt><tt>DEADTIME 15</tt><tt><br>
</tt><tt>POWERDOWNFLAG
/etc/nut/killpower</tt><tt><br>
</tt><tt>NOTIFYFLAG ONLINE
SYSLOG+WALL+EXEC</tt><tt><br>
</tt><tt>NOTIFYFLAG ONBATT
SYSLOG+WALL+EXEC</tt><tt><br>
</tt><tt>NOTIFYFLAG LOWBATT
SYSLOG+WALL+EXEC</tt><tt><br>
</tt><tt>NOTIFYFLAG FSD
SYSLOG+WALL+EXEC</tt><tt><br>
</tt><tt>NOTIFYFLAG COMMOK
SYSLOG+WALL</tt><tt><br>
</tt><tt>NOTIFYFLAG COMMBAD
SYSLOG+WALL</tt><tt><br>
</tt><tt>NOTIFYFLAG SHUTDOWN
SYSLOG+WALL</tt><tt><br>
</tt><tt>NOTIFYFLAG REPLBATT
SYSLOG+WALL</tt><tt><br>
</tt><tt>NOTIFYFLAG NOCOMM
SYSLOG+WALL</tt><tt><br>
</tt><tt>NOTIFYFLAG NOPARENT
SYSLOG+WALL</tt><tt><br>
</tt><tt>RBWARNTIME 43200</tt><tt><br>
</tt><tt>NOCOMMWARNTIME 300</tt><tt><br>
</tt><tt>FINALDELAY 60</tt><tt><br>
</tt><tt>CERTVERIFY 0</tt><tt><br>
</tt><tt>FORCESSL 0</tt><tt><br>
</tt><tt>
</tt></font><font size="2"
face="Verdana"><br>
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.<br>
<br>
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.<br>
<br>
Thanks,<br>
-MikeD<br>
</font></div>
<br>
<div id="smartTemplate4-quoteHeader">
<hr>
<font size="2" face="Consolas">
<b>Date:</b> Saturday, March 30, 2019, at 04:13:12 PM PDT
(GMT/UMT -0700)<br>
<b>From:</b> Mike <a
class="moz-txt-link-rfc2396E"
href="mailto:miked@softtalker.com"><miked@softtalker.com></a><br>
<b>To:</b> Nut Users <a
class="moz-txt-link-rfc2396E"
href="mailto:nut-upsuser@alioth-lists.debian.net"><nut-upsuser@alioth-lists.debian.net></a><br>
<b>Subject:</b> [Nut-upsuser] upssched Not Running<br>
</font>
<br>
</div>
<div class="replaced-blockquote"
cite="mid:0aa56c19-0ddf-f168-d491-ac4a28b082a9@softtalker.com"
type="cite">
<meta http-equiv="content-type" content="text/html;
charset=windows-1252">
<div id="smartTemplate4-template"><font
size="2" face="Verdana">Hello,<br>
<br>
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.<br>
<br>
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.<br>
<br>
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.<br>
<br>
NUT version:<br>
</font><font size="2"><tt>$ upsd
-V</tt><tt><br>
</tt><tt>Network UPS Tools upsd
2.7.4</tt></font><font
size="2" face="Verdana"><br>
<br>
nut.conf:<br>
</font><font size="2"><tt>$ grep -Ev
"^(#|\s*$)"
/etc/nut/nut.conf</tt><tt><br>
</tt><tt>MODE=standalone</tt></font><font
size="2"
face="Verdana"><br>
<br>
ups.conf:<br>
</font><font size="2"><tt>$ grep -Ev
"^(#|\s*$)"
/etc/nut/ups.conf</tt><tt><br>
</tt><tt>[myups1]</tt><tt><br>
</tt><tt> driver =
usbhid-ups</tt><tt><br>
</tt><tt> port =
auto</tt><tt><br>
</tt><tt> vendorid =
0764</tt><tt><br>
</tt><tt> desc = "CyberPower
1350VA/CP1500AVR/CST135XLU
on rockenfield"</tt><tt><br>
</tt><tt> pollinterval =
10</tt><tt><br>
</tt><tt> ignorelb</tt><tt><br>
</tt><tt> override.battery.charge.low =
80</tt><tt><br>
</tt><tt> override.battery.charge.warning =
90</tt><tt><br>
</tt><tt> override.battery.runtime.low =
900</tt></font><font
size="2" face="Verdana"><br>
<br>
upsd.conf:<br>
</font><font size="2"><tt>$ grep -Ev
"^(#|\s*$)"
/etc/nut/upsd.conf</tt><tt><br>
</tt><tt>LISTEN 192.168.123.1
3493</tt><tt><br>
</tt><tt>LISTEN 127.0.0.1
3493</tt></font><font size="2"
face="Verdana"><br>
<br>
upsd.users:<br>
</font><font size="2"><tt>$ grep -Ev
"^(#|\s*$)"
/etc/nut/upsd.users</tt><tt><br>
</tt><tt>[nutmaster]</tt><tt><br>
</tt><tt> password =
pass</tt><tt><br>
</tt><tt> upsmon master</tt><tt><br>
</tt><tt>[nutslave]</tt><tt><br>
</tt><tt> password =
pass</tt><tt><br>
</tt><tt> upsmon slave</tt></font><font
size="2"
face="Verdana"><br>
<br>
upsmon.conf:<br>
</font><font size="2"><tt>$ grep -Ev
"^(#|\s*$)"
/etc/nut/upsmon.conf</tt><tt><br>
</tt><tt>RUN_AS_USER nut</tt><tt><br>
</tt><tt>MONITOR myups1@localhost:3493 1 nutmaster pass
master</tt><tt><br>
</tt><tt>MINSUPPLIES 1</tt><tt><br>
</tt><tt>SHUTDOWNCMD "/sbin/shutdown --poweroff
+0"</tt><tt><br>
</tt><tt>NOTIFYCMD
/sbin/upssched</tt><tt><br>
</tt><tt>POLLFREQ 10</tt><tt><br>
</tt><tt>POLLFREQALERT 5</tt><tt><br>
</tt><tt>HOSTSYNC 15</tt><tt><br>
</tt><tt>DEADTIME 15</tt><tt><br>
</tt><tt>POWERDOWNFLAG
/etc/killpower</tt><tt><br>
</tt><tt>NOTIFYFLAG LOWBATT
SYSLOG+WALL+EXEC</tt><tt><br>
</tt><tt>RBWARNTIME 43200</tt><tt><br>
</tt><tt>NOCOMMWARNTIME 300</tt><tt><br>
</tt><tt>FINALDELAY 30</tt><tt><br>
</tt><tt>CERTVERIFY 0</tt><tt><br>
</tt><tt>FORCESSL 0</tt></font><font
size="2" face="Verdana"><br>
<br>
-----<br>
upssched.conf:<br>
</font><font size="2"><tt>$ grep -Ev
"^(#|\s*$)"
/etc/nut/upssched.conf</tt><tt><br>
</tt><tt>CMDSCRIPT
/etc/nut/upssched-cmd</tt><tt><br>
</tt><tt>PIPEFN
/etc/nut/upssched.pipe</tt><tt><br>
</tt><tt>LOCKFN
/etc/nut/upssched.lock</tt><tt><br>
</tt><tt>AT ONBATT myups1 EXECUTE
onbatt</tt><tt><br>
</tt><tt>AT LOWBATT myups1 EXECUTE
lowbatt</tt></font><font
size="2" face="Verdana"><br>
<br>
-----<br>
upssched-cmd:<br>
</font><tt><font size="2">$ cat
/etc/nut/upssched-cmd<br>
#!/bin/sh<br>
#<br>
# This script should be called by upssched via the CMDSCRIPT
directive.<br>
#<br>
# Here is a quick example to show how to handle a bunch of
possible<br>
# timer names with the help of the case structure.<br>
#<br>
# This script may be replaced with another program without
harm.<br>
#<br>
# The first argument passed to your CMDSCRIPT is the name of
the timer<br>
# from your AT lines.<br>
OPTION="$1"<br>
SCRIPT="$0"<br>
<br>
logger -t $SCRIPT "Script called with arg
$OPTION"<br>
<br>
case $OPTION in<br>
lowbatt)<br>
logger -t $SCRIPT "UPS Low Battery: Begin shutting
down clients"<br>
/root/bin/remote-shutdown-nas<br>
sleep 1<br>
/root/bin/remote-shutdown-win 192.168.123.2<br>
sleep 1<br>
/root/bin/remote-shutdown-win 192.168.123.3<br>
sleep 20<br>
;;<br>
onbatt)<br>
logger -t $SCRIPT "UPS on battery"<br>
;;<br>
upsgone)<br>
logger -t $SCRIPT "The UPS has been gone for
awhile"<br>
;;<br>
*)<br>
logger -t $SCRIPT "Unrecognized arg:
$OPTION"<br>
;;<br>
esac<br>
<br>
exit 0</font></tt><font size="2"
face="Verdana"><br>
<br>
UPS communications are working:<br>
</font><font size="2"><tt>$ upsc
myups1</tt><tt><br>
</tt><tt>Init SSL without certificate
database</tt><tt><br>
</tt><tt>battery.charge:
100</tt><tt><br>
</tt><tt>battery.charge.low:
80</tt><tt><br>
</tt><tt>battery.charge.warning:
90</tt><tt><br>
</tt><tt>battery.mfr.date:
CPS</tt><tt><br>
</tt><tt>battery.runtime:
1350</tt><tt><br>
</tt><tt>battery.runtime.low:
900</tt><tt><br>
</tt><tt>battery.type:
PbAcid</tt><tt><br>
</tt><tt>battery.voltage:
24.0</tt><tt><br>
</tt><tt>battery.voltage.nominal:
24</tt><tt><br>
</tt><tt>device.mfr: CPS</tt><tt><br>
</tt><tt>device.model:
CST135XLU</tt><tt><br>
</tt><tt>device.serial:
CR7GT2000910</tt><tt><br>
</tt><tt>device.type: ups</tt><tt><br>
</tt><tt>driver.flag.ignorelb:
enabled</tt><tt><br>
</tt><tt>driver.name:
usbhid-ups</tt><tt><br>
</tt><tt>driver.parameter.pollfreq:
30</tt><tt><br>
</tt><tt>driver.parameter.pollinterval:
10</tt><tt><br>
</tt><tt>driver.parameter.port:
auto</tt><tt><br>
</tt><tt>driver.parameter.synchronous:
no</tt><tt><br>
</tt><tt>driver.parameter.vendorid:
0764</tt><tt><br>
</tt><tt>driver.version:
2.7.4</tt><tt><br>
</tt><tt>driver.version.data: CyberPower HID
0.4</tt><tt><br>
</tt><tt>driver.version.internal:
0.41</tt><tt><br>
</tt><tt>input.voltage:
119.0</tt><tt><br>
</tt><tt>input.voltage.nominal:
120</tt><tt><br>
</tt><tt>output.voltage:
136.0</tt><tt><br>
</tt><tt>ups.beeper.status:
enabled</tt><tt><br>
</tt><tt>ups.delay.shutdown:
20</tt><tt><br>
</tt><tt>ups.delay.start:
30</tt><tt><br>
</tt><tt>ups.load: 26</tt><tt><br>
</tt><tt>ups.mfr: CPS</tt><tt><br>
</tt><tt>ups.model:
CST135XLU</tt><tt><br>
</tt><tt>ups.productid:
0501</tt><tt><br>
</tt><tt>ups.realpower.nominal:
810</tt><tt><br>
</tt><tt>ups.serial:
CR7GT2000910</tt><tt><br>
</tt><tt>ups.status: OL</tt><tt><br>
</tt><tt>ups.test.result: No test
initiated</tt><tt><br>
</tt><tt>ups.timer.shutdown:
-60</tt><tt><br>
</tt><tt>ups.timer.start:
-60</tt><tt><br>
</tt><tt>ups.vendorid:
0764</tt></font><font size="2"
face="Verdana"><br>
<br>
Show file access:<br>
</font><font size="2"><tt>$ ll
/etc/nut/</tt><tt><br>
</tt><tt>total 53,248</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 1,573 Mar 29 16:00
nut.conf</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 4,892 Mar 29 15:47
ups.conf</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 4,644 Dec 7 2017
upsd.conf</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 2,234 Mar 28 14:55
upsd.users</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 15,352 Mar 29 21:32
upsmon.conf</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 4,099 Mar 30 08:45
upssched.conf</tt><tt><br>
</tt><tt>-rwxr-x--- 1 root nut 986 Mar 30 14:58
upssched-cmd*</tt></font><font size="2"
face="Verdana"><br>
<br>
Verify nut user can write to the dir:<br>
</font><font size="2"><tt>$ sudo --user nut
touch /etc/nut/test</tt><tt><br>
</tt><tt>$ ll /etc/nut/</tt><tt><br>
</tt><tt>total 53,248</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 1,573 Mar 29 16:00
nut.conf</tt><tt><br>
</tt><tt>-rw-r--r-- 1 nut nut 0 Mar 30 15:49
test</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 4,892 Mar 29 15:47
ups.conf</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 4,644 Dec 7 2017
upsd.conf</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 2,234 Mar 28 14:55
upsd.users</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 15,352 Mar 29 21:32
upsmon.conf</tt><tt><br>
</tt><tt>-rw-r----- 1 root nut 4,099 Mar 30 08:45
upssched.conf</tt><tt><br>
</tt><tt>-rwxr-x--- 1 root nut 986 Mar 30 14:58
upssched-cmd*</tt></font><font size="2"
face="Verdana"><br>
<br>
Verify shell script executes as nut user:<br>
</font><font size="2"><tt>$ date; sudo
--user nut
/etc/nut/upssched-cmd dude</tt><tt><br>
</tt><tt>Sat 30 Mar 2019 03:50:56 PM
PDT</tt><tt><br>
</tt><tt>$ grep upssched /var/log/syslog | tail
-2</tt><tt><br>
</tt><tt>Mar 30 15:50:56 rockenfield
/etc/nut/upssched-cmd:
Script called with arg dude</tt><tt><br>
</tt><tt>Mar 30 15:50:56 rockenfield
/etc/nut/upssched-cmd:
Unrecognized arg: dude</tt></font><font
size="2"
face="Verdana"><br>
<br>
Any help is greatly appreciated. Thanks a lot!<br>
<br>
-MikeD</font><br>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre"
wrap="">_______________________________________________
Nut-upsuser mailing list
<a class="moz-txt-link-abbreviated"
href="mailto:Nut-upsuser@alioth-lists.debian.net">Nut-upsuser@alioth-lists.debian.net</a>
<a class="moz-txt-link-freetext"
href="https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser">https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser</a></pre>
</div>
<br>
</body>
</html>
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 at 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 <miked at softtalker.com> > *To:* Nut Users <nut-upsuser at alioth-lists.debian.net> > *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 at 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 > Nut-upsuser at alioth-lists.debian.net > https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser > > > > _______________________________________________ > Nut-upsuser mailing list > Nut-upsuser at alioth-lists.debian.net > https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser >