On 2010-10-08 10:36, Reg gie wrote:
>
> Here’s the problems.
>
> First, when “nut” is running sometimes the Linux “Power Management
> Preference” (PMP) shows a UPS tab, and sometimes it doesn’t. I haven’t
> figured it all out yet but it seem rather random when I do an init 3
> then init 5. That is, on restarting X Windows PMP might or might not
> have a UPS tab.
>
> Regardless of whether PMP has a UPS tab or not, nut seems to work just
> fine.
>
> However, that’s a side issue. The real issue that I am having is that
> nut doesn’t shut down my server when I put the UPS on battery. I have
> run the UPS right down to 10% and it’s minimum threshold is 20%.
>
> And, even though nut doesn’t shut down my server it does work in every
> other way that I can test. Even the web interface works.
>
> Could someone who has got this working please look at my configuration
> and let me know if they see anything wrong, or give ideas on how to
> troubleshoot this, please?
I have it working on another machine with 11.0 - currently it is using 11.2 but I haven’t revised if
it still works. My comments will be based on the 11.0 config.
> Here is my configuration:
>
>
> Code:
> --------------------
>
> HOSTS.CONF
> MONITOR myups@localhost “Tripp Lite UPS SU1500XL”
A shorter name is probably safer. I use “Local UPS”.
>
> NUT.CONF
> MODE = standalone (also tried with “MODE = none”)
I don’t have that file. My version might be older, though.
> UPS.CONF
> [myups]
> driver = usbhid-ups
> port = /dev/usb/hiddev0
> desc = "Tripp Lite UPS SU1500XL
I had to fight this one. I had to run it manually and see what happened - which in my case is that
the daemon had a long startup sequence which lasted a bit more than a minute, and the timeout was
precisely a minute - thus it failed. Thus my config is:
maxstartdelay = 70
[myups]
“BELKIN Active Battery Backup”
driver = megatec_usb -DDD
port = auto
port=/dev/hiddev0
desc = “Local UPS”
offdelay=1
user = root
I think I wrote notes somewhere on how I discovered this.
> UPSD.CONF
It is empty? Weird. I have:
Access Control Lists (ACLs)
ACL all 0.0.0.0/0
ACL localhost 127.0.0.1/32
ACCEPT localhost
REJECT all
> UPSD.USERS
> [upsmaster]
> password = ***********
> allowfrom = localhost
> upsmon master
> actions = SET
> instcmds = ALL
>
> [upsslave]
> password = ***********
> allowfrom = localhost
> upsmon slave
>
I have:
[admin]
password = mypass
actions = SET
instcmds = ALL
[upsd]
password = 123456
allowfrom = localhost
upsmon master
> UPSMON.CONF
> MONITOR myups@localhost 1 upsmaster ******** master
> MINSUPPLIES 1
> SHUTDOWNCMD “/sbin/shutdown -h now”
> POLLFREQ 5
> POLLFREQALERT 5
> HOSTSYNC 15
> DEADTIME 15
> POWERDOWNFLAG /etc/killpower
> NOTIFYFLAG ONLINE SYSLOG
> NOTIFYFLAG COMMOK SYSLOG
> NOTIFYFLAG SHUTDOWN SYSLOG
> NOTIFYFLAG ONBATT SYSLOG+WALL
> NOTIFYFLAG LOWBATT SYSLOG+WALL
> NOTIFYFLAG FSD SYSLOG+WALL
> NOTIFYFLAG NOCOMM SYSLOG+WALL
> NOTIFYFLAG COMMBAD SYSLOG+WALL
>
> RBWARNTIME 43200
> NOCOMMWARNTIME 300
> FINALDELAY 5
I have:
RUN_AS_USER upsd
MONITOR myups@localhost 1 upsd 123456 master
MINSUPPLIES 1
SHUTDOWNCMD “/sbin/shutdown -h +0”
Triggers hibernation
SHUTDOWNCMD “/usr/bin/powersave -U”
Example:
NOTIFYCMD /usr/local/ups/bin/notifyme
Ojo, que este es especial de suse.
NOTIFYCMD /usr/lib/powersave/powersave-notify
editar el de arriba para añadir la linea “/usr/sbin/upssched $*” al final
#NOTIFYCMD /usr/sbin/upssched
(notify command above is suse specific; and powersave-notify had to be edited to add
“/usr/sbin/upssched $*” as the last line. I wrote a bugzilla about this, it was broken).
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower
NOTIFYFLAG REPLBATT SYSLOG
NOTIFYFLAG NOPARENT SYSLOG
NOTIFYFLAG ONLINE SYSLOG+EXEC
NOTIFYFLAG COMMOK SYSLOG+EXEC
NOTIFYFLAG SHUTDOWN SYSLOG+EXEC
NOTIFYFLAG ONBATT SYSLOG+EXEC
NOTIFYFLAG LOWBATT SYSLOG+EXEC
NOTIFYFLAG FSD SYSLOG+EXEC
NOTIFYFLAG NOCOMM SYSLOG+EXEC
NOTIFYFLAG COMMBAD SYSLOG+EXEC
RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5
> UPSSCHED.CONF
> CMDSCRIPT /bin/upssched-cmd
#CMDSCRIPT /usr/local/ups/bin/upssched-cmd
CMDSCRIPT /bin/upssched-cmd
(that file has to be edited, original is a sample, I think. I don’t have that file in the backup I’m
looking at to write this)
PIPEFN /var/lib/ups/upssched/upssched.pipe
LOCKFN /var/lib/ups/upssched/upssched.lock
AT ONBATT * EXECUTE onbattery
AT ONLINE * EXECUTE ups-back-on-power
AT ONBATT * START-TIMER onbattwarn 10
AT ONBATT * START-TIMER hybernate 30
AT ONLINE * CANCEL-TIMER onbattwarn
AT ONLINE * CANCEL-TIMER hybernate
>
> UPSSET.CONF
> I_HAVE_SECURED_MY_CGI_DIRECTORY
Ok.
>
> The two HTML files are too long to post but are unchanged anyway.
They wouldn’t matter for it to work.
For testing, you should see entries in syslog the moment or a bit later than when you pull the plug,
and later when it is going to power off (for which it needs the right command to be configured). In
my case, I power off much earlier, a minute or two after power failure.
This is done by the “AT ONBATT” lines, but the tokens given to “START-TIMER” must exist. IIRC they
are arbitrary tokens for a “case” selector in the script /bin/upssched-cmd you write. Perhaps that’s
the glue you are missing (from memory, I can’t check right now).
Ok, found a copy. The default file is this:
case $1 in
upsgone)
logger -t upssched-cmd "The UPS has been gone for awhile"
;;
*)
logger -t upssched-cmd "Unrecognized command: $1"
;;
esac
My modified file was this (a later version, actually, which I can’t find now):
case $1 in
upsgone)
logger -t upssched-cmd "The UPS has been gone for awhile"
;;
#Cer
onbattery)
touch /etc/ups-on-battery
logger -t upssched-cmd "¡Estamos en batería!"
;;
onbattwarn)
logger -t upssched-cmd "Llevamos en batería 30 segundos, hibernaremos en otros 30"
;;
hybernate)
/usr/sbin/upsmon -c fsd
;;
ups-back-on-power)
/bin/rm -f /etc/ups-on-battery
logger -t upssched-cmd "La corriente ha vuelto a tiempo."
;;
*)
logger -t upssched-cmd "Unrecognized command: $1"
;;
esac
That script is actually responsible of doing things, it is crucial.
Or… hold on. It is crucial on my case, because I power off based on time, not based on remaining
battery charge (the default setup). The default means a deep discharge. If you have a second power
failure in the same day, battery will still be depleted and it is possible it will not last even two
minutes.
In your case, your problem might be that the unit is not reporting low battery, or the daemon not
seeing it, or that it is not triggering the appropriate response.
…]
I found my notes, but they are in Spanish. Let me see…
/usr/lib/powersave/powersave-notify is suse specific. It contains (or contained):
/bin/dbus-send --system --print-reply --dest=com.novell.powersave \
/com/novell/powersave/scripts \
com.novell.powersave.scripts.ScriptReturn int32:-1 int32:2 \
string:"$*"
and is not documented (and obsolete).
NOTIFYCMD is called with the events defined “RUN” in upsmon.conf. Has to be changed:
NOTIFYCMD /usr/sbin/upssched
upssched.conf:
CMDSCRIPT /bin/upssched-cmd
default values:
IPEFN /var/lib/ups/upssched/upssched.pipe
LOCKFN /var/lib/ups/upssched/upssched.lock
Create that directory, owned by upsd.
There is a “/usr/bin/upssched-cmd”, better move to /bin, as /usr might not be mounted yet.
(I reported all this in a Bugzilla, so they should be corrected in your version)
«Furthermore, this procedure is incomplete: after hibernation succeeds, the UPS remains ON, because
the procedure does not send the power-off command to the UPS. The documentation contains a method to
use when the computer is to be powered off, but not when it is to be suspended to disk.»
«This command could perhaps be added to pm-utils somewhere, but is is not documented.»
–
Cheers / Saludos,
Carlos E. R.
(from 11.2 x86_64 “Emerald” at Telcontar)