Cobra Forum

Linux Community Discussions => Ubuntu, Linux and OS Chat => Topic started by: kalpana on Nov 07, 2023, 03:13 AM

Title: Trouble Triggering Script on UPS Power Failure using NUT
Post by: kalpana on Nov 07, 2023, 03:13 AM
I'm currently facing an issue with configuring NUT (Network UPS Tools) to trigger a script when my UPS goes on battery power (ONBATT event). Despite trying various configurations and troubleshooting steps, I haven't been able to get the script to execute when the power failure occurs.


Here's an overview of what I've tried so far:


1. Configuration Files and Script


I have added the following lines to my upsmon.conf file:


NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYCMD /home/nut/batt.sh


The batt.sh script is located at /home/nut/batt.sh and has the execute permission set (chmod +x batt.sh).
The script is simple and logs message to a file (/home/nut/log.txt). Scripts runs on manual execution.



2. Troubleshooting Steps Taken


I've checked system logs (/var/log/syslog) for NUT-related messages but haven't found any relevant entries indicating script execution.
The DEBUGLEVEL option doesn't seem to be available in upsmon.conf for increasing debug output.
I've restarted the NUT service after making changes to configuration files.
The NOTIFYFLAG and NOTIFYCMD settings appear to be correctly defined in upsmon.conf.

NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC



4. Permissions and Ownership


I've given user nut sufficient permissions to execute the script. Even made home directory for nut user.
The batt.sh script is owned by nut user and has the execute permission set.
I've checked that there are no typos or syntax errors in the configuration files.


Has anyone else encountered a similar issue with NUT? Are there any suggestions or insights you can provide to help me resolve this issue?