[Nut-upsuser] NUT & UPS, how to shut down client after 2 min on battery?

Rafael Reinoso reinoso at hotmail.com
Thu Jan 12 08:20:30 GMT 2023


Now I have this in /etc/nut/upsmon.conf (my QNAP NAS wants admin and 123456 or not working)


RUN_AS_USER root
MONITOR qnapups at localhost 1 admin 123456 master
MONITOR qnapups at 192.168.222.252 3493 admin 123456 slave
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +0"
POLLFREQ 5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME 15
POWERDOWNFLAG /etc/killpower

NOTIFYFLAG ONLINE SYSLOG+EXEC
NOTIFYFLAG ONBATT SYSLOG+EXEC
NOTIFYFLAG LOWBATT SYSLOG+EXEC
NOTIFYFLAG REPLBATT SYSLOG+EXEC
NOTIFYCMD /usr/sbin/upssched

RBWARNTIME 43200
NOCOMMWARNTIME 300
FINALDELAY 5




And in /etc/nut/upssched.conf (changed from 2 min to 4 min)



CMDSCRIPT /etc/nut/upssched-execscript.sh

PIPEFN /etc/nut/upssched.pipe
LOCKFN /etc/nut/upssched.lock

AT ONBATT * START-TIMER shutdown_onbatt 240
AT ONBATT * EXECUTE info_onbatt

AT ONLINE * CANCEL-TIMER shutdown_onbatt
AT ONLINE * EXECUTE ups-back-on-power

AT LOWBATT * EXECUTE shutdown_lowbatt

AT REPLBATT * EXECUTE replace_batt




And in /etc/nut/upssched-execscript.sh



#! /bin/sh
case $1 in
    shutdown_onbatt)
        logger -t upsmon[upssched] "shutdown_onbatt): Triggering shutdown after 4 minutes on battery"
        /sbin/shutdown -h +0
        ;;

    shutdown_lowbatt)
        logger -t upsmon[upssched] "shutdown_lowbatt): Triggering shutdown when battery.charge.low is under 50%"
        /sbin/shutdown -h +0
        ;;

    info_onbatt)
        logger -t upsmon[upssched] "info_onbatt): Now on battery"
        ;;

    ups-back-on-power)
        logger -t upsmon[upssched] "ups-back-on-power): UPS back on power"
        ;;

    replace_batt)
        message="Quick self-test indicates battery requires replacement"
        logger -t upsmon[upssched] "replace_batt): $message"
        ;;

    *)
        logger -t upsmon[upssched] "*) = Unrecognized command: $1"
        ;;
esac




And in /etc/nut/ups.conf


[qnapups]
    driver = usbhid-ups
    port = auto
    desc = "UPS"
    ignorelb
    override.battery.charge.low=50




So I have these files

[root at ipfire2 nut]# pwd
/etc/nut
[root at ipfire2 nut]# ls -la
total 104
drwxr-xr-x  2 root root  4096 Jan 10 09:23 .
drwxr-xr-x 50 root root  4096 Jan 10 10:33 ..
-rw-r--r--  1 root root  1542 Jan 10 09:05 nut.conf
-rw-r--r--  1 root root  1538 Dec 18  2020 nut.conf.sample
-rw-r--r--  1 root root  4734 Jan 10 09:10 ups.conf
-rw-r--r--  1 root root  4618 Dec 18  2020 ups.conf.sample
-rw-r-----  1 root root  4606 Dec 22 08:44 upsd.conf
-rw-r--r--  1 root root  4578 Dec 18  2020 upsd.conf.sample
-rw-r-----  1 root root  2292 Dec 22 07:11 upsd.users
-rw-r--r--  1 root root  2131 Dec 18  2020 upsd.users.sample
-rw-r--r--  1 root root 15569 Jan 10 10:20 upsmon.conf
-rw-r--r--  1 root root 15313 Dec 18  2020 upsmon.conf.sample
-rw-r--r--  1 root root  4173 Jan 10 10:22 upssched.conf
-rw-r--r--  1 root root  3895 Dec 18  2020 upssched.conf.sample
-rwxr-xr-x  1 root root   810 Jan 10 10:29 upssched-execscript.sh


Do all that seem right to you?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/nut-upsuser/attachments/20230112/45cb9cef/attachment.htm>


More information about the Nut-upsuser mailing list