summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Lahfa <masterancpp@gmail.com>2021-03-26 13:45:04 +0100
committerGitHub <noreply@github.com>2021-03-26 12:45:04 +0000
commitb7c45c9d988402b41024245c1a3ef553798ff912 (patch)
treea2299eaff7a4305fa80bdb598bdf8a67ac11b154
parentba0992f3affcc57cd62343891455d8defa04530b (diff)
alarm(irc): add support to change IRC_PORT (#10824)
* alarm(irc): add support to change IRC_PORT
-rwxr-xr-xhealth/notifications/alarm-notify.sh.in9
-rwxr-xr-xhealth/notifications/health_alarm_notify.conf4
2 files changed, 9 insertions, 4 deletions
diff --git a/health/notifications/alarm-notify.sh.in b/health/notifications/alarm-notify.sh.in
index 7252a306e0..bf6c02816d 100755
--- a/health/notifications/alarm-notify.sh.in
+++ b/health/notifications/alarm-notify.sh.in
@@ -375,6 +375,7 @@ EMAIL_PLAINTEXT_ONLY=
IRC_NICKNAME=
IRC_REALNAME=
IRC_NETWORK=
+IRC_PORT=6667
# hangouts configs
declare -A HANGOUTS_WEBHOOK_URI
@@ -1744,9 +1745,9 @@ send_prowl() {
# irc sender
send_irc() {
- local NICKNAME="${1}" REALNAME="${2}" CHANNELS="${3}" NETWORK="${4}" SERVERNAME="${5}" MESSAGE="${6}" sent=0 channel color send_alarm reply_codes error
+ local NICKNAME="${1}" REALNAME="${2}" CHANNELS="${3}" NETWORK="${4}" PORT="${5}" SERVERNAME="${6}" MESSAGE="${7}" sent=0 channel color send_alarm reply_codes error
- if [ "${SEND_IRC}" = "YES" ] && [ -n "${NICKNAME}" ] && [ -n "${REALNAME}" ] && [ -n "${CHANNELS}" ] && [ -n "${NETWORK}" ] && [ -n "${SERVERNAME}" ]; then
+ if [ "${SEND_IRC}" = "YES" ] && [ -n "${NICKNAME}" ] && [ -n "${REALNAME}" ] && [ -n "${CHANNELS}" ] && [ -n "${NETWORK}" ] && [ -n "${SERVERNAME}" ] && [ -n "${PORT}" ]; then
case "${status}" in
WARNING) color="warning" ;;
CRITICAL) color="danger" ;;
@@ -1757,7 +1758,7 @@ send_irc() {
SNDMESSAGE="${MESSAGE//$'\n'/", "}"
for CHANNEL in ${CHANNELS}; do
error=0
- send_alarm=$(echo -e "USER ${NICKNAME} guest ${REALNAME} ${SERVERNAME}\\nNICK ${NICKNAME}\\nJOIN ${CHANNEL}\\nPRIVMSG ${CHANNEL} :${SNDMESSAGE}\\nQUIT\\n" \ | nc "${NETWORK}" 6667)
+ send_alarm=$(echo -e "USER ${NICKNAME} guest ${REALNAME} ${SERVERNAME}\\nNICK ${NICKNAME}\\nJOIN ${CHANNEL}\\nPRIVMSG ${CHANNEL} :${SNDMESSAGE}\\nQUIT\\n" \ | nc "${NETWORK}" "${PORT}")
reply_codes=$(echo "${send_alarm}" | cut -d ' ' -f 2 | grep -o '[0-9]*')
for code in ${reply_codes}; do
if [ "${code}" -ge 400 ] && [ "${code}" -le 599 ]; then
@@ -2487,7 +2488,7 @@ SENT_PROWL=$?
# -----------------------------------------------------------------------------
# send the irc message
-send_irc "${IRC_NICKNAME}" "${IRC_REALNAME}" "${to_irc}" "${IRC_NETWORK}" "${host}" "${host} ${status_message} - ${name//_/ } - ${chart} ----- ${alarm}
+send_irc "${IRC_NICKNAME}" "${IRC_REALNAME}" "${to_irc}" "${IRC_NETWORK}" "${IRC_PORT}" "${host}" "${host} ${status_message} - ${name//_/ } - ${chart} ----- ${alarm}
Severity: ${severity}
Chart: ${chart}
Family: ${family}
diff --git a/health/notifications/health_alarm_notify.conf b/health/notifications/health_alarm_notify.conf
index be669e135d..2dab1d4896 100755
--- a/health/notifications/health_alarm_notify.conf
+++ b/health/notifications/health_alarm_notify.conf
@@ -676,6 +676,10 @@ DEFAULT_RECIPIENT_IRC=""
# e.g. "irc.freenode.net"
IRC_NETWORK=""
+# The irc port to which a connection will occur.
+# e.g. 6667 (the default one), 6697 (a TLS/SSL one)
+IRC_PORT=6667
+
# The irc nickname which is required to send the notification. It must not be
# an already registered name as the connection's MODE is defined as a 'guest'.
IRC_NICKNAME=""