SMS notification via D7SMS

Nagios SMS Plugin

Python script for sending SMS notifications from Nagios using D7SMS Gateway.

Getting Started

These instructions will get you a copy of the script and configuration guidelines for setting it up in Nagios


  1. Signup at and verify account with mobile number
  2. Navigate to API Tokens > Create App
  3. Once the application is created, click on "Generate Token" and this token needs to be added in file.

Installation Instructions

Download script and configure Token

  1. Navigate to plugins folder on Nagios/Icinga Server

        Following the location of plugins folder in different Operating Systems. 
        Debian/Ubuntu: /usr/local/nagios/libexec
        Centos: /usr/lib/nagios/plugins (32 bit)
                /usr/lib64/nagios/plugins (64 bit)
  2. Download from
  3. Make it executable
        cd /usr/local/nagios/libexec
        chmod +x
  4. Replace "YOUR_D7_TOKEN" in the file with the token you have created earlier.
        vim +12

    Test the script

    (Remeber to replace the destination number)

        ./ --to 9715097526xx --content "Test message from Nagios"

Modify Nagios configs

  1. Create notification commands.

    Create for both Service and Host notifications.

    Default path : /usr/local/nagios/etc/objects/commands.cfg

    define command{
        command_name    service-notify-by-sms
        command_line    $USER1$/ --to $CONTACTPAGER$ --content "$NOTIFICATIONTYPE$:$SERVICEDESC$ on $HOSTNAME$ with IP $HOSTADDRESS$ Current State $SERVICESTATE$ Service Info: $SERVICEOUTPUT$ Date: $LONGDATETIME$"
    define command{
        command_name    host-notify-by-sms
        command_line    $USER1$/ --to $CONTACTPAGER$ --content "$NOTIFICATIONTYPE$: Host: $HOSTNAME$, State: $HOSTSTATE$, Address: $HOSTADDRESS$, Info: $HOSTOUTPUT$, Date/Time: $LONGDATETIME$"
  2. Update contact template

    Add below commands to templates.

    Default path : /usr/local/nagios/etc/objects/templates.cfg

        service_notification_commands   notify-service-by-email,service-notify-by-sms
        host_notification_commands      notify-host-by-email,host-notify-by-sms
  3. Add a pager number to your contacts.

    This will be used as sms destination number. Make sure it has the international prefix (country code)

    Default path : /usr/local/nagios/etc/objects/contacts.cfg

        define contact {
            contact_name            nagiosadmin
            use                     generic-contact
            alias                   Nagios Admin
            pager                   +9715097526xx
  1. Check configurations and restart Nagios

  2. Also, you can check the /usr/local/nagios/nagios.log, in case if you need to check for errors

Support and Help

You can get the latest version of this script from

For all queries and help on installation please contact or visit

Setup instructions for NagiosXI can be found here: