@cryptotaxi247 / netdata-1 / commits / b7c45c9d9

alarm(irc): add support to change IRC_PORT (#10824)

* alarm(irc): add support to change IRC_PORT

Ryan Lahfa committed Mar 26, 2021 at 13:45 UTC b7c45c9d988402b41024245c1a3ef553798ff912
2 files changed +9 -4
health/notifications/alarm-notify.sh.in
+5 -4
@@ -375,6 +375,7 @@ EMAIL_PLAINTEXT_ONLY=
375 IRC_NICKNAME=
376 IRC_REALNAME=
377 IRC_NETWORK=
378 +IRC_PORT=6667
379
380 # hangouts configs
381 declare -A HANGOUTS_WEBHOOK_URI
@@ -1744,9 +1745,9 @@ send_prowl() {
1745 # irc sender
1746
1747 send_irc() {
1747 - local NICKNAME="${1}" REALNAME="${2}" CHANNELS="${3}" NETWORK="${4}" SERVERNAME="${5}" MESSAGE="${6}" sent=0 channel color send_alarm reply_codes error
1748 + local NICKNAME="${1}" REALNAME="${2}" CHANNELS="${3}" NETWORK="${4}" PORT="${5}" SERVERNAME="${6}" MESSAGE="${7}" sent=0 channel color send_alarm reply_codes error
1749
1749 - if [ "${SEND_IRC}" = "YES" ] && [ -n "${NICKNAME}" ] && [ -n "${REALNAME}" ] && [ -n "${CHANNELS}" ] && [ -n "${NETWORK}" ] && [ -n "${SERVERNAME}" ]; then
1750 + if [ "${SEND_IRC}" = "YES" ] && [ -n "${NICKNAME}" ] && [ -n "${REALNAME}" ] && [ -n "${CHANNELS}" ] && [ -n "${NETWORK}" ] && [ -n "${SERVERNAME}" ] && [ -n "${PORT}" ]; then
1751 case "${status}" in
1752 WARNING) color="warning" ;;
1753 CRITICAL) color="danger" ;;
@@ -1757,7 +1758,7 @@ send_irc() {
1758 SNDMESSAGE="${MESSAGE//$'\n'/", "}"
1759 for CHANNEL in ${CHANNELS}; do
1760 error=0
1760 - send_alarm=$(echo -e "USER ${NICKNAME} guest ${REALNAME} ${SERVERNAME}\\nNICK ${NICKNAME}\\nJOIN ${CHANNEL}\\nPRIVMSG ${CHANNEL} :${SNDMESSAGE}\\nQUIT\\n" \ | nc "${NETWORK}" 6667)
1761 + send_alarm=$(echo -e "USER ${NICKNAME} guest ${REALNAME} ${SERVERNAME}\\nNICK ${NICKNAME}\\nJOIN ${CHANNEL}\\nPRIVMSG ${CHANNEL} :${SNDMESSAGE}\\nQUIT\\n" \ | nc "${NETWORK}" "${PORT}")
1762 reply_codes=$(echo "${send_alarm}" | cut -d ' ' -f 2 | grep -o '[0-9]*')
1763 for code in ${reply_codes}; do
1764 if [ "${code}" -ge 400 ] && [ "${code}" -le 599 ]; then
@@ -2487,7 +2488,7 @@ SENT_PROWL=$?
2488 # -----------------------------------------------------------------------------
2489 # send the irc message
2490
2490 -send_irc "${IRC_NICKNAME}" "${IRC_REALNAME}" "${to_irc}" "${IRC_NETWORK}" "${host}" "${host} ${status_message} - ${name//_/ } - ${chart} ----- ${alarm}
2491 +send_irc "${IRC_NICKNAME}" "${IRC_REALNAME}" "${to_irc}" "${IRC_NETWORK}" "${IRC_PORT}" "${host}" "${host} ${status_message} - ${name//_/ } - ${chart} ----- ${alarm}
2492 Severity: ${severity}
2493 Chart: ${chart}
2494 Family: ${family}
health/notifications/health_alarm_notify.conf
+4
@@ -676,6 +676,10 @@ DEFAULT_RECIPIENT_IRC=""
676 # e.g. "irc.freenode.net"
677 IRC_NETWORK=""
678
679 +# The irc port to which a connection will occur.
680 +# e.g. 6667 (the default one), 6697 (a TLS/SSL one)
681 +IRC_PORT=6667
682 +
683 # The irc nickname which is required to send the notification. It must not be
684 # an already registered name as the connection's MODE is defined as a 'guest'.
685 IRC_NICKNAME=""