wyattanderson.com

Hey there. I'm Wyatt Anderson. Not the construction company owner, or biology professor, or the singer, but the software engineer. I'll post some stuff on here from time to time, but you're more likely to hear from me on Twitter or something. Feel free to get in touch.

Prowl notifications with apcupsd

I use Prowl to deliver push notifications to my iPhone for various things like sabnzbd completions and, now, apcupsd notifications. It’s relatively easy to accomplish with a simple script to fire notifications at the Prowl service:

#!/bin/bash
curl -s \
     -d apikey=YOUR_API_KEY_HERE \
     -d priority="$1" \
     -d application=apcupsd \
     -d event="$2" \
     -d description="$3" \
     https://api.prowlapp.com/publicapi/add

Replace YOUR_API_KEY_HERE with your Prowl API key, drop the script in /etc/apcupsd and then add relevant lines to your /etc/apcupsd/apccontrol script:

PROWL="$SCRIPTDIR/prowl_notify.ssh"

...

case "$1" in
    onbattery)
        ${PROWL} 1 "apcupsd" "Power failure on UPS ${2}. Running on batteries."
        ...
    runlimit)
        ${PROWL} 2 "apcupsd" "Battery power exhausted. Shutting down."
        ...
esac

The number in the script commandline is the priority of the alert: 2 is for emergencies and bypasses my Prowl silent mode, as I found out when my UPS ran out of battery power this weekend.