User Tools

Site Tools


nagios_integration

Nagios/Icinga integration for SMS alerts

This article explains how to integrate a standard Nagios (or Icinga) monitoring server with your FoxBox, in order to use it as an external SMS notification system.

#1: Installation on the FoxBox side

Your FoxBox is specifically designed for these kind of communication tasks, thus there is not much to do here except:

  • Providing a valid IP address, reachable from your monitoring server;
  • Inserting a tested and full working SIM card, to send the SMS.

#2: Installation on the Server side

First of all you need to place the script sendSMS.sh (available here) inside of the folder /usr/lib/nagios/plugins/ giving it right permissions, in order to allow the Nagios user executing it.

Resolving dependencies

The sendSMS.sh script required the perl LWP::UserAgent library. This had to be installed through the command:

apt-get install libwww-perl

NTP and timezone configuration

Adjust NTP config and timezone through these commands:

apt-get install ntp
dpkg-reconfigure tzdata

Notification setting

Now you should add the new notification commands, working on the SMS channel instead of the classic email one. To do so, you need to add these lines to the file /etc/nagios3/commands.cfg :

# 'notify-host-by-foxbox' command definition
define command{
        command_name    notify-host-by-foxbox
        command_line    /usr/lib/nagios/plugins/sendSMS.sh -h "127.0.0.1" -u "nagiosadmin" -pw "nagios" -n "$CONTACTPAGER$" -m "Host Alert: $HOSTNAME$ \nHost State: $HOSTSTATE$ \nDate/Time: $LONGDATETIME$"
        }
# 'notify-service-by-foxbox' command definition
define command{
        command_name    notify-service-by-foxbox
        command_line    /usr/lib/nagios/plugins/sendSMS.sh -h "127.0.0.1" -u "nagiosadmin" -pw "nagios" -n "$CONTACTPAGER$" -m "Service Alert: $HOSTALIAS$/$SERVICEDESC$ \nService State: $SERVICESTATE$ \nDate/Time: $LONGDATETIME$"
        }

As you can see, you need a new information for the contacts: their phone number. Thus, you have to define it as “pager” inside of the file /etc/nagios3/conf.d/contacts_nagios2.cfg .

Moreover, you need to set up the service/host notification command. By default these are using the email channel, while we want to alert with the SMS one, thus you have to edit the parameters “service_notification_commands” and “host_notification_commands” too:

define contact{
        contact_name                    test-contact
        use                             generic-contact
        alias                           tester
        email                           yourname@domain
        host_notification_commands      notify-host-by-foxbox
        service_notification_commands   notify-service-by-foxbox
        pager                           12453683421
        }

#3: Restarting Nagios

The configuration is now complete. Obviously, you have to restart the Nagios service in order to see its effects, using:

/etc/init.d/nagios3 restart

In order to check that everything is ok, maybe you could launch the pre-flight check using:

nagios3 -v /etc/nagios3/nagios.cfg
nagios_integration.txt · Last modified: 2017/05/09 07:26 by admin