diff options
author | Ilya Mashchenko <ilya@netdata.cloud> | 2023-07-05 13:18:44 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-05 13:18:44 +0300 |
commit | 1e181518553ea297768aa80a86e74e15569e0617 (patch) | |
tree | bbd7084eda22c1c1610ee3fe8b3ffa3dc1428ee2 /health | |
parent | 82339fb66d13c132b09eb280f70704ee94c94d10 (diff) |
health: respect overriding nc binary for IRC notifications (#15310)
Diffstat (limited to 'health')
-rwxr-xr-x | health/notifications/alarm-notify.sh.in | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/health/notifications/alarm-notify.sh.in b/health/notifications/alarm-notify.sh.in index 51c0002187..1867cf818f 100755 --- a/health/notifications/alarm-notify.sh.in +++ b/health/notifications/alarm-notify.sh.in @@ -768,6 +768,15 @@ if [ "${SEND_AWSSNS}" = "YES" ] && [ -z "${aws}" ]; then fi fi +# if we need nc, check for the nc command +if [ "${SEND_IRC}" = "YES" ] && [ -z "${nc}" ]; then + nc="$(command -v nc 2>/dev/null)" + if [ -z "${nc}" ]; then + debug "Cannot find nc command in the system path. Disabling IRC notifications." + SEND_IRC="NO" + fi +fi + if [ ${dump_methods} ]; then for name in "${!SEND_@}"; do if [ "${!name}" = "YES" ]; then @@ -1913,7 +1922,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}" "${PORT}") + 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 |