@cryptotaxi247 / netdata-1 / commits / e0f69fd8b

Fix smstools3 error handling (#5770)

* Fixed smstools3 error handling * Correct variable declarations * Correct smssend to sendsms * Add two spaces before dashes in .md lists * Add two spaces AFTER dashes in .md lists * Change list to star

Chris Akritidis committed Apr 2, 2019 at 16:56 UTC e0f69fd8be92866b83299e04a1ef3752db5bc097
2 files changed +12 -4
health/notifications/alarm-notify.sh.in
+5 -4
@@ -1740,7 +1740,7 @@ send_syslog() {
1740 # SMS sender
1741
1742 send_sms() {
1743 - local recipients="${1}" exitcode sent=0
1743 + local recipients="${1}" errcode errmessage sent=0
1744
1745 # Human readable SMS
1746 local msg="${host} ${status_message}: ${chart} (${family}), ${alarm}"
@@ -1751,12 +1751,13 @@ send_sms() {
1751 if [ "${SEND_SMS}" = "YES" ] && [ -n "${sendsms}" ] && [ -n "${recipients}" ] && [ -n "${msg}" ]; then
1752 # http://api.kavenegar.com/v1/{API-KEY}/sms/send.json
1753 for phone in ${recipients}; do
1754 - exitcode=$($sendsms $phone "$msg")
1755 - if [ ${exitcode} -eq 0 ]; then
1754 + errmessage=$($sendsms $phone "$msg" 2>&1)
1755 + errcode=$?
1756 + if [ ${errcode} -eq 0 ]; then
1757 info "sent smstools3 SMS for: ${host} ${chart}.${name} is ${status} to '${user}'"
1758 sent=$((sent + 1))
1759 else
1759 - error "failed to send smstools3 SMS for: ${host} ${chart}.${name} is ${status} to '${user}' with error code ${exitcode}."
1760 + error "failed to send smstools3 SMS for: ${host} ${chart}.${name} is ${status} to '${user}' with error code ${errcode}: ${errmessage}."
1761 fi
1762 done
1763
health/notifications/smstools3/README.md
+7
@@ -4,6 +4,13 @@ The [SMS Server Tools 3](http://smstools3.kekekasvi.com/) is a SMS Gateway softw
4
5 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.
6
7 +Ensure that the user `netdata` can execute `sendsms`. Any user executing `sendsms` needs to:
8 +
9 +* Have write permissions to `/tmp` and `/var/spool/sms/outgoing`
10 +* Be a member of group `smsd`
11 +
12 +To ensure that the steps above are successful, just `su netdata` and execute `sendsms phone message`.
13 +
14 You then just need to configure the recipient phone numbers in `health_alarm_notify.conf`:
15
16 ```sh