@cryptotaxi247 / netdata-1 / commits / 8895ab749

Add fleep.io notification support.

This adds support for sending alarm notifications to fleep.io conversations via webhooks. It uses the JSON interface to POST a simple message containing information about the alarm, and by default uses the host that raised the alarm as the sender name. Recipients are specified via the last component of the webhook URL (the only part that's different for each webhook).

Austin S. Hemmelgarn committed Jun 8, 2018 at 07:50 UTC 8895ab749fa211d9cf0d3636cbcc5210ac5427e5
2 files changed +97
conf.d/health_alarm_notify.conf
+34
@@ -447,6 +447,28 @@ SEND_PD="YES"
447 DEFAULT_RECIPIENT_PD=""
448
449
450 +#------------------------------------------------------------------------------
451 +# fleep notification options
452 +#
453 +# To send fleep.io notifications, you will need a webhook for the
454 +# conversation you want to send to.
455 +
456 +# Fleep recipients are specified as the last part of the webhook URL.
457 +# So, for a webhook URL of: https://fleep.io/hook/IJONmBuuSlWlkb_ttqyXJg, the
458 +# recipient name would be: 'IJONmBuuSlWlkb_ttqyXJg'.
459 +
460 +# enable/disable sending fleep notifications
461 +SEND_FLEEP="YES"
462 +
463 +# if a role's recipients are not configured, a notification will not be sent.
464 +# (empty = do not send a notification for unconfigured roles):
465 +DEFAULT_RECIPIENT_FLEEP=""
466 +
467 +# The user name to label the messages with. If this is unset,
468 +# the hostname of the system the notification is for will be used.
469 +FLEEP_SENDER=""
470 +
471 +
472 #------------------------------------------------------------------------------
473 # irc notification options
474 #
@@ -636,6 +658,8 @@ role_recipients_kavenegar[sysadmin]="${DEFAULT_RECIPIENT_KAVENEGAR}"
658
659 role_recipients_pd[sysadmin]="${DEFAULT_RECIPIENT_PD}"
660
661 +role_recipients_fleep[sysadmin]="${DEFAULT_RECIPIENT_FLEEP}"
662 +
663 role_recipients_irc[sysadmin]="${DEFAULT_RECIPIENT_IRC}"
664
665 role_recipients_syslog[sysadmin]="${DEFAULT_RECIPIENT_SYSLOG}"
@@ -671,6 +695,8 @@ role_recipients_kavenegar[domainadmin]="${DEFAULT_RECIPIENT_KAVENEGAR}"
695
696 role_recipients_pd[domainadmin]="${DEFAULT_RECIPIENT_PD}"
697
698 +role_recipients_fleep[domainadmin]="${DEFAULT_RECIPIENT_FLEEP}"
699 +
700 role_recipients_irc[domainadmin]="${DEFAULT_RECIPIENT_IRC}"
701
702 role_recipients_syslog[domainadmin]="${DEFAULT_RECIPIENT_SYSLOG}"
@@ -707,6 +733,8 @@ role_recipients_kavenegar[dba]="${DEFAULT_RECIPIENT_KAVENEGAR}"
733
734 role_recipients_pd[dba]="${DEFAULT_RECIPIENT_PD}"
735
736 +role_recipients_fleep[dba]="${DEFAULT_RECIPIENT_FLEEP}"
737 +
738 role_recipients_irc[dba]="${DEFAULT_RECIPIENT_IRC}"
739
740 role_recipients_syslog[dba]="${DEFAULT_RECIPIENT_SYSLOG}"
@@ -743,6 +771,8 @@ role_recipients_kavenegar[webmaster]="${DEFAULT_RECIPIENT_KAVENEGAR}"
771
772 role_recipients_pd[webmaster]="${DEFAULT_RECIPIENT_PD}"
773
774 +role_recipients_fleep[webmaster]="${DEFAULT_RECIPIENT_FLEEP}"
775 +
776 role_recipients_irc[webmaster]="${DEFAULT_RECIPIENT_IRC}"
777
778 role_recipients_syslog[webmaster]="${DEFAULT_RECIPIENT_SYSLOG}"
@@ -779,6 +809,8 @@ role_recipients_kavenegar[proxyadmin]="${DEFAULT_RECIPIENT_KAVENEGAR}"
809
810 role_recipients_pd[proxyadmin]="${DEFAULT_RECIPIENT_PD}"
811
812 +role_recipients_fleep[proxyadmin]="${DEFAULT_RECIPIENT_FLEEP}"
813 +
814 role_recipients_irc[proxyadmin]="${DEFAULT_RECIPIENT_IRC}"
815
816 role_recipients_syslog[proxyadmin]="${DEFAULT_RECIPIENT_SYSLOG}"
@@ -815,6 +847,8 @@ role_recipients_kavenegar[sitemgr]="${DEFAULT_RECIPIENT_KAVENEGAR}"
847
848 role_recipients_pd[sitemgr]="${DEFAULT_RECIPIENT_PD}"
849
850 +role_recipients_fleep[sitemgr]="${DEFAULT_RECIPIENT_FLEEP}"
851 +
852 role_recipients_syslog[sitemgr]="${DEFAULT_RECIPIENT_SYSLOG}"
853
854 role_recipients_custom[sitemgr]="${DEFAULT_RECIPIENT_CUSTOM}"
plugins.d/alarm-notify.sh
+63
@@ -26,6 +26,7 @@
26 # - pagerduty.com notifications by Jim Cooley @jimcooley #1373
27 # - messagebird.com notifications by @tech_no_logical #1453
28 # - hipchat notifications by @ktsaou #1561
29 +# - fleep notifications by @Ferroin
30 # - custom notifications by @ktsaou
31 # - syslog messages by @Ferroin
32
@@ -239,6 +240,7 @@ SEND_EMAIL="YES"
240 SEND_PUSHBULLET="YES"
241 SEND_KAFKA="YES"
242 SEND_PD="YES"
243 +SEND_FLEEP="YES"
244 SEND_IRC="YES"
245 SEND_SYSLOG="NO"
246 SEND_CUSTOM="YES"
@@ -314,6 +316,11 @@ PD_SERVICE_KEY=
316 DEFAULT_RECIPIENT_PD=
317 declare -A role_recipients_pd=()
318
319 +# fleep.io configs
320 +FLEEP_SENDER="${host}"
321 +DEFAULT_RECIPIENT_FLEEP=
322 +declare -A role_recipients_fleep=()
323 +
324 # syslog configs
325 SYSLOG_FACILITY=
326 declare -A role_recipients_syslog=()
@@ -427,6 +434,7 @@ declare -A arr_email=()
434 declare -A arr_custom=()
435 declare -A arr_messagebird=()
436 declare -A arr_kavenegar=()
437 +declare -A arr_fleep=()
438 declare -A arr_irc=()
439 declare -A arr_syslog=()
440
@@ -542,6 +550,14 @@ do
550 [ "${r}" != "disabled" ] && filter_recipient_by_criticality pd "${r}" && arr_pd[${r/|*/}]="1"
551 done
552
553 + # fleep.io
554 + a="${role_recipients_fleep[${x}]}"
555 + [ -z "${a}" ] && a="${DEFAULT_RECIPIENT_FLEEP}"
556 + for r in ${a//,/ }
557 + do
558 + [ "${r}" != "disabled" ] && filter_recipient_by_criticality fleep "${r}" && arr_fleep[${r/|*/}]="1"
559 + done
560 +
561 # irc
562 a="${role_recipients_irc[${x}]}"
563 [ -z "${a}" ] && a="${DEFAULT_RECIPIENT_IRC}"
@@ -616,6 +632,10 @@ to_telegram="${!arr_telegram[*]}"
632 to_pd="${!arr_pd[*]}"
633 [ -z "${to_pd}" ] && SEND_PD="NO"
634
635 +# build the list of fleep recipients (conversation webhooks)
636 +to_fleep="${!arr_fleep[*]}"
637 +[ -z "${to_fleep}" ] && SEND_FLEEP="NO"
638 +
639 # build the list of custom recipients
640 to_custom="${!arr_custom[*]}"
641 [ -z "${to_custom}" ] && SEND_CUSTOM="NO"
@@ -679,6 +699,9 @@ to_syslog="${!arr_syslog[*]}"
699 # check irc
700 [ -z "${IRC_NETWORK}" ] && SEND_IRC="NO"
701
702 +# check fleep
703 +[ -z "${FLEEP_SERVER}" -o -z "${FLEEP_SENDER}" ] && SEND_FLEEP="NO"
704 +
705 # check pagerduty.com
706 # if we need pd-send, check for the pd-send command
707 # https://www.pagerduty.com/docs/guides/agent-install-guide/
@@ -706,6 +729,7 @@ if [ \( \
729 -o "${SEND_TELEGRAM}" = "YES" \
730 -o "${SEND_PUSHBULLET}" = "YES" \
731 -o "${SEND_KAFKA}" = "YES" \
732 + -o "${SEND_FLEEP}" = "YES" \
733 -o "${SEND_CUSTOM}" = "YES" \
734 \) -a -z "${curl}" ]
735 then
@@ -725,6 +749,7 @@ if [ \( \
749 SEND_MESSAGEBIRD="NO"
750 SEND_KAVENEGAR="NO"
751 SEND_KAFKA="NO"
752 + SEND_FLEEP="NO"
753 SEND_CUSTOM="NO"
754 fi
755 fi
@@ -766,6 +791,7 @@ if [ "${SEND_EMAIL}" != "YES" \
791 -a "${SEND_PUSHBULLET}" != "YES" \
792 -a "${SEND_KAFKA}" != "YES" \
793 -a "${SEND_PD}" != "YES" \
794 + -a "${SEND_FLEEP}" != "YES" \
795 -a "${SEND_CUSTOM}" != "YES" \
796 -a "${SEND_IRC}" != "YES" \
797 -a "${SEND_SYSLOG}" != "YES" \
@@ -1514,6 +1540,36 @@ EOF
1540 return 1
1541 }
1542
1543 +# -----------------------------------------------------------------------------
1544 +# fleep sender
1545 +
1546 +send_fleep() {
1547 + local httpcode sent=0 webhooks="${1}" data message
1548 + if [ "${SEND_FLEEP}" = "YES" ] ; then
1549 + message="${host} ${status_message}, \`${chart}\` (${family}), *${alarm}*\\n${info}"
1550 +
1551 + for hook in "${webhooks}" ; do
1552 + data="{ "
1553 + data="${data} 'message': '${message}', "
1554 + data="${data} 'user': '${FLEEP_SENDER}' "
1555 + data="${data} }"
1556 +
1557 + httpcode=$(docurl -X POST --data "${data}" "https://fleep.io/hook/${hook}")
1558 +
1559 + if [ "${httpcode}" = "200" ] ; then
1560 + info "sent fleep data for: ${host} ${chart}.${name} is ${status} and user '${FLEEP_SENDER}'"
1561 + sent=$((sent + 1))
1562 + else
1563 + error "failed to send fleep data for: ${host} ${chart}.${name} is ${status} and user '${FLEEP_SENDER}' with HTTP error code ${httpcode}."
1564 + fi
1565 + done
1566 +
1567 + [ ${sent} -gt 0 ] && return 0
1568 + fi
1569 +
1570 + return 1
1571 +}
1572 +
1573 # -----------------------------------------------------------------------------
1574 # irc sender
1575
@@ -1840,6 +1896,12 @@ SENT_KAFKA=$?
1896 send_pd "${to_pd}"
1897 SENT_PD=$?
1898
1899 +# -----------------------------------------------------------------------------
1900 +# send the fleep message
1901 +
1902 +send_fleep "${to_fleep}"
1903 +SENT_FLEEP=$?
1904 +
1905 # -----------------------------------------------------------------------------
1906 # send the irc message
1907
@@ -2032,6 +2094,7 @@ if [ ${SENT_EMAIL} -eq 0 \
2094 -o ${SENT_PUSHBULLET} -eq 0 \
2095 -o ${SENT_KAFKA} -eq 0 \
2096 -o ${SENT_PD} -eq 0 \
2097 + -o ${SENT_FLEEP} -eq 0 \
2098 -o ${SENT_IRC} -eq 0 \
2099 -o ${SENT_CUSTOM} -eq 0 \
2100 -o ${SENT_SYSLOG} -eq 0 \