[Nut-upsuser] Dummy-ups cycles between online and onbatt every 5 minutes. (Nut 2.8.0)

Dan Grostick danpower2023 at outlook.com
Fri Jun 16 21:21:59 BST 2023


Now that upsstats.cgi works, I've noticed that dummy-ups changes state every 5 minutes between OL and OB (probably when the 300 second timer expires). The UPS state stays online.
Also "online" and "onbatt" are broadcast to the console probably via WALL. (The state changes don't seem to be form the ups as upsshed-cmd doesn't run).   Upssched-cmd does run when the UPS is actually unplugged and plugged back in.
It happens on two different installation.

See attached screenshot and configuration.

Dan

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/nut-upsuser/attachments/20230616/842fcb53/attachment-0001.htm>
-------------- next part --------------
===============================================================================================================
heartbeat.conf:

ups.status: OL
TIMER 300
ups.status: OB
TIMER 300

================================================================================================================ 

    NUT configuration  2023-06-16 17:52:21 UTC

        ########### Operating system ###########
Kernel release 6.1.21-v7+ GNU/Linux
PRETTY_NAME="Raspbian GNU/Linux 11 (bullseye)"
NAME="Raspbian GNU/Linux"
VERSION_CODENAME=bullseye
Network UPS Tools upsd 2.8.0.1
Bash version 5.1.4(1)-release
User root
updated-nut-report version: 2020-08-07

        ########### USB attached UPS units ###########
Bus 001 Device 006: ID 051d:0002 American Power Conversion Uninterruptible Power Supply
Bus 001 Device 004: ID 0b38:0010 Gear Head 107-Key Keyboard

        ########### /etc/nut//nut.conf ###########
MODE=standalone

        ########### /etc/nut//ups.conf ###########
maxretry = 2
[ups]
        driver=usbhid-ups
        desc="APS BR1600G UPS"
        port=auto
        lowbatt=97
        offdelay=60
[heartbeat]
        driver=dummy-ups
        port=heartbeat.conf
        mode=dummy-loop
        desc="Heart beat verification of NUT"

        ########### /etc/nut//upsd.conf ###########
LISTEN 192.168.123.49 3493

        ########### /etc/nut//upsd.users ###########
        [upsmonitor]
                password  =  ****m****
                actions = SET
                instcmds = ALL
                upsmon primary
        [heartbeat]
                password  =  ****m****
                actions = SET
                instcmds = ALL
                upsmon primary
        [admin]
                password  =  ****m****
                actions = SET
                instcmds = ALL
        [dan]
                password  =  ****m****
                actions = SET
                instcmds = ALL

        ########### /etc/nut//upsmon.conf ###########
RUN_AS_USER root
MONITOR ups at localhost 1 upsmonitor  ****m****  primary
MONITOR heartbeat at localhost 0 heartbeat  ****m****  secondary
MINSUPPLIES 1
SHUTDOWNCMD "/sbin/shutdown -h +10"
NOTIFYCMD /usr/sbin/upssched
POLLFREQ  5
POLLFREQALERT 5
HOSTSYNC 15
DEADTIME  15
POWERDOWNFLAG /etc/killpower
NOTIFYMSG ONLINE        "online"
NOTIFYMSG ONBATT        "onbatt"
NOTIFYMSG LOWBATT       "lowbatt"
NOTIFYMSG FSD           "fsd"
NOTIFYMSG COMMOK        "commok"
NOTIFYMSG COMMBAD       "commbad"
NOTIFYMSG SHUTDOWN      "shutdown"
NOTIFYMSG REPLBATT      "replacebatt"
NOTIFYMSG NOCOMM        "nocomm"
NOTIFYMSG NOPARENT      "noparent"
NOTIFYFLAG ONLINE       SYSLOG+WALL+EXEC
NOTIFYFLAG ONBATT       SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT      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
RBWARNTIME 43200
NOCOMMWARNTIME 60
FINALDELAY 15

        ########### /etc/nut//upssched.conf ###########
