@cryptotaxi247 / netdata-1 / commits / cb6aacc86

custom sender should require curl; fixed typos in conditions with ==

Costa Tsaousis (ktsaou) committed Oct 13, 2017 at 12:52 UTC cb6aacc869a5303464d70df621ffcdccc5d6a254
1 file changed +13 -11
plugins.d/alarm-notify.sh
+13 -11
@@ -609,6 +609,7 @@ if [ \( \
609 -o "${SEND_TELEGRAM}" = "YES" \
610 -o "${SEND_PUSHBULLET}" = "YES" \
611 -o "${SEND_KAFKA}" = "YES" \
612 + -o "${SEND_CUSTOM}" = "YES" \
613 \) -a -z "${curl}" ]
614 then
615 curl="$(which curl 2>/dev/null || command -v curl 2>/dev/null)"
@@ -625,6 +626,7 @@ if [ \( \
626 SEND_MESSAGEBIRD="NO"
627 SEND_KAVENEGAR="NO"
628 SEND_KAFKA="NO"
629 + SEND_CUSTOM="NO"
630 fi
631 fi
632
@@ -828,7 +830,7 @@ send_pushover() {
830 --form-string "priority=${priority}" \
831 https://api.pushover.net/1/messages.json)
832
831 - if [ "${httpcode}" == "200" ]
833 + if [ "${httpcode}" = "200" ]
834 then
835 info "sent pushover notification for: ${host} ${chart}.${name} is ${status} to '${user}'"
836 sent=$((sent + 1))
@@ -864,7 +866,7 @@ send_pushbullet() {
866 EOF
867 ) "https://api.pushbullet.com/v2/pushes" -X POST)
868
867 - if [ "${httpcode}" == "200" ]
869 + if [ "${httpcode}" = "200" ]
870 then
871 info "sent pushbullet notification for: ${host} ${chart}.${name} is ${status} to '${user}'"
872 sent=$((sent + 1))
@@ -890,7 +892,7 @@ send_kafka() {
892 --data "{host_ip:\"${KAFKA_SENDER_IP}\",when:${when},name:\"${name}\",chart:\"${chart}\",family:\"${family}\",status:\"${status}\",old_status:\"${old_status}\",value:${value},old_value:${old_value},duration:${duration},non_clear_duration:${non_clear_duration},units:\"${units}\",info:\"${info}\"}" \
893 "${KAFKA_URL}")
894
893 - if [ "${httpcode}" == "204" ]
895 + if [ "${httpcode}" = "204" ]
896 then
897 info "sent kafka data for: ${host} ${chart}.${name} is ${status} and ip '${KAFKA_SENDER_IP}'"
898 sent=$((sent + 1))
@@ -977,7 +979,7 @@ send_twilio() {
979 -u "${accountsid}:${accounttoken}" \
980 "https://api.twilio.com/2010-04-01/Accounts/${accountsid}/Messages.json")
981
980 - if [ "${httpcode}" == "201" ]
982 + if [ "${httpcode}" = "201" ]
983 then
984 info "sent Twilio SMS for: ${host} ${chart}.${name} is ${status} to '${user}'"
985 sent=$((sent + 1))
@@ -1030,7 +1032,7 @@ send_hipchat() {
1032 -d "{\"color\": \"${color}\", \"from\": \"${host}\", \"message_format\": \"${msg_format}\", \"message\": \"${message}\", \"notify\": \"${notify}\"}" \
1033 "https://${HIPCHAT_SERVER}/v2/room/${room}/notification")
1034
1033 - if [ "${httpcode}" == "204" ]
1035 + if [ "${httpcode}" = "204" ]
1036 then
1037 info "sent HipChat notification for: ${host} ${chart}.${name} is ${status} to '${room}'"
1038 sent=$((sent + 1))
@@ -1064,7 +1066,7 @@ send_messagebird() {
1066 -H "Authorization: AccessKey ${accesskey}" \
1067 "https://rest.messagebird.com/messages")
1068
1067 - if [ "${httpcode}" == "201" ]
1069 + if [ "${httpcode}" = "201" ]
1070 then
1071 info "sent Messagebird SMS for: ${host} ${chart}.${name} is ${status} to '${user}'"
1072 sent=$((sent + 1))
@@ -1094,7 +1096,7 @@ send_kavenegar() {
1096 --data-urlencode "receptor=${user}" \
1097 --data-urlencode "message=${title} ${message}")
1098
1097 - if [ "${httpcode}" == "201" ]
1099 + if [ "${httpcode}" = "201" ]
1100 then
1101 info "sent Kavenegar SMS for: ${host} ${chart}.${name} is ${status} to '${user}'"
1102 sent=$((sent + 1))
@@ -1135,11 +1137,11 @@ send_telegram() {
1137 --data-urlencode "text=${emoji} ${message}" \
1138 "https://api.telegram.org/bot${bottoken}/sendMessage?chat_id=${chatid}")
1139
1138 - if [ "${httpcode}" == "200" ]
1140 + if [ "${httpcode}" = "200" ]
1141 then
1142 info "sent telegram notification for: ${host} ${chart}.${name} is ${status} to '${chatid}'"
1143 sent=$((sent + 1))
1142 - elif [ "${httpcode}" == "401" ]
1144 + elif [ "${httpcode}" = "401" ]
1145 then
1146 error "failed to send telegram notification for: ${host} ${chart}.${name} is ${status} to '${chatid}': Wrong bot token."
1147 else
@@ -1203,7 +1205,7 @@ EOF
1205 )"
1206
1207 httpcode=$(docurl -X POST --data-urlencode "payload=${payload}" "${webhook}")
1206 - if [ "${httpcode}" == "200" ]
1208 + if [ "${httpcode}" = "200" ]
1209 then
1210 info "sent slack notification for: ${host} ${chart}.${name} is ${status} to '${channel}'"
1211 sent=$((sent + 1))
@@ -1266,7 +1268,7 @@ EOF
1268 )"
1269
1270 httpcode=$(docurl -X POST --data-urlencode "payload=${payload}" "${webhook}")
1269 - if [ "${httpcode}" == "200" ]
1271 + if [ "${httpcode}" = "200" ]
1272 then
1273 info "sent discord notification for: ${host} ${chart}.${name} is ${status} to '${channel}'"
1274 sent=$((sent + 1))