Greg Troxel
2026-Jan-10 23:23 UTC
[Nut-upsuser] help requested for setting up email notification of UPS events
hakayova via Nut-upsuser <nut-upsuser at alioth-lists.debian.net> writes:> I have a working UPS setup on my NAS, which runs FreeBSD14.3. It can > communicate with the UPS, and both nut and upsd services are running > as expected. I made the following changes in the upsmon.conf to enable > email notification to myself: > > NOTIFYCMD /usr/local/bin/mailme > NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC > NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC > NOTIFYFLAG FSD SYSLOG+WALL+EXEC > NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC > NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC > NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC > NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC > NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC > NOTIFYFLAG NOPARENT SYSLOG+WALL+EXEC > > This is the script /usr/local/bin/mailme: > > #!/usr/bin/env sh > > echo "$*" | /usr/bin/mail -s "Notification for UPS event" myemail at example.com- check that the script is 755 or 555 permissions - become the nut user with su, /bin/sh, and clear out the environment. Set PATH to dafault. Then /usr/local/bin/mailme foo bar baz and see what happens - read /var/log/messages and /var/log/maillog, or however you spell those logs on your system
hakayova
2026-Jan-11 00:04 UTC
[Nut-upsuser] help requested for setting up email notification of UPS events
Thank you for your quick response. Please see below for my replies. On 26/01/10 06:23PM, Greg Troxel via Nut-upsuser wrote:> hakayova via Nut-upsuser <nut-upsuser at alioth-lists.debian.net> writes: > > > I have a working UPS setup on my NAS, which runs FreeBSD14.3. It can > > communicate with the UPS, and both nut and upsd services are running > > as expected. I made the following changes in the upsmon.conf to enable > > email notification to myself: > > > > NOTIFYCMD /usr/local/bin/mailme > > NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC > > NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC > > NOTIFYFLAG FSD SYSLOG+WALL+EXEC > > NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC > > NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC > > NOTIFYFLAG SHUTDOWN SYSLOG+WALL+EXEC > > NOTIFYFLAG REPLBATT SYSLOG+WALL+EXEC > > NOTIFYFLAG NOCOMM SYSLOG+WALL+EXEC > > NOTIFYFLAG NOPARENT SYSLOG+WALL+EXEC > > > > This is the script /usr/local/bin/mailme: > > > > #!/usr/bin/env sh > > > > echo "$*" | /usr/bin/mail -s "Notification for UPS event" myemail at example.com > > > - check that the script is 755 or 555 permissionsIndeed this was a problem. I modified the permissions from 750 to 755.> > - become the nut user with su, /bin/sh, and clear out the environment.Cannot do it in FreeBSD, it appears. # su nut This account is currently not available. # su -l nut /usr/local/bin/mailme su: no directory # cat /etc/passwd | grep nut nut:*:316:316:Network UPS Tools user:/nonexistent:/usr/sbin/nologin> Set PATH to dafault. Then > /usr/local/bin/mailme foo bar baz > and see what happensSee above, perhaps the nut user doesn't have a PATH?> > - read /var/log/messages and /var/log/maillog, or however you spell > those logs on your systemThanks to this pointer, I realized that upsd.conf and upsmon.conf were owned by root and could not be accessed by the nut user. I changed the ownership of them and set permissions to 750. The error messages in /var/log/messages disappeared after that. /var/log/maillog does not show any entry with the power outage simulation, likely becuase the nut user cannot find and execute the mailme script as described above.> > _______________________________________________ > Nut-upsuser mailing list > Nut-upsuser at alioth-lists.debian.net > https://alioth-lists.debian.net/cgi-bin/mailman/listinfo/nut-upsuser