Suppresed unnecessary and repetitive non-error messages.
manosf committed
Feb 25, 2018 at 22:17 UTC
65e2dddfa554e36c26aa23127512fa61c442d8cd
1 file changed
+9
-4
plugins.d/alarm-notify.sh
+9
-4
@@ -1471,7 +1471,7 @@ EOF
1471
# irc sender
1472
1473
send_irc() {
1474
- local NICKNAME="${1}" REALNAME="${2}" CHANNELS="${3}" NETWORK="${4}" MESSAGE="${5}" sent=0 channel color send_alarm reply_codes
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" ;;
@@ -1484,18 +1484,23 @@ send_irc() {
1484
then
1485
for channel in ${CHANNELS}
1486
do
1487
+ error=0
1488
send_alarm=$(echo -e "USER ${NICKNAME} guest ${REALNAME} ${SERVERNAME}\nNICK ${NICKNAME}\nJOIN ${CHANNEL}\nPRIVMSG ${CHANNEL}> :${MESSAGE}\nQUIT\n" \ | nc ${NETWORK} 6667)
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
1493
- info "sent irc notification for: ${host} ${chart}.${name} is ${status} to '${channel}'"
1494
- sent=$((sent + 1))
1495
- else
1494
error "failed to send irc notification for: ${host} ${chart}.${name} is ${status} to '${channel}', with error code ${code}."
1495
+ error=1
1496
fi
1497
done
1498
+
1499
+ if [ ${error} -eq 0 ]
1500
+ then
1501
+ info "sent irc notification for: ${host} ${chart}.${name} is ${status} to '${channel}'"
1502
+ sent=$((sent + 1))
1503
+ fi
1504
done
1505
fi
1506