[Nut-upsuser] upssched. Again.

Arjen de Korte nut+users at de-korte.org
Mon Jun 25 07:38:52 UTC 2007


Ciprian Marius Vizitiu wrote:

>>> SERVER=yes 
>>> MODEL=apcsmart 
>>> DEVICE=/dev/ttyS0 
>>> OPTIONS= 
>> Please change to 
>>
>>       MODEL=upsdrvctl 
>>       DEVICE= 
> 
> OK, done. But it looks like there is a small bug in nut's FC6 init scripts
> which prevents this config from working with "restart".

Since stopping a driver is an asynchronous process, so you'll need to
wait a couple of seconds after stopping a driver before you can start it
again. If you put 'sleep 3' between stop and start in the restart
section of this init script, you'll be fine.

> I mean if I change
> it to "upsdrvctl" you can not issue "service ups restart" because it fails
> with: 
> 
> Stopping UPS monitor:                                      [  OK  ]
> Stopping upsd:                                             [  OK  ] 
> Shutting down upsdrvctl: Network UPS Tools - UPS driver controller 2.0.3 
> Stopping UPS: APC750 
> 
> Starting upsdrvctl: Network UPS Tools - UPS driver controller 2.0.3 
> Network UPS Tools (version 2.0.3) - APC Smart protocol driver 
>         Driver version 1.99.7, command table version 2.0 
> /dev/ttyS0 is locked by another process 
> Driver failed to start (exit status=1) 
>                                                         [FAILED]
> 
> Starting upsd: Network UPS Tools upsd 2.0.3 
> Connected to UPS [APC750]: apcsmart-ttyS0 
> Synchronizing...Read from UPS [APC750] failed: Connection reset by peer 
> ..... giving up 
> Data for UPS [APC750] is stale - check driver 
> Can't connect to UPS [APC750] (apcsmart-ttyS0): No such file or directory 
>                                                         [  OK  ]
> 
> Starting UPS monitor (master): Network UPS Tools upsmon 2.0.3 
> UPS: APC750 at 127.0.0.1 (master) (power value 1) 
> Using power down flag file /etc/killpower               [  OK  ] 

That could be expected.

> And then of course you get the warnings (a clear proof that upsmon is
> working): 
> 
> 
> 
> Broadcast message from nut (Sun Jun 24 21:55:48 2007): 
> Communications with UPS APC750 at 127.0.0.1 lost 
> 
> Broadcast message from nut (Sun Jun 24 21:55:53 2007): 
> UPS APC750 at 127.0.0.1 is unavailable 
> 
> 
> 
> Instead one must do "ups stop" and then "ups start"; kinda of a silly...
> Just out of curiosity why not use apcsmart? 'cos in this situation APC is
> the only UPS controlled by NUT.

This is not how the drivers are supposed to be started and will cause
failures as soon as you upgrade your setup to nut-2.0.5.

>>> AT ONBATT APC750 at localhost EXCUTE onbattwarn 
>> Typo? The command here should read EXECUTE. 
> 
> Yeah... :-s Me angry that upssched doesn't behave. I've been here in January
> with my Unitek UPS. Same problem... Haven't fixed it back then have to now. 
> 
> ... OK, fixed the typo; Absolutely no difference. :-| 
> 
>> What are the contents of 'upsmon.conf', most notably the EXEC 
>> flag on the relevant NOTIFYFLAG items? 
> 
> ... Oh sorry, forgot about this one; here: 
> 
> RUN_AS_USER nut 
> MONITOR APC750 at 127.0.0.1 1 <censored> <censored> master 
> MINSUPPLIES 1 
> SHUTDOWNCMD "/sbin/shutdown -h +0" 
> NOTIFYCMD /usr/sbin/upssched 
> POLLFREQ 5 
> POLLFREQALERT 5 
> HOSTSYNC 15 
> DEADTIME 15 
> POWERDOWNFLAG /etc/killpower 
> NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC 
> NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC 
> NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC 
> RBWARNTIME 43200 
> NOCOMMWARNTIME 300 
> FINALDELAY 5 
> 
> Oh and just before you ask, 
> 
> # /usr/sbin/upssched 
> Error: UPSNAME and NOTIFYTYPE must be set. 
> This program should only be run from upsmon. 

A way to bypass this for testing purposes, is to export both UPSNAME and
NOTIFYTYPE as environment variables

> ... So it's there. 
> 
>> Is upsmon running? 
> 
> Not only is shows at ps but each time I unplug the UPS I can see in
> messages: 
> 
> Jun 24 21:50:26 mah upsmon[5129]: UPS APC750 at 127.0.0.1 on battery 
> Jun 24 21:50:26 mah wall[5142]: wall: user nut broadcasted 1 lines (33
> chars) 
> Jun 24 21:51:01 mah upsmon[5129]: UPS APC750 at 127.0.0.1 on line power 
> Jun 24 21:51:01 mah wall[5148]: wall: user nut broadcasted 1 lines (36
> chars) 
> 
> Looks as if upsmon is working but still no upssched. :-| 
> 
> 
> 
> PS. OK, just to make sure I've replaced: 
> 
> NOTIFYCMD /usr/sbin/upssched 
> 
> ... with 
> 
> NOTIFYCMD /usr/sbin/upssched-cmd 
> 
> Upon the next unplug I could see both the file in /tmp and the log message
> from my script; So the script is accessible but upsschedule no? :-o
> 
> PPS. selinux disabled... :-| 
> 
> 
> 





More information about the Nut-upsuser mailing list