Fixed IRC notifications proper checking.
manosf committed
Feb 23, 2018 at 19:15 UTC
a16297849bde5e33bff6d2009fe5ad951c068c91
1 file changed
+7
-7
plugins.d/alarm-notify.sh
+7
-7
@@ -683,7 +683,7 @@ if [ \( \
683
-o "${SEND_KAFKA}" = "YES" \
684
-o "${SEND_CUSTOM}" = "YES" \
685
-o "${SEND_IRC}" = "YES" \
686
- \) -a -z "${curl}" ]
686
+ \) -a -z "${curl}" ]
687
then
688
curl="$(which curl 2>/dev/null || command -v curl 2>/dev/null)"
689
if [ -z "${curl}" ]
@@ -1482,17 +1482,17 @@ send_irc() {
1482
*) color="#777777" ;;
1483
esac
1484
1485
- if ["${SEND_IRC}" = "YES" -a ! -z "${nickname}" -a ! -z "${realname}" -a ! -z "${channels}" -a ! -z "${network}"]
1485
+ if ["${SEND_IRC}" = "YES" -a ! -z "${nickname}" -a ! -z "${realname}" -a ! -z "${channels}" -a ! -z "${network}" -a ! -z "${servername}"]
1486
then
1487
for channel in ${CHANNELS}
1488
do
1489
- httpcode=$(echo -e "USER ${NICKNAME} guest ${REALNAME}\nNICK ${NICKNAME}\nJOIN ${CHANNEL}\nPRIVMSG ${CHANNEL}> :${MESSAGE}\nQUIT\n" \| nc ${NETWORK} 6667)
1490
- if [ "${httpcode}" = "200" ]
1489
+ sentcheck=$(echo -e "USER ${NICKNAME} guest ${REALNAME} ${SERVERNAME}\nNICK ${NICKNAME}\nJOIN ${CHANNEL}\nPRIVMSG ${CHANNEL}> :${MESSAGE}\nQUIT\n" \ | nc ${NETWORK} 6667)
1490
+ if [ $(echo ${sentcheck} | grep --fixed-strings --count ":${nickname} MODE ${nickname} :+i") -gt 0 ]
1491
then
1492
- info "sent flock notification for: ${host} ${chart}.${name} is ${status} to '${channel}'"
1492
+ info "sent irc notification for: ${host} ${chart}.${name} is ${status} to '${channel}'"
1493
sent=$((sent + 1))
1494
else
1495
- error "failed to send flock notification for: ${host} ${chart}.${name} is ${status} to '${channel}', with HTTP error code ${httpcode}."
1495
+ error "failed to send irc notification for: ${host} ${chart}.${name} is ${status} to '${channel}', with HTTP error code ${httpcode}."
1496
fi
1497
done
1498
fi
@@ -1719,7 +1719,7 @@ SENT_PD=$?
1719
# -----------------------------------------------------------------------------
1720
# send the irc message
1721
1722
-send_irc "${IRC_NICKNAME}" "${IRC_REALNAME}" "${to_irc}" "${DEFAULT_IRC_NETWORK}" "${host} ${status_message} - ${name//_/ } - ${chart} ----- ${alarm}
1722
+send_irc "${IRC_NICKNAME}" "${IRC_REALNAME}" "${to_irc}" "${DEFAULT_IRC_NETWORK}" "${host}" "${host} ${status_message} - ${name//_/ } - ${chart} ----- ${alarm}
1723
Severity: ${severity}
1724
Chart: ${chart}
1725
Family: ${family}