summaryrefslogtreecommitdiffstats
path: root/health
diff options
context:
space:
mode:
authorChris Akritidis <43294513+cakrit@users.noreply.github.com>2019-03-25 10:52:25 +0100
committerGitHub <noreply@github.com>2019-03-25 10:52:25 +0100
commit9c807630ea5e10144892a5bfc5379b36c2a63e8d (patch)
tree34b836a527467531ff0321fafaa44f8a67ae772d /health
parent03ca8f3c4bbc3cbd3d1b120b265052675e2f8079 (diff)
Add SMS Server Tools 3 SMS notifications (#5662)
* Add SMS Server Tools 3 SMS notifications * Minor reordering to present changes better * Fix typo in README link * Fix Codacy Missing code-language flag * Fix missing "to" in readme
Diffstat (limited to 'health')
-rw-r--r--health/notifications/Makefile.am1
-rwxr-xr-xhealth/notifications/alarm-notify.sh.in48
-rwxr-xr-xhealth/notifications/health_alarm_notify.conf28
-rw-r--r--health/notifications/smstools3/Makefile.inc12
-rw-r--r--health/notifications/smstools3/README.md32
5 files changed, 121 insertions, 0 deletions
diff --git a/health/notifications/Makefile.am b/health/notifications/Makefile.am
index a5b88f0de6..24bc1da331 100644
--- a/health/notifications/Makefile.am
+++ b/health/notifications/Makefile.am
@@ -39,6 +39,7 @@ include pushbullet/Makefile.inc
include pushover/Makefile.inc
include rocketchat/Makefile.inc
include slack/Makefile.inc
+include smstools3/Makefile.inc
include syslog/Makefile.inc
include telegram/Makefile.inc
include twilio/Makefile.inc
diff --git a/health/notifications/alarm-notify.sh.in b/health/notifications/alarm-notify.sh.in
index 10be12c7f6..763b1d224f 100755
--- a/health/notifications/alarm-notify.sh.in
+++ b/health/notifications/alarm-notify.sh.in
@@ -165,6 +165,7 @@ kavenegar
prowl
awssns
rocketchat
+sms
"
# -----------------------------------------------------------------------------
@@ -537,6 +538,14 @@ if [ "${SEND_PUSHOVER}" = "YES" ] ||
fi
fi
+if [ "${SEND_SMS}" = "YES" ]; then
+ if [ -z "${sendsms}" ]; then
+ sendsms="$(command -v sendsms 2>/dev/null)"
+ fi
+ if [ -z "${sendsms}" ]; then
+ SEND_SMS="NO"
+ fi
+fi
# if we need sendmail, check for the sendmail command
if [ "${SEND_EMAIL}" = "YES" ] && [ -z "${sendmail}" ]; then
sendmail="$(command -v sendmail 2>/dev/null)"
@@ -649,6 +658,7 @@ for method in "${SEND_EMAIL}" \
"${SEND_IRC}" \
"${SEND_AWSSNS}" \
"${SEND_SYSLOG}" \
+ "${SEND_SMS}" \
"${SEND_MSTEAM}"; do
if [ "${method}" == "YES" ]; then
proceed=1
@@ -1727,6 +1737,36 @@ send_syslog() {
}
# -----------------------------------------------------------------------------
+# SMS sender
+
+send_sms() {
+ local recipients="${1}" exitcode sent=0
+
+ # Human readable SMS
+ local msg="${host} ${status_message}: ${chart} (${family}), ${alarm}"
+
+ # limit it to 160 characters
+ msg="${msg:0:160}"
+
+ if [ "${SEND_SMS}" = "YES" ] && [ -n "${sendsms}" ] && [ -n "${recipients}" ] && [ -n "${msg}" ]; then
+ # http://api.kavenegar.com/v1/{API-KEY}/sms/send.json
+ for phone in ${recipients}; do
+ exitcode=$($sendsms $phone "$msg")
+ if [ ${exitcode} -eq 0 ]; then
+ info "sent smstools3 SMS for: ${host} ${chart}.${name} is ${status} to '${user}'"
+ sent=$((sent + 1))
+ else
+ error "failed to send smstools3 SMS for: ${host} ${chart}.${name} is ${status} to '${user}' with error code ${exitcode}."
+ fi
+ done
+
+ [ ${sent} -gt 0 ] && return 0
+ fi
+
+ return 1
+}
+
+# -----------------------------------------------------------------------------
# prepare the content of the notification
# the url to send the user on click
@@ -1996,6 +2036,13 @@ ${info}"
SENT_IRC=$?
# -----------------------------------------------------------------------------
+# send the SMS message with smstools3
+
+send_sms "${to_sms}"
+
+SENT_SMS=$?
+
+# -----------------------------------------------------------------------------
# send the custom message
send_custom() {
@@ -2209,6 +2256,7 @@ for state in "${SENT_EMAIL}" \
"${SENT_IRC}" \
"${SENT_AWSSNS}" \
"${SENT_SYSLOG}" \
+ "${SENT_SMS}" \
"${SENT_MSTEAM}"; do
if [ "${state}" -eq 0 ]; then
# we sent something
diff --git a/health/notifications/health_alarm_notify.conf b/health/notifications/health_alarm_notify.conf
index b96cf57931..cfbbd029ab 100755
--- a/health/notifications/health_alarm_notify.conf
+++ b/health/notifications/health_alarm_notify.conf
@@ -13,6 +13,7 @@
# - messages to your telegram chat / group chat (telegram.org)
# - sms messages to your cell phone or any sms enabled device (twilio.com)
# - sms messages to your cell phone or any sms enabled device (messagebird.com)
+# - sms messages to your cell phone or any sms enabled device (smstools3)
# - notifications to users on pagerduty.com
# - push notifications to iOS devices (via prowlapp.com)
# - notifications to Amazon SNS topics (aws.amazon.com)
@@ -110,6 +111,11 @@ logger=""
# If not found, Amazon SNS notifications will be silently disabled.
aws=""
+# The full path of the sendsms command (smstools3).
+# If empty, the system $PATH will be searched for it.
+# If not found, SMS notifications will be silently disabled.
+sendsms=""
+
#------------------------------------------------------------------------------
# extra options for external commands
#
@@ -693,6 +699,18 @@ AWSSNS_MESSAGE_FORMAT="${status} on ${host} at ${date}: ${chart} ${value_string}
DEFAULT_RECIPIENT_AWSSNS=""
#------------------------------------------------------------------------------
+# SMS Server Tools 3 (smstools3) global notification options
+
+# enable/disable sending SMS Server Tools 3 SMS notifications
+SEND_SMS="YES"
+
+# if a role's recipients are not configured, a notification will be sent to
+# this SMS channel (empty = do not send a notification for unconfigured
+# roles). Multiple recipients can be given like this: "PHONE1 PHONE2 ..."
+
+DEFAULT_RECIPIENT_SMS=""
+
+#------------------------------------------------------------------------------
# custom notifications
#
@@ -844,6 +862,8 @@ role_recipients_custom[domainadmin]="${DEFAULT_RECIPIENT_CUSTOM}"
role_recipients_msteam[domainadmin]="${DEFAULT_RECIPIENT_MSTEAM}"
+role_recipients_sms[domainadmin]="${DEFAULT_RECIPIENT_SMS}"
+
# -----------------------------------------------------------------------------
# database servers alarms
# mysql, redis, memcached, postgres, etc
@@ -888,6 +908,8 @@ role_recipients_custom[dba]="${DEFAULT_RECIPIENT_CUSTOM}"
role_recipients_msteam[dba]="${DEFAULT_RECIPIENT_MSTEAM}"
+role_recipients_sms[dba]="${DEFAULT_RECIPIENT_SMS}"
+
# -----------------------------------------------------------------------------
# web servers alarms
# apache, nginx, lighttpd, etc
@@ -932,6 +954,8 @@ role_recipients_custom[webmaster]="${DEFAULT_RECIPIENT_CUSTOM}"
role_recipients_msteam[webmaster]="${DEFAULT_RECIPIENT_MSTEAM}"
+role_recipients_sms[webmaster]="${DEFAULT_RECIPIENT_SMS}"
+
# -----------------------------------------------------------------------------
# proxy servers alarms
# squid, etc
@@ -976,6 +1000,8 @@ role_recipients_custom[proxyadmin]="${DEFAULT_RECIPIENT_CUSTOM}"
role_recipients_msteam[proxyadmin]="${DEFAULT_RECIPIENT_MSTEAM}"
+role_recipients_sms[proxyadmin]="${DEFAULT_RECIPIENT_SMS}"
+
# -----------------------------------------------------------------------------
# peripheral devices
# UPS, photovoltaics, etc
@@ -1017,3 +1043,5 @@ role_recipients_awssns[sitemgr]="${DEFAULT_RECIPIENT_AWSSNS}"
role_recipients_custom[sitemgr]="${DEFAULT_RECIPIENT_CUSTOM}"
role_recipients_msteam[sitemgr]="${DEFAULT_RECIPIENT_MSTEAM}"
+
+role_recipients_sms[sitemgr]="${DEFAULT_RECIPIENT_SMS}"
diff --git a/health/notifications/smstools3/Makefile.inc b/health/notifications/smstools3/Makefile.inc
new file mode 100644
index 0000000000..b2d424eaf3
--- /dev/null
+++ b/health/notifications/smstools3/Makefile.inc
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-3.0-or-later
+
+# THIS IS NOT A COMPLETE Makefile
+# IT IS INCLUDED BY ITS PARENT'S Makefile.am
+# IT IS REQUIRED TO REFERENCE ALL FILES RELATIVE TO THE PARENT
+
+# install these files
+dist_noinst_DATA += \
+ smstools3/README.md \
+ smstools3/Makefile.inc \
+ $(NULL)
+
diff --git a/health/notifications/smstools3/README.md b/health/notifications/smstools3/README.md
new file mode 100644
index 0000000000..71e13dc197
--- /dev/null
+++ b/health/notifications/smstools3/README.md
@@ -0,0 +1,32 @@
+# SMS Server Tools 3
+
+The [SMS Server Tools 3](http://smstools3.kekekasvi.com/) is a SMS Gateway software which can send and receive short messages through GSM modems and mobile phones.
+
+To have netdata send notifications via SMS Server Tools 3, you'll first need to [install](http://smstools3.kekekasvi.com/index.php?p=compiling) and [configure](http://smstools3.kekekasvi.com/index.php?p=configure) smsd.
+
+You then just need to configure the recipient phone numbers in `health_alarm_notify.conf`:
+
+```sh
+#------------------------------------------------------------------------------
+# SMS Server Tools 3 (smstools3) global notification options
+
+# enable/disable sending SMS Server Tools 3 SMS notifications
+SEND_SMS="YES"
+
+# if a role's recipients are not configured, a notification will be sent to
+# this SMS channel (empty = do not send a notification for unconfigured
+# roles). Multiple recipients can be given like this: "PHONE1 PHONE2 ..."
+
+DEFAULT_RECIPIENT_SMS=""
+```
+
+Netdata uses the script `sendsms` that is installed by `smstools3` and just passes a phone number and a message to it. If `sendsms` is not in `$PATH`, you can pass its location in `health_alarm_notify.conf`:
+
+```sh
+# The full path of the sendsms command (smstools3).
+# If empty, the system $PATH will be searched for it.
+# If not found, SMS notifications will be silently disabled.
+sendsms=""
+```
+
+[![analytics](https://www.google-analytics.com/collect?v=1&aip=1&t=pageview&_s=1&ds=github&dr=https%3A%2F%2Fgithub.com%2Fnetdata%2Fnetdata&dl=https%3A%2F%2Fmy-netdata.io%2Fgithub%2Fhealth%2Fnotifications%2Fsmstools3%2FREADME&_u=MAC~&cid=5792dfd7-8dc4-476b-af31-da2fdb9f93d2&tid=UA-64295674-3)]()