User Tools

Site Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:public:apcupsd-notifications [2018/07/25 22:11] (current)
robertguerra created
Line 1: Line 1:
 +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
 +
 +4. 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