Made requested adjustments and fixes.
manosf committed
Feb 26, 2018 at 01:24 UTC
b8945601e3a606033011becbbc9f6377a89eb07a
2 files changed
+15
-17
conf.d/health_alarm_notify.conf
+1
-1
@@ -408,7 +408,7 @@ DEFAULT_RECIPIENT_PD=""
408
# "<irc_channel_1> <irc_channel_2> ..."
409
410
# enable/disable sending irc notifications
411
-SEND_PD="YES"
411
+SEND_IRC="YES"
412
413
# if a role's recipients are not configured, a notification will not be sent.
414
# (empty = do not send a notification for unconfigured roles):
plugins.d/alarm-notify.sh
+14
-16
@@ -1472,16 +1472,16 @@ EOF
1472
1473
send_irc() {
1474
local NICKNAME="${1}" REALNAME="${2}" CHANNELS="${3}" NETWORK="${4}" MESSAGE="${5}" sent=0 channel color send_alarm reply_codes error
1475
-
1476
- case "${status}" in
1477
- WARNING) color="warning" ;;
1478
- CRITICAL) color="danger" ;;
1479
- CLEAR) color="good" ;;
1480
- *) color="#777777" ;;
1481
- esac
1482
-
1483
- if ["${SEND_IRC}" = "YES" -a ! -z "${nickname}" -a ! -z "${realname}" -a ! -z "${channels}" -a ! -z "${network}" -a ! -z "${servername}"]
1475
+
1476
+ if [ "${SEND_IRC}" = "YES" -a ! -z "${nickname}" -a ! -z "${realname}" -a ! -z "${channels}" -a ! -z "${network}" -a ! -z "${servername}" ]
1477
then
1478
+ case "${status}" in
1479
+ WARNING) color="warning" ;;
1480
+ CRITICAL) color="danger" ;;
1481
+ CLEAR) color="good" ;;
1482
+ *) color="#777777" ;;
1483
+ esac
1484
+
1485
for channel in ${CHANNELS}
1486
do
1487
error=0
@@ -1489,17 +1489,15 @@ send_irc() {
1489
reply_codes=$(echo ${send_alarm} | cut -d ' ' -f 2 | grep -o '[0-9]*')
1490
for code in ${reply_codes}
1491
do
1492
- if [ "${code}" -ge 400 -a "${code}" -le 599 ]
1493
- then
1494
- error "failed to send irc notification for: ${host} ${chart}.${name} is ${status} to '${channel}', with error code ${code}."
1495
- error=1
1496
- fi
1492
+ [ "${code}" -ge 400 -a "${code}" -le 599 ] && error=1 && break
1493
done
1498
-
1499
- if [ ${error} -eq 0 ]
1494
+
1495
+ if [ "${error}" -eq 0 ]
1496
then
1497
info "sent irc notification for: ${host} ${chart}.${name} is ${status} to '${channel}'"
1498
sent=$((sent + 1))
1499
+ else
1500
+ error "failed to send irc notification for: ${host} ${chart}.${name} is ${status} to '${channel}', with error code ${code}."
1501
fi
1502
done
1503
fi