Skip to content

NUT "NOTIFYCMD" not working as expcted within Docker container #305

Description

@CRFSlick

The nut-upsd container (https://hub.docker.com/r/instantlinux/nut-upsd/) seems to support enabling notifications for UPS events (ONBATT, LOWBATT, SHUTDOWN, etc.) through the NOTIFYCMD environment variable. But I couldn't get it working. Here is a short version of my docker compose file.

services:

  nut:
    container_name: 'nut'
    image: instantlinux/nut-upsd
    volumes:
      - '/mnt/nut/data/bin/notify:/usr/local/bin/notify'
    (...)
    environment:
      SERIAL: '***********'
      API_USER: 'admin'
      INSTCMDS: 'all'
      DESCRIPTION: 'ups'
      NUT_DEBUG_LEVEL: 1
      NOTIFYCMD: '/usr/local/bin/notify'
      USER: 'root'
      NUT_QUIET_INIT_SSL: false
      NUT_QUIET_INIT_UPSNOTIFY: false
(...)

The notification script is mounted, executable, and accessible from within the container.

root@debian # docker exec -it nut /bin/sh
~ # tail -n 1 /etc/nut/upsmon.conf
NOTIFYCMD "/usr/local/bin/notify"
~ # ls -l "/usr/local/bin/notify"
-rwxr-xr-x    1 root     root           169 Sep  1 23:39 /usr/local/bin/notify

Running the script directly (from within the container) works as expected. But when the UPS changes state, such as when wall power is disconnected, no notification is sent.

...
nut  |    0.000682	[D1] NUT_QUIET_INIT_SSL='false' value was not recognized, ignored
nut  |    0.000781	Init SSL without certificate database
nut  |    0.001395	[D1] NUT_QUIET_INIT_UPSNOTIFY='false' value was not recognized, ignored
nut  |    0.001407	upsnotify: failed to notify about state NOTIFY_STATE_READY_WITH_PID: no notification tech defined, will not spam more about it
nut  |    0.001412	[D1] Trying to connect to UPS [ups@localhost]
nut  |    0.001758	[D1] Logged into UPS ups@localhost
nut  |    0.001908	UPS ups@localhost: has at least one unclassified status token: [WAIT]
nut  |    5.002429	UPS ups@localhost has no unclassified status tokens anymore
nut  |   65.007489	UPS ups@localhost on battery
nut  |   75.008754	UPS ups@localhost on line power

From what I gather, the upsmon.conf configuration file is missing the NOTIFYFLAG directives which tell the software when it should send notifications and how. These seem to be commented out.

/etc/nut # grep 'NOTIFYFLAG' upsmon.conf
# NOTIFYFLAG.  See NOTIFYFLAG below for more details.
# NOTIFYFLAG - change behavior of upsmon when NOTIFY events occur
# NOTIFYFLAG <notify type> <flag>[+<flag>][+<flag>] ...
# NOTIFYFLAG ONLINE	SYSLOG+WALL
# NOTIFYFLAG ONBATT	SYSLOG+WALL
# NOTIFYFLAG LOWBATT	SYSLOG+WALL
# NOTIFYFLAG FSD	SYSLOG+WALL
# NOTIFYFLAG COMMOK	SYSLOG+WALL
# NOTIFYFLAG COMMBAD	SYSLOG+WALL
# NOTIFYFLAG SHUTDOWN	SYSLOG+WALL
# NOTIFYFLAG REPLBATT	SYSLOG+WALL
# NOTIFYFLAG NOCOMM	SYSLOG+WALL
# NOTIFYFLAG NOPARENT	SYSLOG+WALL
# NOTIFYFLAG CAL	SYSLOG+WALL
# NOTIFYFLAG NOTCAL	SYSLOG+WALL
# NOTIFYFLAG OFF	SYSLOG+WALL
# NOTIFYFLAG NOTOFF	SYSLOG+WALL
# NOTIFYFLAG BYPASS	SYSLOG+WALL
# NOTIFYFLAG NOTBYPASS	SYSLOG+WALL
# NOTIFYFLAG ECO	SYSLOG+WALL
# NOTIFYFLAG NOTECO	SYSLOG+WALL
# NOTIFYFLAG ALARM	SYSLOG+WALL
# NOTIFYFLAG NOTALARM	SYSLOG+WALL
# NOTIFYFLAG OTHER	SYSLOG+WALL
# NOTIFYFLAG NOTOTHER	SYSLOG+WALL
# NOTIFYFLAG SUSPEND_STARTING	SYSLOG+WALL
# NOTIFYFLAG SUSPEND_FINISHED	SYSLOG+WALL

I would expect to see something more like the following with the EXEC flag set...

NOTIFYFLAG ONLINE     SYSLOG+EXEC
NOTIFYFLAG ONBATT     SYSLOG+EXEC
NOTIFYFLAG LOWBATT    SYSLOG+EXEC
...

... but maybe I'm just missing something? Do notifications work on your end?

Thank you!

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions