[Nut-upsuser] Unable run command on notify events

Arnaud Quette aquette.dev at gmail.com
Thu Apr 7 15:56:53 UTC 2011


Hi Antoine,

2011/4/7 GATINEAU, ANTOINE (ANTOINE) <antoine.gatineau at alcatel-lucent.com>

> Hello,
>
> I'm trying to integrate upsmon with my alarm management application.
> For that I wan't to use NOTIFYCMD from upsmon. I am having troubles making
> everything work together.
>
> I'm using nut version 2.4.3
>
> I created a nutmon user and my script defined in NOTIFYCMD works perfectly
> when executed in a nutmon shell.
> I have configured RUN_AS_USER nutmon
>
> Here is upsmon.conf :
> MONITOR ups_on_usb at localhost 1 nut nut master
> RUN_AS_USER nutmon
> SHUTDOWNCMD "/sbin/shutdown -h +0"
> MINSUPPLIES 1
> POLLFREQ 30
> POLLFREQALERT 30
> HOSTSYNC 15
> DEADTIME 60
> POWERDOWNFLAG /etc/killpower
> RBWARNTIME 43200
> NOCOMMWARNTIME 300
> FINALDELAY 5
> NOTIFYCMD "upsAlarmManager"
> NOTIFYMSG ONLINE "UPS %s state is on line"
> NOTIFYMSG ONBATT "UPS %s state is on battery"
> NOTIFYMSG LOWBATT "UPS %s battery level is low"
> NOTIFYMSG SHUTDOWN "UPS %s triggered a server shutdown"
> NOTIFYMSG REPLBATT "UPS %s battery needs to be replaced"
> NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
> NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
> NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
> NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC
> NOTIFYFLAG REPLBATT SYSLOG+EXEC
>
> upsAlarmManager's path is defined i environment variable $PATH and i have
> the same behavior using the complete path.
>

as a general best practice, prefer to use absolute path.
this way, you avoid path related issues due to the launch context (see
below)


> In order to check if it is called, the script writes in /tmp/alarm.txt
>
> Here are my results :
> Upsmon runing as daemon by "service ups start" => /tmp/alarm.txt empty,
> alarms are not sent
> Upsmon runing using command line as root "/usr/sbin/upsmon" =>
> /tmp/alarm.txt empty, alarms are not sent
> Upsmon runing in debug using command line as root "/usr/sbin/upsmon -D" =>
> /tmp/alarm.txt is written, alarms are sent to my alarm management framework.
>

are you cleaning the testbed before each tests (ie "rm -f /tmp/alarm.txt"),
just to be sure?


> I want it to work as daemon. Did i miss something, what is the difference
> between debug and the other modes?
>

the user context you launched the command from... but more probably here,
the way you retrieve data from upsAlarmManager to write it to the file and
send it.

To be able to confirm, or at least troubleshoot this issue, I'd need, if
possible, to have a look at your script.
If that pose a problem to do it publicly, don't hesitate to send it to my @
eaton.com address.

cheers,
Arnaud
-- 
Linux / Unix Expert R&D - Eaton - http://powerquality.eaton.com
Network UPS Tools (NUT) Project Leader - http://www.networkupstools.org/
Debian Developer - http://www.debian.org
Free Software Developer - http://arnaud.quette.free.fr/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/nut-upsuser/attachments/20110407/fb5b8616/attachment.htm>


More information about the Nut-upsuser mailing list