Skip to content
← All articles

Zabbix, PRTG and Checkmk alerts by SMS

7 min readDeutsch

Send Zabbix, PRTG and Checkmk alerts as SMS with one HTTP request or by e-mail to SMS, without a GSM modem: media type, HTTP action and notification script.

In short

All three monitoring systems can call a URL: Zabbix with a webhook media type, PRTG with the Execute HTTP Action notification, Checkmk with a small notification script. Point them at the TopSMS HTTP GET API (https://www.topsms.cz/api/sms/get with to and text) and every alert becomes an SMS, €0.089 each to Germany and Austria. Systems that can only send e-mail use e-mail to SMS: 4915112345678@sms.topsms.eu.

A monitoring alert by e-mail is easy to miss at night or on the road. An SMS reaches the on-call phone without an app, without mobile data and without a login. This guide connects Zabbix, PRTG and Checkmk to SMS with one HTTP request each, and shows the e-mail route for devices that cannot do HTTP.

The building block: SMS with one URL

The TopSMS HTTP GET API sends an SMS with a single GET or form POST to https://www.topsms.cz/api/sms/get (also reachable at https://topsms.eu/api/sms/get). Two parameters are required, to in international format and text; from, send_at, ref and format=json are optional. The answer is one line of plain text, so even a shell script can check it:

curl -H "Authorization: Bearer CLIENT_ID:SECRET" \
  "https://www.topsms.cz/api/sms/get?to=%2B4915112345678&text=Disk%20full%20on%20db1"

OK cmh3x9k2a0001qz8l5v7w2abc
ERROR insufficient_credit Insufficient credit. ...

HTTP status codes match the REST API: 200 sent, 401 wrong key, 402 not enough credit, 429 rate limit. Credit, sender, blacklist, test keys and the request log work exactly as with POST /api/sms/send.

One key just for monitoring

Create a separate API key in the dashboard with scope send only, and restrict it to the IP addresses of your monitoring server. Authenticate in this order of preference: header Authorization: Bearer CLIENT_ID:SECRET, then client_id and secret in a POST form body. Putting the key in the URL query string is possible for devices that can do nothing else, but it is off by default; enable “Allow URL authentication” under GET & e-mail for that key only if you must, because URLs end up in logs.

Zabbix: webhook media type

Zabbix’s own SMS media type needs a GSM modem on the server’s serial port. The webhook media type needs only HTTPS. According to the Zabbix manual, you create it under Alerts, Media types, Create media type; the script is JavaScript that receives the parameters as JSON in value and must return a value. Set the type to Webhook and add three parameters:

  • to = {ALERT.SENDTO}
  • message = {ALERT.SUBJECT}: {ALERT.MESSAGE}
  • token = CLIENT_ID:SECRET

Script:

var p = JSON.parse(value);
var req = new HttpRequest();
req.addHeader('Authorization: Bearer ' + p.token);
req.addHeader('Content-Type: application/x-www-form-urlencoded');
var body = 'to=' + encodeURIComponent(p.to) + '&text=' + encodeURIComponent(p.message.slice(0, 600));
var res = req.post('https://www.topsms.cz/api/sms/get', body);
if (req.getStatus() !== 200 || res.indexOf('OK ') !== 0) throw 'TopSMS: ' + res;
return 'OK';

HttpRequest, addHeader, post and getStatus are Zabbix’s documented JavaScript objects. The script cuts the text to 600 characters, so a verbose trigger description does not turn into ten SMS; shorten it further if you prefer one SMS per alert. Then add the media to each user who should get SMS, with the mobile number in international format as “Send to”, and use the media type in your trigger actions. A failed send throws an error, which Zabbix shows in the action log.

PRTG: Execute HTTP Action

In PRTG open Setup, Account Settings, Notification Templates, add a template and enable Execute HTTP Action. The PRTG manual describes the fields URL, HTTP method and, for POST, a payload, which must be form-encoded, not JSON. That matches the HTTP GET API:

Method:  POST
URL:     https://www.topsms.cz/api/sms/get
Payload: client_id=CLIENT_ID&secret=SECRET&to=%2B4915112345678&text=%device %name %status %message

%device, %name, %status and %message are PRTG placeholders for the device, the sensor, the old and new status and the last sensor message. POST keeps the key out of the URL. Create one template per recipient number, or per on-call group with several templates, and attach them to the triggers on your sensors or groups.

Checkmk: notification script

Checkmk passes alert data to notification scripts in environment variables starting with NOTIFY_. The Checkmk user guide says to place your own scripts in ~/local/share/check_mk/notifications and make them executable; the comment on the second line is the title shown in the notification rule. As the site user, save this as topsms:

#!/bin/bash
# TopSMS SMS
# parameter 1 in the notification rule: CLIENT_ID:SECRET
TEXT="$NOTIFY_WHAT $NOTIFY_HOSTNAME ${NOTIFY_SERVICEDESC:-} ${NOTIFY_SERVICESTATE:-}"
/usr/bin/curl -s -H "Authorization: Bearer $NOTIFY_PARAMETER_1" \
  --data-urlencode "to=$NOTIFY_CONTACTPAGER" \
  --data-urlencode "text=$TEXT" \
  https://www.topsms.cz/api/sms/get

Run chmod +x topsms. In a notification rule choose the method “TopSMS SMS” and enter CLIENT_ID:SECRET as the first parameter, which reaches the script as NOTIFY_PARAMETER_1. Enter the on-call mobile number in the Pager field of the user profile; the script reads it from NOTIFY_CONTACTPAGER. Nagios and Icinga work the same way with a curl notification command, see the documentation.

E-mail to SMS for everything else

UPS units, NAS boxes, backup software and older monitoring often know only e-mail alerts. Send them to the phone number at our domain: 4915112345678@sms.topsms.eu. The plain-text body becomes the SMS (HTML is converted, quoted replies and signatures removed, at most 1,600 characters); an empty body uses the subject. Up to 10 numbers fit in To and Cc of one e-mail.

Set it up on a key under GET & e-mail: enable e-mail to SMS and list the allowed sender addresses or your own domain. An e-mail passes only if the sender is on that list and passes DMARC, DKIM or SPF for its domain. If a device’s mail server has no SPF or DKIM, use the address with the key token, 4915112345678.tok_…@sms.topsms.eu. At most 60 e-mails per hour are accepted per key and per sender address, which also caps an alert storm.

Practical tips

  • Keep texts short and in GSM-7. One SMS holds 160 GSM-7 characters; a single character outside that set switches to Unicode and 70 characters per part. Host, service and state are usually enough.
  • Avoid alert storms: send SMS only for high-severity triggers and use escalations; e-mail can carry the rest.
  • Test first: with a test key the monitoring system gets the same OK answers, nothing is sent and nothing charged.
  • Watch the credit: a 402 or ERROR insufficient_credit means alerts stop. Top up in time; credit does not expire.

What it costs

No monthly fee, no modem, no SIM contract. Each SMS to Germany, Austria and the rest of the EU costs €0.089, a final price with no VAT added. 200 alerts a month cost €17.78. New accounts get €0.50 free credit after phone verification. All countries are on the pricing page, more connections under integrations. Create a free account.

Frequently asked questions

Do I need a GSM modem?

No. Zabbix’s built-in SMS media type expects a serial GSM modem on the Zabbix server. With an SMS gateway the server only needs outbound HTTPS to the API, or an e-mail route.

How do I keep the API key out of logs?

Send it in the Authorization header (Zabbix, Checkmk) or in a POST body (PRTG). The key in the URL query string is off by default and returns 403 url_auth_disabled until you allow it for a key. Use a dedicated key with scope send only and an IP whitelist.

What if the same alert fires repeatedly?

Use the ref parameter where your system offers a stable event identifier: the same ref within 24 hours does not send a second SMS. For e-mail to SMS, the same e-mail (same Message-ID) delivered again within 24 hours is ignored.

Can I test the setup without sending SMS?

Yes. Use a test API key: requests are validated and answered like live ones, but nothing is sent or charged. Then switch to a live key.