Alerting Configuration

Upon initial configuration of the monitoring system, it is advised to configure alerting (or escalation rules) based on specific needs of your organization or environment.

Actions and Escalations

The notification sending is configured in the Configuration -> Actions section of Zabbix.

Actions can be currently configured via the Danube Cloud API, e.g.:

user@laptop:~ $ es create /mon/action/notify-mygroup -usergroups mygroup \
                                                     -hostgroups linux-servers,windows-servers \
                                                     -recovery_message_enabled true

The Danube Cloud monitoring appliance comes preconfigured with following actions:

  • Notify (with recovery message) - sends notifications for every host in the Notification host group.
  • Notify - Custom Alerts (without recovery message) - sends notifications for every trigger related to items in the Custom Alerts application. Used internally by the Danube Cloud system (e.g. backup failure).

For correct notification delivery of the preconfigured actions, it is necessary to configure users in the Operations section of preconfigured actions.

Notification Delivery Configuration

Individual notifications are sent to users or group of users. Users and user groups are reflected from Danube Cloud to Zabbix by default. It is possible to configure different media for every user or group of users through which the notification shall be delivered. This is configurable in Administration -> Media types. Danube Cloud comes preconfigured with following media types:

  • Email media type sends notifications via email. Emails are delivered via local mail server on the monitoring server. The destination email address can be configured in user’s media type settings (Send to). This media type corresponds to the alerting email set in user’s profile.
  • SMS media type sends SMS notifications via an SMS provider. Notifications are sent over HTTP to the SMS gateway. This media type requires sms.sh and hqsms.py scripts. The phone number has to be able to receive text messages and it can be configured in user’s media type settings (Send to). This media type corresponds to the alerting phone set in user’s profile.
  • Ludolph media type sends notifications via the Ludolph Jabber bot. It requires the ludolph.sh script. XMMP receiver address needs to be configured in user’s media type settings (Send to). This media type corresponds to the alerting jabber set in user’s profile.
  • Prowl media type sends notifications over PUSH notifications to Apple IOS devices. It requires the prowl.sh and prowl.pl scripts. The API user key needs to be configured in user’s media type settings (Send to).
  • NMA media type sends notifications over PUSH notifications to Google Android devices. It requires the nma.sh and nma.pl. The API user key needs to be configured in user’s media type settings (Send to).

Advanced notification delivery configuration

Scripts used for the correct functioning of following media types need to be placed in the /etc/zabbix/alertscripts folder on the monitoring server.

SMS

  • sms.sh

    #!/bin/bash
    
    PHONE="${1}" # Set this in user media
    shift
    # Everything else is the message itself
    MSG=$(echo "${@}" | sed 's/|\?\*UNKNOWN\*|\?//g')
    
    /etc/zabbix/alertscripts/hqsms.py "${PHONE}" "${MSG}"
    
  • hqsms.py - python script, which requires the requests Python library. The library can be installed via yum install python-requests or pip install requests.

    #!/usr/bin/env python
    
    import sys
    import requests
    
    __USERNAME__ = 'SMS API user name'
    __PASSWORD__ = '123456672aaaa6b508858551264' # md5 hash of the password
    __FROM__ = 'Sender name'
    
    def login_data():
        return { 'username': __USERNAME__, 'password': __PASSWORD__, 'from': __FROM__}
    
    def sms_send(phone, message):
        data = login_data()
        data['to'] = phone.replace('+', '')
        data['message'] = message
        return requests.post("https://ssl.hqsms.com/sms.do", data)
    
    
    if __name__ == '__main__':
        if len(sys.argv) < 3:
            sys.stderr.write('Usage: %s <phone> <message>\n' % sys.argv[0])
            sys.exit(1)
    
        msg = str(' '.join(sys.argv[2:]))
        r = sms_send(sys.argv[1], msg[:160])
    
        print('%s (%s)' % (r.text, r.status_code))
    
        if r.status_code == 200 and r.text.startswith('OK:'):
            sys.exit(0)
    
        sys.exit(1)
    

Ludolph

  • ludolph.sh - requires the Ludolph running directly on the monitoring server. Ludolph needs to have the web server module turned on.

    #!/bin/bash
    
    JID=${1}
    shift
    MSG=$(echo "${@}" | sed 's/|\?\*UNKNOWN\*|\?//g')
    
    curl -s -m 3 -o /dev/null -d "jid=${JID}&msg=${MSG}" http://127.0.0.1:8922/alert
    

Prowl

  • prowl.sh

    #!/bin/bash
    
    APP="Danube Cloud"
    APIKEY="${1}" # Set this in user media
    shift
    # Everything else is the message itself
    MSG=$(echo "${@}" | cut -d ':' -f 2- | sed 's/|\?\*UNKNOWN\*|\?//g')
    # The message begins with the "${HOSTNAME}:"
    HOST=$(echo "${@}" | cut -d ':' -f 1)
    # Extract priority from the message end, which is in format "(${TRIGGER.NSEVERITY})"
    # Subtract 3, because prowl uses priorities from -2 (Very Low) to 2 (Emergency)
    # (We are not using the 0 / "Not classified" severity in zabbix)
    PRIO=$((${MSG:(-2):1} - 3))
    
    /etc/zabbix/alertscripts/prowl.pl -apikey="${APIKEY}" -application="${APP}" \
        -priority="${PRIO}" -event="${HOST}" -notification="${MSG}"
    
  • prowl.pl - can be downloaded from https://www.prowlapp.com/static/prowl.pl

NMA

  • nma.sh

    #!/bin/bash
    
    APP="Danube Cloud"
    APIKEY="${1}" # Set this in user media
    shift
    # Everything else is the message itself
    MSG=$(echo "${@}" | cut -d ':' -f 2- | sed 's/|\?\*UNKNOWN\*|\?//g')
    # The message begins with the "${HOSTNAME}:"
    HOST=$(echo "${@}" | cut -d ':' -f 1)
    # Extract priority from the message end, which is in format "(${TRIGGER.NSEVERITY})"
    # Subtract 3, because prowl uses priorities from -2 (Very Low) to 2 (Emergency)
    # (We are not using the 0 / "Not classified" severity in zabbix)
    PRIO=$((${MSG:(-2):1} - 3))
    
    /etc/zabbix/alertscripts/nma.pl -apikey="${APIKEY}" -application="${APP}" \
        -priority="${PRIO}" -event="${HOST}" -notification="${MSG}"
    
  • nma.pl - can be downloaded from https://www.notifymyandroid.com/files/nma.pl

Note

Zabbix is a registered trademark of Zabbix LLC.