CMDSCRIPT /etc/nut/upssched-cmd
PIPEFN /var/state/ups/upssched/upssched.pipe
LOCKFN /var/state/ups/upssched/upssched.lock
AT ONBATT   ups at localhost  START-TIMER onbatt-timer 5
AT ONBATT   ups at localhost  CANCEL-TIMER lowbatt-timer
AT ONBATT   ups at localhost  CANCEL-TIMER shutdown-timer
AT LOWBATT  ups at localhost  EXECUTE lowbatt
AT LOWBATT  ups at localhost  START_TIMER shutdown-timer 125
AT COMMBAD  ups at localhost  EXECUTE commbad
AT COMMOK   ups at localhost  CANCEL-TIMER nocomm-timer
AT COMMOK   ups at localhost  EXECUTE  commok
AT NOCOMM   ups at localhost  START-TIMER nocomm-timer 30
AT SHUTDOWN ups at localhost  EXECUTE powerdown
AT FSD      ups at localhost  EXECUTE fsd
AT NOPARENT ups at localhost  EXECUTE noparent
AT REPLBATT ups at localhost  EXECUTE replacebatt
AT ONLINE   ups at localhost  CANCEL-TIMER onbatt-timer
AT ONLINE   ups at localhost  CANCEL-TIMER shutdown-timer
AT ONLINE   ups at localhost  EXECUTE online
AT ONBATT   heartbeat at localhost  CANCEL-TIMER heartbeat-failure-timer
AT ONBATT   heartbeat at localhost  START-TIMER heartbeat-failure-timer 660

        ########### /etc/nut/upssched-cmd ###########
logger -t upssched-cmd: "upssched-cmd running"
UPS="ups at localhost"
STATUS=$( upsc $UPS ups.status)
CHARGE=$( upsc $UPS battery.charge)
CHMSG="[$STATUS] : $CHARGE%"
FILE="/tmp/u"
FILE1="/tmp/w"
FILE2="/tmp/x"
FILE3="/tmp/y"
FILE4="/tmp/z"
case $1 in
        online)
        logger -t upssched-cmd: "online"
        if [[ -f $FILE ]];
         then
        echo
        else
        touch $FILE
        rm -f $FILE1
        rm -f $FILE2
        rm -f $FILE3
        rm -f $FILE4
        MSG2="\nCurrent status: $CHMSG  $1"
        cat /etc/nut/online.txt >/tmp/message
        echo -e "$MSG2" >> /tmp/message
        msmtp -t </tmp/message
        fi
;;
        onbatt)
        rm $FILE
        logger -t upssched-cmd: "onbatt"
;;
        lowbatt)
        logger -t upssched-cmd: "lowbatt"
        MSG1="\nUPS low batt \n"
        MSG2="Current status: $CHMSG $1"
        cat /etc/nut/lowbatt.txt >/tmp/message
        echo -e "$MSG1 $MSG2" >>/tmp/message
        msmtp -t </tmp/message
;;
        commok)
        rm -f $FILE3
        logger -t upssched-cmd: "commok"
        msmtp -t dan.grostick at outlook.com </etc/nut/commok.txt
;;
        commbad)
        logger -t upssched-cmd: "commbad"
        if [[ -f $FILE3 ]];
         then
        echo
        else
        touch $FILE3
        msmtp -t dan.grostick at outlook.com </etc/nut/commbad.txt
        fi
;;
        shutdown-timer)
        logger -t upssched-cmd: "shutdown"
        msmtp -t dan.grostick at outlook.com </etc/nut/shutdown.txt
        /usr/sbin/upsmon -c shutdown
;;
        replacebatt)
        logger -t upssched-cmd: "replacebatt"
        if [[ -f $FILE2 ]];
         then
        echo
        else
        touch $FILE2
        msmtp -t dan.grostick at outlook.com </etc/nut/replacebatt.txt
        fi
;;
        nocomm)
        logger -t upssched-cmd: "nocomm"
        if [[ -f $FILE2 ]];
         then
        echo
        else
        touch $FILE2
        msmtp -t dan.grostick at outlook.com </etc/nut/nocomm.txt
        fi
;;
        noparent)
        logger -t upssched-cmd: "noparent"
        if [[ -f $FILE4 ]];
         then
        echo
        else
        touch $FILE4
        msmtp -t dan.grostick at outlook.com </etc/nut/noparent.txt
        fi
;;
        fsd)
        logger -t upssched-cmd: "fsd"
        msmtp -t dan.grostick at outlook.com </etc/nut/fsd.txt
;;
        heartbeat-failure-timer)
        logger -t upssched-cmd: "heart beat fails"
         MSG1="\nNUT hearbeat fails"
        MSG2="\nCurrent status: $CHMSG $1"
        MSG3="\n$(ps -elf |grep -E 'ups[dms] |nut')"
        cat /etc/nut/heartbeatfails.txt >/tmp/message
        echo -e "$MSG1 $MSG2 $MSG3" >>/tmp/message
        msmtp -t </tmp/message
;;
        onbatt-timer)
        logger -t upssched-cmd:  "onbatt-timer-expired"
        MSG1="\nUPS is on battery"
        MSG2="\nCurrent status: $CHMSG $1"
        cat /etc/nut/onbatt.txt >/tmp/message
        echo -e "$MSG1 $MSG2" >>/tmp/message
         msmtp -t </tmp/message
;;
        nocomm-timer)
        logger -t upssched-cmd:  "nocomm-timer-expired"
        if [[ -f $FILE2 ]];
         then
        echo
        else
        touch $FILE2
        msmtp -t dan.grostick at outlook.com </etc/nut/nocomm.txt
        fi
;;
        *)
        logger -t upssched-cmd:  "Unknown command: $1"   
        MSG1="\nUnknown command: $1"
        cat /etc/nut/unknowncommand.txt >/tmp/message
        echo -e "$MSG1" >>/tmp/message
        msmtp -t </tmp/message
;;
esac
exit 0

        ########### /etc/hosts.allow ###########

        ########### ps -eLf ###########
root      1329     1  1329  0    1 13:41 ?        00:00:00 /usr/sbin/upsd -F
root      1333     1  1333  0    1 13:41 ?        00:00:00 /usr/sbin/upsmon -F
root      1335  1333  1335  0    1 13:41 ?        00:00:00 /usr/sbin/upsmon -F
root      1484     1  1484 99    1 13:46 ?        00:06:31 /usr/sbin/upssched onbatt

        ########### Ownership and permissions of executables ###########
-rwxr-xr-x 1 root root 333348 Jun 14 10:33 /usr/sbin//upsd*
-rwxr-xr-x 1 root root 163600 Jun 14 10:33 /usr/sbin//upsdrvctl*
-rwxr-xr-x 1 root root   6466 Jun 14 10:33 /usr/sbin//upsdrvsvcctl*
-rwxr-xr-x 1 root root 182636 Jun 14 10:33 /usr/sbin//upsmon*
-rwxr-xr-x 1 root root 133088 Jun 14 10:33 /usr/sbin//upssched*

        ########### Ownership and permissions of configuration files ###########
