Skip to main content
The NUT (Network UPS Tools) upsmon daemon can run the script set by NOTIFYCMD when a UPS changes state: the environment variable NOTIFYTYPE holds the event type (ONBATT, ONLINE, COMMBAD and so on), UPSNAME holds the UPS name, and the notification text is passed as the last argument. NUT has no native webhook, so a short script pushes these events to Flashduty in the Standard Alert Event format: ONBATT triggers an alert and ONLINE recovers it.

In Flashduty On-call


Get an integration push URL in either of the two ways below. Choose the Standard Alert Event integration type in both, not NUT.

Use a dedicated integration

  1. In the Flashduty console, go to Channels and open a channel
  2. Go to Settings → Integrations → Dedicated integrations and click Add an integration
  3. Select Standard Alert Event and click Save
  4. Open the generated integration card and copy the Push URL, in the form https://api.flashcat.cloud/event/push/alert/standard?integration_key=<integration key>

Use a shared integration

  1. In the Flashduty console, go to Integration Center → Alert Events
  2. Select Standard Alert Event and enter an integration name
  3. Configure the default route and select a channel; you can add more rules under Routes after creation
  4. Click Save and copy the generated Push URL

Configure in NUT


Step 1: Create the notification script

On the host that runs upsmon, create a script such as /usr/local/bin/nut-flashduty.sh, replace URL with the push URL copied above, and make it executable (chmod +x). The host needs curl.
The script only handles the event types in the table below and ignores every other type.

Step 2: Enable the script in upsmon.conf

Edit upsmon.conf, set the notification script, and add the EXEC flag for every event type you want to push (NOTIFYCMD only runs for events that have EXEC set):
The first value of NOTIFYCMD is interpreted as the full path of the script, quoted if the path contains spaces (NUT 2.8.5 and older releases parsed it differently; see the NUT documentation for upsmon.conf). To also push ALARM, OVER or BYPASS, add a NOTIFYFLAG line for each of them and for their recovery types (NOTALARM, NOTOVER, NOTBYPASS) in the same way. Then have upsmon re-read its configuration:
upsmon runs NOTIFYCMD in the background, so several instances can run at once when many events happen together; the script above sends exactly one request per call and is safe to run in parallel. Shutdown-related event types (FSD, SHUTDOWN and so on) are outside the script’s scope and it exits when it receives them.

Step 3: Verify

Run the script by hand on the host, first a trigger and then a recovery:
In Flashduty you should first see the alert UPS ups@localhost: on battery and then see it recover.

Recovery and deduplication


  • ONBATT, LOWBATT and ONLINE share the Alert Key nut:<UPS name>:power: ONBATT triggers the alert, a following LOWBATT raises it to Critical, and ONLINE recovers it
  • COMMBAD, NOCOMM and COMMOK share comm; ALARM and NOTALARM, OVER and NOTOVER, and BYPASS and NOTBYPASS are also paired
  • REPLBATT has no matching recovery event. After replacing the battery, close the alert manually in Flashduty, or enable the auto-resolve timeout on the channel, starting with 7 days
  • Alerts of several UPS units do not affect each other: the Alert Key contains UPSNAME

Troubleshooting


  • No alert arrives: confirm the NOTIFYFLAG of the event type in upsmon.conf includes EXEC and that upsmon -c reload was run
  • The script works by hand but no alert arrives when upsmon triggers it: NOTIFYCMD must be the full path of the script and the user upsmon runs as must be able to execute it; curl -fsS prints failures to stderr, which upsmon may not record, so run the script by hand to see them
  • The alert does not recover: confirm recovery types such as ONLINE also have EXEC set
  • Flashduty returns a parameter error: confirm URL is the full push URL, including integration_key
For more details, see the NUT documentation upsmon.conf and upsmon.