Battery Status (apcupsd) Notification

This example uses the feature create_notification to send an error message with the Battery (apcupsd) status.

  1. Edit the /etc/apcupsd/changeme file so it is as follows:

    #!/bin/sh
    MSG="$HOSTNAME UPS battery needs changing NOW. \n \n $(apcaccess status)"
    /usr/bin/create_notification -s error β€œ${MSG}”
    /usr/bin/notifier
    exit 0

  2. Edit the /etc/apcupsd/commfailure file so it is as follows:

    #!/bin/sh
    MSG="$HOSTNAME Communications with UPS lost. \n \n $(apcaccess status)"
    /usr/bin/create_notification -s error β€œ${MSG}”
    /usr/bin/notifier
    exit 0

  3. Edit the /etc/apcupsd/commok file so it is as follows:

    #!/bin/sh
    message="$(echo -e β€œ${common_name} Communications with UPS restored. \n \n $(apcaccess status)”
    /usr/bin/create_notification -s error β€œ${message}”
    /usr/bin/notifier
    exit 0

  4. Edit the /etc/apcupsd/offbattery file so it is as follows:

    #!/bin/sh
    MSG="$HOSTNAME Communications with UPS restored. \n \n $(apcaccess status)"
    /usr/bin/create_notification -s error β€œ${MSG}”
    /usr/bin/notifier
    exit 0

  5. Edit the /etc/apcupsd/onbattery file so it is as follows:

    #!/bin/sh
    MSG="$HOSTNAME Power Failure!!! \n \n $(apcaccess status)"
    /usr/bin/create_notification -s error β€œ${MSG}”
    /usr/bin/notifier
    exit 0

Hello,

thank you! Would you please create article in community documentation?

done - it’s available here - https://doc.turris.cz/doc/en/public/apcupsd-notifications

1 Like