Nagios 3.x.x/Icinga 1.x.x Server Integration For SMS Alerts Via FoxBox Devices On Debian Squeeze

This tutorial explains how to integrate a standard Nagios (or Icinga) monitoring server with an SMS notification external device, the FoxBox (


1 Preliminary note

FoxBox, as stated by manufacturers, comes in two similar versions (G25 and LX800) differing on hardware specifics. In this guide we will refer to SMS Gateway LX800 (we bought this one because of its higher performance, and the CompactFlash storage), but I am confident that it could be extended to other versions without problems.

Our server runs the Nagios Core 3.5.0 (with 1.4.16 Nagios plugins) on a Debian Squeeze. Probably for different distros the paths will change, but the logic remains petty much the same.


2 Installation on the FoxBox side

The device is designed for these kind of communication tasks, so there is not much to do here except:

  • Provide a valid IP address, reachable from our monitoring server;
  • Insert a tested and full working SIM card, to send the SMS.


3 Installation on the Server side

First of all we need to place this script inside of the folder /usr/lib/nagios/plugins/:

use LWP::UserAgent;
use Getopt::Long;
use strict;
use warnings;
use constant OK => 0;
use constant WARNING => 1;
use constant CRITICAL => 2;
use constant UNKNOWN => 3;
use constant SEND_PAGE => "/source/send_sms.php";
sub usage() {
    print("Usage: send_sms -h|--host <host> -u|--user <username> --pw|--pass
<password> -n|--number
<phone_number> -m|--message <message>\n\n");
    print("<host> - IP address or hostname of the SMS FoxBox\n");
    print("<username> - name of the SMS FoxBox administrator\n");
<password> - password of the SMS FoxBox administrator\n");
<phone_number> - phone number where SMS will be sent\n");
    print("<message> - message to be sent\n");
sub send_sms {
    my($host, $user, $pass, $phonenum, $text) = @_;
    $ua = LWP::UserAgent-&gt;new;
    $response = $ua-&gt;post("http://$host" . SEND_PAGE,
                    "username" =&gt; $user,
                    "pwd" =&gt; $pass,
                    "from" =&gt; 'Nagios',
                    "nphone" =&gt; $phonenum,
                    "testo" =&gt; $text,
                    "nc" =&gt; "http://$host" . SEND_PAGE
    if(!$response-&gt;is_success) {
        print("ERROR: " . $response-&gt;status_line . "\n");
        $status_code = UNKNOWN;
    $html_page =  $response-&gt;content;
    if($html_page =~ /p class="(\w+)"/g) {
        if($1 eq "confneg") {
            print("ERROR: Unable to send SMS\n");
            $status_code = UNKNOWN;
        else {
            $status_code = OK;
    else {
        print("ERROR: Unknown page output\n");
        $status_code = UNKNOWN;
    return $status_code;
undef $host;
undef $username;
undef $password;
undef $number;
undef $message;
GetOptions(    'host|H=s'    =&gt; \$host,
        'user|u=s'     =&gt; \$username,
        'pass|pw=s'     =&gt; \$password,
        'number|n=s'     =&gt; \$number,
        'message|m=s'     =&gt; \$message);
if(!defined $host || !defined $username || !defined $password || !defined $number || !defined $message) {

$message =~ s/\\n/\n/g;
$ret_status = send_sms($host, $username, $password, $number, $message);

It is also important to set properly the permissions on this file, to allow the Nagios user executing it.

Now we should add the new notification commands, working on the SMS channel instead of the classic email one. To do so, we have 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/ -h "" -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/ -h "" -u "nagiosadmin" -pw "nagios" -n "$CONTACTPAGER$" -m "Service Alert: $HOSTALIAS$/$SERVICEDESC$ \nService State: $SERVICESTATE$ \nDate/Time: $LONGDATETIME$"

As you can see, we need a new information for the contacts: the phone number. Thus, we have to define it as "pager" in the file /etc/nagios3/conf.d/contacts_nagios2.cfg.

Moreover, we set up the service/host notification command. By default these are using the email channel, while we want to alert with the new notification commands, so we 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                           [email protected]
        host_notification_commands      notify-host-by-foxbox
        service_notification_commands   notify-service-by-foxbox
        pager                           12453683421

Obviously, once finished the configurations we have to restart the Nagios service in order to see their effects.

To check that everything is ok, maybe you could launch the pre-flight check with

nagios3 -v /etc/nagios3/nagios.cfg

As I see, this architecture has also been implemented on a pair of FoxBox versions, providing an all-in-one notification solution (EasyG2 G25 and Monitoring LX800).


Share this page:

Suggested articles

6 Comment(s)

Add comment



Alternative and cheaper way, is to use gnokii and old Nokia phone.
Nagios can execute any php script over network, that's meant Nagios can add data (like alert info) to mysql database, next step i to read that data by script and send info by sms.


you are right that this solution is cheaper, but as a company we cannot install in our production environment a system based on an old Nokia phone (or something similar), mainly for reliability reasons.
Moreover, FoxBox is much more powerful and flexible of a common phone (being a full Debian device), giving us the possibility of executing additional processing, thus in our case our solution is more efficient than yours.
Anyway, thanks for the hint ;)



I wish to have  solution like FoxBox, but all is always about tha money. In small company with small IT budget, are always promoted cheap or free solutions. Typical phone with gnooki can receiving and sending sms, rest is on Linux and scripts side (your skills and ideas) , so I bet that these solutions are quite similar in work ;)
There is difference ofcourse, FoxBox is more professional than typical phone and some custom scripts ;)




I don't want to seem a lazy one, but in my (small) company we decided to buy an out-of-the-box solution because it's not just a matter of your skills and ideas, but also your time.

I mean, developing from scratch a stable system similar to FoxBox would surely take some week full-time, for an expert employee... And this is a cost too! :D

By: Jeff

These configurations are hectic and sometimes they dont work. The best is to try Nagios SMS alert. It sends out SMS text message to you whenever you get email from nagios. Its fast and works in more than 200 counties. Try it.

By: steve

Je ne parviens pas à faire communiquer mon foxbox avec nagios, besoin d'aide s'il vous plait

Sur le manuel d'utilisation on demande de saisir FoxBox_IP/nagios3, mais ça me renvois l'erreur 404 (NOT FOUND The URL requested is not found on this server. Apache /2.41(Debian) FoxBox_IP