Anton E. Panchenko
2009-Jun-19 01:02 UTC
[Nut-upsuser] UPS does not want to power off itself
Greetings! I have successfully installed and configured nut package. All i want now is to power off ups. If i run upsmon -c fsd as root - everything goes fine, system and ups gracefully shutting down. If i unplug power cable from an ups, then system is down, but ups still on load. Any help would be appreciated. Debian Lenny x86 ups.conf [ippon] driver = megatec port = /dev/ttyS0 desc = "Ippon Smart Power Pro 1000 upsd.conf ACL all 0.0.0.0/0 ACL localhost 127.0.0.1/32 ACCEPT localhost REJECT all upsd.users [monuser] password = pass allowfrom = localhost upsmon master actions = set instcmds = ALL upsmon.conf MONITOR ippon at localhost 1 monuser pass master MINSUPPLIES 1 SHUTDOWNCMD "/sbin/shutdown -h now" NOTIFYCMD /sbin/upssched POLLFREQ 5 POLLFREQALERT 5 HOSTSYNC 15 DEADTIME 15 POWERDOWNFLAG /etc/killpower NOTIFYFLAG ONLINE SYSLOG+WALL NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC NOTIFYFLAG FSD SYSLOG+WALL NOTIFYFLAG COMMOK SYSLOG+WALL NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC NOTIFYFLAG SHUTDOWN SYSLOG+WALL NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC NOTIFYFLAG NOPARENT SYSLOG+WALL RBWARNTIME 43200 NOCOMMWARNTIME 300 FINALDELAY 5 upsshed.conf CMDSCRIPT /etc/nut/upssched-cmd PIPEFN /var/run/nut/upssched.pipe LOCKFN /var/run/nut/upssched.lock AT ONBATT ippon at localhost START-TIMER fsd 30 #for testing AT ONLINE ippon at localhost CANCEL-TIMER fsd upsshed-cmd #!/bin/sh MSG="The UPS is running on battery about 2 minutes, doing force shutdown" case $1 in fsd) logger -t upssched-cmd $MSG /sbin/upsmon -c fsd ;; *) logger -t upssched-cmd "ERROR!! $0 Unrecognized command: $1" ;; esac crw-rw---- 1 root nut 4, 64 ??? 19 11:58 ttyS0 crw-rw---- 1 root nut 4, 65 ??? 19 11:41 ttyS1 crw-rw---- 1 root dialout 4, 66 ??? 19 11:41 ttyS2 crw-rw---- 1 root dialout 4, 67 ??? 19 11:41 ttyS3 wcc:/var/run/nut# ls -la ????? 20 drwxrwx--- 2 root nut 4096 ??? 19 11:41 . drwxr-xr-x 5 root root 4096 ??? 19 11:41 .. srw-rw---- 1 nut nut 0 ??? 19 11:41 megatec-ippon -rw-r--r-- 1 nut nut 5 ??? 19 11:41 megatec-ippon.pid -rw-r--r-- 1 nut nut 5 ??? 19 11:41 upsd.pid -rw-r--r-- 1 root root 5 ??? 19 11:41 upsmon.pid wcc:/var/run/nut# cat /etc/init.d/halt | grep -v "#" NETDOWN=yes PATH=/sbin:/usr/sbin:/bin:/usr/bin [ -f /etc/default/halt ] && . /etc/default/halt . /lib/lsb/init-functions do_stop () { if [ "$INIT_HALT" = "" ] then case "$HALT" in [Pp]*) INIT_HALT=POWEROFF ;; [Hh]*) INIT_HALT=HALT ;; *) INIT_HALT=POWEROFF ;; esac fi if (test -f /etc/killpower) then echo "Killing the power, bye!" /sbin/upsdrvctl shutdown sleep 120 fi if [ "$INIT_HALT" = "POWEROFF" ] && [ -x /etc/init.d/ups-monitor ] then /etc/init.d/ups-monitor poweroff fi hddown="-h" if grep -qs '^md.*active' /proc/mdstat then hddown="" fi poweroff="-p" if [ "$INIT_HALT" = "HALT" ] then poweroff="" fi netdown="-i" if [ "$NETDOWN" = "no" ]; then netdown="" fi log_action_msg "Will now halt" halt -d -f $netdown $poweroff $hddown } case "$1" in start) ;; restart|reload|force-reload) echo "Error: argument '$1' not supported" >&2 exit 3 ;; stop) do_stop ;; *) echo "Usage: $0 start|stop" >&2 exit 3 ;; esac :
Citeren "Anton E. Panchenko" <pae op chernigovka.org>: [...]> upsshed-cmd > #!/bin/sh > MSG="The UPS is running on battery about 2 minutes, doing force shutdown" > > case $1 in > fsd) > logger -t upssched-cmd $MSG > /sbin/upsmon -c fsd > ;; > *) > logger -t upssched-cmd "ERROR!! $0 Unrecognized command: $1" > ;; > esacAssuming the message is logged (and you thereby having confirmed that indeed the 'fsd' timer is elapsed, the problem is that upssched will run with the same UID as upsmon (that started this timer). In that case, the command /sbin/upsmon -c fsd will also run as this user. So in order to test this, you must make sure that the above command when running as a non-privileged user will shutdown your system or you must run upsmon as a privileged user. You might be able to do something similar by allowing this user to use 'sudo' for just this command. Choose your poison. Best regards, Arjen -- Please keep list traffic on the list