NUT UPS push notifications
NUT's upsmon can send UPS alerts to your phone through PushPiper, free for 10,000 messages a month on 10 devices. Setup takes one POSIX shell script and a few lines in upsmon.conf, and each alert carries up to 1,024 characters, so power events arrive as push notifications.
How upsmon triggers alert commands
Network UPS Tools uses the upsmon daemon to watch power states and shut down systems cleanly when batteries run dry. While upsmon can write to syslog or broadcast to open terminal terminals via wall, it also supports executing external scripts through the NOTIFYCMD directive. This lets you route hardware events to remote notification services without running heavyweight background daemons.
When an event occurs, upsmon inspects the flags assigned to that event type. If the flag includes EXEC, upsmon calls your custom command and passes the human-readable notification text as the last command-line argument. In addition to that argument, upsmon sets environment variables for the execution environment:
NOTIFYTYPE: The specific event identifier, such asONBATT,ONLINE, orLOWBATT.UPSNAME: The name of the reporting UPS as configured in your NUT system files.
A single curl request to the PushPiper API sends the message and environment variables straight to your devices.
Creating the notification script
Your notification script inspects the incoming event, picks an appropriate sound and urgency level, and sends the payload to PushPiper. You can write it using standard POSIX shell commands and curl.
- Create a new script file at
/usr/local/bin/ups-pushpiper.sh. - Paste the tested script below into the file.
- Make the file executable so
upsmoncan run it:chmod +x /usr/local/bin/ups-pushpiper.sh.
#!/bin/sh
case "$NOTIFYTYPE" in
ONBATT|LOWBATT|FSD|COMMBAD|NOCOMM) priority=1; sound=siren ;;
*) priority=0; sound=pushover ;;
esac
curl -s -o /dev/null https://api.pushpiper.com/1/messages.json \
--form-string "token=APP_TOKEN" \
--form-string "user=USER_KEY" \
--form-string "title=UPS ${UPSNAME:-ups}: ${NOTIFYTYPE:-event}" \
--form-string "message=$1" \
--form-string "priority=$priority" \
--form-string "sound=$sound"Before saving, you need to replace two placeholders in the script:
APP_TOKEN: Replace this with your 30-character application token (starts witha).USER_KEY: Replace this with your 30-character user key (starts withu), or a comma-separated list of up to 50 user keys.
You can grab both values from the PushPiper web app after signing in with Google. The script uses PushPiper's Pushover-compatible endpoint, which means you can pass standard parameters like sound, priority, and title. If you already have existing scripts that target Pushover, you can see how they map over in our guide on how PushPiper compares with Pushover. For more complex command-line pipelines, check our shell script notifications guide.
Mapping NUT event types to priorities
Not every UPS event demands waking you up in the middle of the night. A battery replacement warning needs attention by tomorrow, but an actual utility outage or a lost communication link requires an immediate alert.
The table below compares the event types sent by upsmon, what each condition represents, and how the script assigns notification priority.
| NOTIFYTYPE | Meaning | Priority in the script |
|---|---|---|
| ONBATT | Running on battery | 1 |
| LOWBATT | Battery is low | 1 |
| FSD | Forced shutdown | 1 |
| COMMBAD or NOCOMM | Lost contact with the UPS | 1 |
| ONLINE | Power is back | 0 |
| REPLBATT | Battery needs replacing | 0 |
The script sorts events into two categories:
- Priority 1 (High): Used for
ONBATT,LOWBATT,FSD(forced shutdown), and lost communication (COMMBADorNOCOMM). These messages bypass PushPiper's quiet hours and play the loudsirensound on your device. - Priority 0 (Normal): Used for recovery events like
ONLINEand maintenance flags likeREPLBATT. These messages play the defaultpushoversound and respect your device's quiet hours.
PushPiper also supports emergency alerts at priority 2, which repeat on an interval until acknowledged. However, priority 2 requires setting retry (at least 30 seconds) and expire (up to 10,800 seconds). For standard homelab and server monitoring, high priority 1 delivers immediate sound and screen alerts without repeating until someone acknowledges the notification.
Configuring upsmon.conf and reloading
Once the script is in place, you must instruct upsmon to execute it for your chosen events. Open your upsmon.conf file and register the script using NOTIFYCMD.
Add the configuration lines below to tell upsmon to pass power changes to the executable.
NOTIFYCMD /usr/local/bin/ups-pushpiper.sh
NOTIFYFLAG ONBATT SYSLOG+WALL+EXEC
NOTIFYFLAG ONLINE SYSLOG+WALL+EXEC
NOTIFYFLAG LOWBATT SYSLOG+WALL+EXEC
NOTIFYFLAG COMMBAD SYSLOG+WALL+EXEC
NOTIFYFLAG COMMOK SYSLOG+WALL+EXEC
NOTIFYFLAG REPLBATT SYSLOG+WALL+EXECEach NOTIFYFLAG line assigns three actions separated by plus signs:
SYSLOG: Writes the event to the local system log.WALL: Broadcasts the alert to all logged-in terminals using the systemwallcommand.EXEC: Executes the command specified inNOTIFYCMD.
Without the EXEC flag, upsmon skips calling your script entirely. Once you save your changes to upsmon.conf, instruct the running daemon to load the new settings:
upsmon -c reloadThis reloads the configuration cleanly without dropping your UPS connection or interrupting active monitoring.
Power routing and testing your setup
A power outage notification is useless if your infrastructure drops offline before the message hits the internet. Because the notification script fires the moment line power fails, your local network path must stay powered long enough for curl to reach PushPiper's servers.
If your network gear runs on utility power, it will die the instant power drops, leaving the machine unable to resolve DNS or transmit the HTTPS request. Read our power outage alert guide for more details on planning battery runtimes across network equipment.
To test your configuration:
- Unplug the UPS power cable from the wall outlet.
- Listen for the UPS beeper and check your phone for the high-priority alert with the siren sound.
- Plug the UPS back into the wall outlet after a few seconds.
- Check for the
ONLINErecovery notification, which should arrive at normal priority.
PushPiper notifications arrive through the browser using Web Push. On Android, Windows, macOS, and Linux, notifications work through Chrome, Edge, Firefox, or Safari. For iPhone and iPad running iOS 16.4 or later, open the PushPiper web app in Safari, tap Share, and select Add to Home Screen. PushPiper does not have a native app store download, does not send SMS text messages, and cannot bypass the native iOS Do Not Disturb switch.
If you need advanced payload options, full sound lists, or automated receipt polling, review the API reference.
Sources
Questions and answers
Does PushPiper wake an iPhone that is set to Do Not Disturb?
No. PushPiper uses Web Push notifications, and priority 1 alerts only bypass PushPiper's own quiet hours setting. Web Push alerts cannot break through Apple's native iOS Focus modes or Do Not Disturb settings.
Can upsmon send SMS alerts through PushPiper?
PushPiper does not send SMS text messages or make automated voice calls. Alerts are delivered as push notifications to your desktop browsers and mobile devices.
What happens if NUT triggers an alert while my monthly quota is exhausted?
When an account exceeds its monthly quota, the PushPiper API rejects incoming messages with HTTP status code 429. Free accounts include 10,000 messages a month, which reset on the 1st of each month at 00:00 UTC.
Why does the script use priority 1 instead of priority 2?
Priority 2 is an emergency alert that repeats every retry seconds (at least 30 seconds) until someone acknowledges it or it expires, and it requires both retry and expire parameters. Priority 1 sends an immediate, high-urgency alert with sound that bypasses app quiet hours without requiring manual acknowledgement loops.
Can I run NUT and PushPiper on a machine without internet access?
No, the script uses curl to send alerts directly to the PushPiper API over HTTPS. The machine running upsmon requires outbound internet access and functional DNS resolution to deliver notifications.