Skip to content

Commit

Permalink
Fix: alerts: ensure sample alert agents handle undefined recipient
Browse files Browse the repository at this point in the history
  • Loading branch information
kgaillot committed Jun 17, 2016
1 parent ba315f1 commit a895923
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
13 changes: 12 additions & 1 deletion extra/alerts/alert_file.sh.sample
Expand Up @@ -33,8 +33,19 @@
# </alerts>
# </configuration>

# No one will probably ever see this echo, unless they run the script manually.
# An alternative would be to log to the system log, or similar. (We can't send
# this to the configured recipient, because that variable won't be defined in
# this case either.)
if [ -z $CRM_alert_version ]; then
echo "Pacemaker version 1.1.15 or later is required" >> "${CRM_alert_recipient}"
echo "$0 must be run by Pacemaker version 1.1.15 or later"
exit 0
fi

# Alert agents must always handle the case where no recipients are defined,
# even if it's a no-op (a recipient might be added to the configuration later).
if [ -z "${CRM_alert_recipient}" ]; then
echo "$0 requires a recipient configured with a full filename path"
exit 0
fi

Expand Down
7 changes: 6 additions & 1 deletion extra/alerts/alert_snmp.sh.sample
Expand Up @@ -43,7 +43,12 @@
# ================================

if [ -z "$CRM_alert_version" ]; then
echo "Pacemaker version 1.1.15 or later is required"
echo "$0 must be run by Pacemaker version 1.1.15 or later"
exit 0
fi

if [ -z "$CRM_alert_recipient" ]; then
echo "$0 requires a recipient configured with the SNMP server IP address"
exit 0
fi

Expand Down

0 comments on commit a895923

Please sign in to comment.