-rw-r--r-- 1 root root 15269 Jun  7 15:55 /etc/nut//\
-rw-r--r-- 1 root root   136 Jun 12 20:15 /etc/nut//commbad.txt
-rw-r--r-- 1 root root   141 Jun 12 20:16 /etc/nut//commok.txt
-rw-r--r-- 1 root root   123 Jun 12 20:17 /etc/nut//fsd.txt
-rw-r--r-- 1 root root    50 Jun  7 12:52 /etc/nut//heartbeat.conf
-rw-r--r-- 1 root root   121 Jun 12 20:12 /etc/nut//heartbeatfails.txt
-rwxr-xr-x 1 root root    86 Jun 11 20:48 /etc/nut//hosts.conf*
-rw-r--r-- 1 root root   131 Jun 14 09:35 /etc/nut//lowbatt.txt
-rw-r--r-- 1 root root   135 Jun 12 20:18 /etc/nut//nocomm.txt
-rw-r--r-- 1 root root   129 Jun 12 20:18 /etc/nut//noparent.txt
-rw-r--r-- 1 root root    17 Jun 14 20:47 /etc/nut//nut.conf
-rw-r--r-- 1 root root   125 Jun 12 20:19 /etc/nut//onbatt.txt
-rw-r--r-- 1 root root   101 Jun 12 20:13 /etc/nut//online.txt
-rw-r--r-- 1 root root   166 Jun 12 20:19 /etc/nut//replacebatt.txt
-rw-r--r-- 1 root root   121 Jun 12 20:13 /etc/nut//shutdown.txt
-rw-r--r-- 1 root root   229 Jun 16 13:24 /etc/nut//start
-rw-r--r-- 1 root root   328 Jun  7 12:52 /etc/nut//stop
-rw-r--r-- 1 root root   103 Jun 12 20:13 /etc/nut//unknowncommand.txt
-rwxr-xr-x 1 root root   207 Jun 14 20:43 /etc/nut//ups.conf*
-rwxr-xr-x 1 root root    28 Jun 12 14:26 /etc/nut//upsd.conf*
-rwx------ 1 root root   309 Jun 13 13:33 /etc/nut//upsd.users*
-rwxr-xr-x 1 root root   995 Jun 14 09:54 /etc/nut//upsmon.conf*
-rwxr-xr-x 1 root root  2829 Jun 14 14:51 /etc/nut//upssched-cmd*
-rwxr-xr-x 1 root root  1058 Jun 15 17:37 /etc/nut//upssched.conf*

        ########### Custom NOTIFYCMD scheduler /usr/sbin/upssched ###########
Custom NOTIFYCMD scheduler /usr/sbin/upssched is not a script

        ########### nut-journal ###########

        Current boot
Jun 16 13:41:01 Raspberry-Pi-3 nut-server[1329]: fopen /var/state/ups/upsd.pid: No such file or directory
Jun 16 13:41:01 Raspberry-Pi-3 nut-server[1329]: Could not find PID file '/var/state/ups/upsd.pid' to see if previous upsd instance is already running!
Jun 16 13:41:01 Raspberry-Pi-3 nut-server[1329]: /etc/nut/upsd.conf is world readable
Jun 16 13:41:01 Raspberry-Pi-3 upsd[1329]: /etc/nut/upsd.conf is world readable
Jun 16 13:41:01 Raspberry-Pi-3 upsd[1329]: listening on 192.168.123.49 port 3493
Jun 16 13:41:01 Raspberry-Pi-3 upsd[1329]: Connected to UPS [heartbeat]: dummy-ups-heartbeat
Jun 16 13:41:01 Raspberry-Pi-3 upsd[1329]: Connected to UPS [ups]: usbhid-ups-ups
Jun 16 13:41:01 Raspberry-Pi-3 upsd[1329]: Found 2 UPS defined in ups.conf
Jun 16 13:41:05 Raspberry-Pi-3 nut-monitor[1333]: fopen /run/upsmon.pid: No such file or directory
Jun 16 13:41:05 Raspberry-Pi-3 nut-monitor[1333]: Could not find PID file to see if previous upsmon instance is already running!
Jun 16 13:41:08 Raspberry-Pi-3 upsd[1329]: Running as foreground process, not saving a PID file
Jun 16 13:41:08 Raspberry-Pi-3 nut-server[1329]: User upsmonitor at 192.168.123.49 logged into UPS [ups]
Jun 16 13:41:08 Raspberry-Pi-3 upsd[1329]: User upsmonitor at 192.168.123.49 logged into UPS [ups]
Jun 16 13:41:08 Raspberry-Pi-3 upsd[1329]: User heartbeat at 192.168.123.49 logged into UPS [heartbeat]
Jun 16 13:46:03 Raspberry-Pi-3 nut-monitor[1479]: Network UPS Tools upsmon 2.8.0.1
Jun 16 13:51:03 Raspberry-Pi-3 nut-monitor[1597]: Network UPS Tools upsmon 2.8.0.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: heartbeat onbatt.jpg
Type: image/jpeg
Size: 10040 bytes
Desc: heartbeat onbatt.jpg
URL: <http://alioth-lists.debian.net/pipermail/nut-upsuser/attachments/20230616/842fcb53/attachment-0001.jpg>


More information about the Nut-upsuser mailing list