How to configure Nagios to send sms to your mobile

Nagios is an open source host, service and network monitoring program. The official homepage is http://nagios.org/, and i use it with cacti to monitor my network.
Nagios sends you an alert via email, sms when a service is down, the sms solution is very usefull when your smtp server is unreachable.
You can drive a GSM mobile by your favorite operating system. With an usb data cable connect it to your monitoring server.
On debian there are a too packages for communicating with mobile phones (gnokii and gsm-utils), at first we’ll use gsm-utils you can get it like:
$ sudo apt-get install gsm-utils
Verify first that your GSM is connected to your server
$ sudo ls -al /dev/ttyUSB*
You can now test it by sending a sms to your mobile number +3299999999.
$ sudo gsmsendsms -d /dev/ttyUSB0 +3299999999 “Nagios – Test SMS OK”
If the test is OK, that mean you will be able to configure nagios to send sms to your phone.
Add a pager to your contact info in /etc/nagios3/conf.d/contacts_nagios2.cfg and set up sms notification mode like:

define contact{
contact_name mezgani
alias Ali MEZGANI
service_notification_period 24×7
host_notification_period 24×7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-service-by-email,notify-service-by-sms
host_notification_commands notify-host-by-email,notify-host-by-sms
email mezgani@secufox.org
pager +329999999999
}

Now you have to define a command, which talks to our sms-notification-software,
so add these lines to your /etc/nagios3/commands.cfg

define command{
command_name notify-service-by-sms
command_line /usr/bin/gsmsendsms -d /dev/ttyUSB0 $CONTACTPAGER$ “Nagios – $NOTIFICATIONTYPE$ : $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ ($OUTPUT$)”
}

define command{
command_name notify-host-by-sms
command_line /usr/bin/gsmsendsms -d /dev/ttyUSB0 $CONTACTPAGER$ “Nagios – $NOTIFICATIONTYPE$ : Host $HOSTALIAS$ is $HOSTSTATE$ ($OUTPUT$)”
}

At this point, you’ve done.
For gnokii users, you can also get it by aptitude as:
$ sudo aptitude install gnokii

Send you a sms test by:
$ echo “Hello world!” | gnokii –sendsms +329999999999 -r

Later, add these lines to your /etc/nagios3/commands.cfg

define command {
command_name notify-service-by-sms
command_line /usr/bin/printf “%.120s” “Nagios – $NOTIFICATIONTYPE$ : $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ ($OUTPUT$)” | /usr/local/bin/gnokii –sendsms $CONTACTPAGER$ -r
}

define command {
command_name notify-host-by-sms
command_line /usr/bin/printf “%.120s” “Nagios – $NOTIFICATIONTYPE$ : Host $HOSTALIAS$ is $HOSTSTATE$ ($OUTPUT$)” | /usr/local/bin/gnokii –sendsms $CONTACTPAGER$ -r
}

Well, i can not get a dedicated GSM for my monitoring server right now, in my country there are some providers that purpose some sms services like sending free sms via web to mobile for example meditel.
in the suite we will focus on how to configure nagios to send sms to meditel mobile via a python script.
If your operators is meditel, get meditelsms package :
$ git clone git://github.com/mezgani/meditelsms.git.
and now add this following lines to your commands.cfg, change the path of your script in our example i used /home/mezgani/script/sms.py

define command{
command_name notify-host-by-sms
command_line /usr/bin/printf “%.120s” “Nagios – $NOTIFICATIONTYPE$ : Host $HOSTALIAS$ is $HOSTSTATE$ ($OUTPUT$)” |/usr/bin/python /home/mezgani/script/sms.py $CONTACTPAGER$
}

define command{
command_name notify-service-by-sms
command_line /usr/bin/printf “%.120s” “Nagios – $NOTIFICATIONTYPE$ : $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ ($OUTPUT$)” |/usr/bin/python /home/mezgani/script/sms.py $CONTACTPAGER$
}

About these ads

69 thoughts on “How to configure Nagios to send sms to your mobile

  1. Hello:

    Can you talk more about the part where you say: “You can drive a GSM mobile by your favorite operating system. With an usb data cable connect it to your monitoring server.”

    Do you have a device connected via a usb cable to the box where nagios is running? If so, what is that device?

    Thanks.
    –Willie

    • Hi Willie,

      First, you need a GSM that support AT-command ’cause gsmtool uses GSM AT-command extensions. and will help you to send and receive SMS messages and others features.
      Currently gsmtool does not support Nokia phones 61xx or similar. These phones do not have a built in modem.
      there are many GSM that support AT-command, and may be you can choose a Siemens GSM AX75, with its data cable DCA-510.
      I did not test it, but apparently it works fine with that software, also most Siemens phone implement AT-command.

  2. Thanks for your response Ali. I will do some research regarding a GSM that supports AT-command. I will look into the Siemens GSM AX75.

    Which one have you tested?

    Thanks.

    • I used another way to send nagios’s notification based on a free sms sending website, but actually I’m looking for a hardware solution maybe i’ll use the Siemens GSM AX75 too, or some Sony Ericsson.

      Regards,

      • Hi!
        First could you explain how to send alerts,using free sms web-services?
        Second,I can’t define name of my Nokia E50-1 connected to my box,there is no device like ttyUSB* in the /dev/,there are only tty*-like devices…But,In that time system successfully found my terminal:
        test-server:~# lsusb|grep Nok
        Bus 001 Device 002: ID 0421:04c9 Nokia Mobile Phones
        ——
        test-server:~# dmesg|tail
        [ 134.948104] usb 1-2: New USB device strings: Mfr=0, Product=1, SerialNumber=0
        [ 134.948104] usb 1-2: Product: VMware Virtual USB Hub
        [ 134.962430] usbcore: registered new interface driver cdc_ether
        [ 134.979565] usb 1-1: bad CDC descriptors
        [ 134.979873] usbcore: registered new interface driver rndis_host
        [ 135.024682] cdc_acm 1-1:1.10: ttyACM0: USB ACM device
        [ 135.037981] usbcore: registered new interface driver cdc_acm
        [ 135.038126] cdc_acm: v0.26:USB Abstract Control Model driver for USB modems and ISDN adapters
        [ 135.092996] usb 1-1: bad CDC descriptors
        [ 135.093182] usbcore: registered new interface driver rndis_wlan
        —-
        So,how to verify name of this device?

        test-server:~# uname -a
        Linux test-server 2.6.26-1-686 #1 SMP Fri Mar 13 18:08:45 UTC 2009 i686 GNU/Linux
        Thanx in advance!

      • Sorry for disturbing!My device known as ttyACM0,I did not observed it,it’s my fault.
        And what about first question:how to send sms via free web-services?

      • Hi,

        Sending sms with nagios is based on the commands.cfg file, that make life easy so you can define a command, which talks to your favorite sms-notification-software or maybe your webservice client.

        in the case of webservice :
        you can use the following, where ws_client is your webservice client.

        define command{
        command_name service-notify-by-sms
        command_line /path/ws_client -q $CONTACTPAGER$ ‘$NOTIFICATIONTYPE$: $HOSTNAME$: $SERVICEDESC$ is $SERVICESTATE$ ($OUTPUT$)’
        }

        define command{
        command_name host-notify-by-sms
        command_line /path/ws_client -q $CONTACTPAGER$ ‘$NOTIFICATIONTYPE$: $HOSTNAME$ is $HOSTSTATE$ ($OUTPUT$)’
        }

        Well ws_client could send notifications via webservice API, you can check a very basic solution based on a free sms sending web site here. http://www.secufox.org/meditelsms.tgz

  3. Ok. I will come back to post my results. I do not know how long this would take me, but I will do it.

    Thanks for your time.
    –Willie

  4. hi gays i traid this configuration still not work with nagios + gnokii

    define command {
    command_name notify-service-by-sms
    command_line /usr/bin/printf “%.120s” “Nagios – $NOTIFICATIONTYPE$ : $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ ($OUTPUT$)” | /usr/local/bin/gnokii –sendsms $CONTACTPAGER$ -r
    }

    define command {
    command_name notify-host-by-sms
    command_line /usr/bin/printf “%.120s” “Nagios – $NOTIFICATIONTYPE$ : Host $HOSTALIAS$ is $HOSTSTATE$ ($OUTPUT$)” | /usr/local/bin/gnokii –sendsms $CONTACTPAGER$ -r
    }

    • Please try first this command, where +329999999999 is you phone number.
      $ echo “Hello world!” | /usr/local/bin/gnokii –sendsms +329999999999 -r

      If that work that mean, you can start using nagios with gnokii.

  5. is not working

    define command {
    command_name notify-service-by-sms
    command_line /usr/bin/printf “%.120s” “Nagios – $NOTIFICATIONTYPE$ : $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ ($OUTPUT$)” | /usr/local/bin/gnokii –sendsms $CONTACTPAGER$ -r
    }

    define command {
    command_name notify-host-by-sms
    command_line /usr/bin/printf “%.120s” “Nagios – $NOTIFICATIONTYPE$ : Host $HOSTALIAS$ is $HOSTSTATE$ ($OUTPUT$)” | /usr/local/bin/gnokii –sendsms $CONTACTPAGER$ -r
    }

  6. It’s working fine
    $ echo “Hello world!” | /usr/local/bin/gnokii –sendsms +329999999999 -r

    but it’s not

    define command {
    command_name notify-service-by-sms
    command_line /usr/bin/printf “%.120s” “Nagios – $NOTIFICATIONTYPE$ : $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ ($OUTPUT$)” | /usr/local/bin/gnokii –sendsms $CONTACTPAGER$ -r
    }

    define command {
    command_name notify-host-by-sms
    command_line /usr/bin/printf “%.120s” “Nagios – $NOTIFICATIONTYPE$ : Host $HOSTALIAS$ is $HOSTSTATE$ ($OUTPUT$)” | /usr/local/bin/gnokii –sendsms $CONTACTPAGER$ -r
    }

    • Great did you set your pager in your contact info in /etc/nagios3/conf.d/contacts_nagios2.cfg like:

      define contact{
      contact_name your_name
      alias alias_name
      service_notification_period 24×7
      host_notification_period 24×7
      service_notification_options w,u,c,r
      host_notification_options d,u,r
      service_notification_commands notify-service-by-email,notify-service-by-sms
      host_notification_commands notify-host-by-email,notify-host-by-sms
      email your_mail
      pager your_phone_number
      }

      If not please do and reload nagios daemon.

  7. Hi there,

    Great how to. Could you help me out? I can send SMS messages manually using: sudo gsmsendsms -d /dev/ttyUSB0 +6421xxxxxxxx “Nagios – Test SMS OK”

    and have defined the SMS command in commands.cfg. I receive emails fine, yet I’m not receiving the SMS message. the event log tells me it’s gone through but never arrives.. Can you point me in the right direction?

    [08-03-2009 23:37:09] SERVICE NOTIFICATION: nagiosadmin;localhost;PING;CUSTOM (OK);notify-service-by-email;PING OK – Packet loss = 0%, RTA = 0.06 ms;Nagios Admin;Hello World
    Service Notification[08-03-2009 23:37:09] SERVICE NOTIFICATION: nagiosadmin;localhost;PING;CUSTOM (OK);notify-service-by-sms;PING OK – Packet loss = 0%, RTA = 0.06 ms;Nagios Admin;Hello World

  8. Hi,
    Great tutorial,

    But i am facing the same situation, not getting any sms from nagios,

    i am using nagios with gnokii..
    =================================
    first i check phone is atached or not by

    [root@app ~]# gnokii –identify
    GNOKII Version 0.6.19
    IMEI : 366882008837174
    Manufacturer : Nokia
    Model : Nokia 7610
    Product name : Nokia 7610
    Revision : V 5.0509.0
    ===================================
    2. second i try to send sms

    [root@app ~]# echo “hello World” | gnokii –sendsms +919910124897
    GNOKII Version 0.6.19
    Send succeeded!
    ===================================
    3. this is mine template.cfg { i have installed by rpm}

    define contact{
    name generic-contact ; The name of this contact template
    service_notification_period 24×7 ; service notifications can be sent anytime
    host_notification_period 24×7 ; host notifications can be sent anytime
    service_notification_options w,u,c,r,f,s ; send notifications for all service states, flapping events, and scheduled downtime events
    host_notification_options d,u,r,f,s ; send notifications for all host states, flapping events, and scheduled downtime events
    service_notification_commands notify-service-by-email,notify-service-by-sms ; send service notifications via email
    host_notification_commands notify-host-by-email,notify-host-by-sms ; send host notifications via email
    register 0 ; DONT REGISTER THIS DEFINITION – ITS NOT A REAL CONTACT, JUST A TEMPLATE!
    }
    ===================================

    4. this is mine contact.cfg

    define contact{
    contact_name nagiosadmin ; Short name of user
    use generic-contact ; Inherit default values from generic-contact template (defined above)
    alias Nagios Admin ; Full name of user

    email amandhally@yahoo.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS *****
    pager +919910124897
    }
    ======================================
    5. then i find gnokii

    [root@app objects]# which gnokii
    /usr/bin/gnokii
    [root@app objects]#

    and printf

    [root@app objects]# which printf
    /usr/bin/printf

    ==================================
    6. and here is mine command.cfg

    define command {
    command_name notify-service-by-sms
    command_line /usr/bin/printf "%.120s" "Nagios – $NOTIFICATIONTYPE$ : $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ ($OUTPUT$)" | /usr/bin/gnokii –sendsms $CONTACTPAGER$ -r
    }

    define command {
    command_name notify-host-by-sms
    command_line /usr/bin/printf "%.120s" "Nagios – $NOTIFICATIONTYPE$ : Host $HOSTALIAS$ is $HOSTSTATE$ ($OUTPUT$)" | /usr/bin/gnokii –sendsms $CONTACTPAGER$ -r
    }

    ===============================

    and i think everything seems fine but i am still not able to get sms . can u please help me i m still not able to find what is wrong…

    Thanks

    Regards
    AMan Dhally

  9. After a bit of investigation… The test event writes the file to the correct location:

    # ‘notify-service-by-sms’ command definition
    define command{
    command_name notify-service-by-sms
    command_line touch /tmp/sms2.txt

    Yet when I attempt to run this command as the NAGIOS user I receive this error:

    $ /usr/bin/gsmsendsms -d /dev/ttyACM0 +6421xxxxxxxx “Nagios”
    /usr/bin/gsmsendsms[ERROR]: opening device ‘/dev/ttyACM0′ (errno: 13/Permission denied)
    $

    The above sommand works fine as a standard user and of course as root.

    Any help would be great as I am tearing my hair out.

    • I think that you miss service_notification_commands and host_notification_commands In your contact.cfg.

      the contact.cfg must be like this:
      define contact{
      contact_name nagiosadmin
      alias nagiosadmin
      service_notification_period 24×7
      host_notification_period 24×7
      service_notification_options w,u,c,r
      host_notification_options d,u,r
      service_notification_commands notify-service-by-email,notify-service-by-sms
      host_notification_commands notify-host-by-email,notify-host-by-sms
      email amandhally@yahoo.com
      pager +919910124897
      }
      Please set your contact file and keep me informed if it work

  10. Hi!

    Can i implement this using CentOS 5.3. I have sony ericsson k700, k 530i.
    It seems that gsm-utils is not available on centos. Can you please give some suggestion.

    Regards.

  11. HI, i edited the command and remove -r and ($OUTPUT$) variable now see the log,I still dont know why the sms not going? any Idea ???

    =================================

    [1250086746.117550] [032.2] [pid=14610] ** Checking host notification viability for contact ‘nagiosadmin’…
    [1250086746.117569] [032.2] [pid=14610] ** Host notification viability for contact ‘nagiosadmin’ PASSED.
    [1250086746.117579] [032.2] [pid=14610] ** Notifying contact ‘nagiosadmin’
    [1250086746.117600] [032.2] [pid=14610] Raw notification command: /usr/bin/printf “%.120s” “Nagios – $NOTIFICATIONTYPE$ : Host $HOSTALIAS$ is $HOSTSTATE$” | /usr/bin/gnokii –sendsms $CONTACTPAGER$
    [1250086746.117630] [032.2] [pid=14610] Processed notification command: /usr/bin/printf “%.120s” “Nagios – PROBLEM : Host Knowleadge web is DOWN” | /usr/bin/gnokii –sendsms +919910124897
    [1250086746.128183] [032.2] [pid=14610] Raw notification command: /usr/bin/printf “%b” “***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n” | /bin/mail -s “** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **” $CONTACTEMAIL$
    [1250086746.128283] [032.2] [pid=14610] Processed notification command: /usr/bin/printf “%b” “***** Nagios *****\n\nNotification Type: PROBLEM\nHost: Knowleadge Web Server\nState: DOWN\nAddress: 192.168.1.45\nInfo: CRITICAL – Host Unreachable (192.168.1.45)\n\nDate/Time: Wed Aug 12 19:49:06 IST 2009\n” | /bin/mail -s “** PROBLEM Host Alert: Knowleadge Web Server is DOWN **” amandhally@yahoo.com
    [1250086746.882526] [032.2] [pid=14610] Calculating next valid notification time…
    [1250086746.882587] [032.2] [pid=14610] Default interval: 30.000000
    [1250086746.882619] [032.2] [pid=14610] Interval used for calculating next valid notification time: 30.000000
    [1250086746.882661] [032.0] [pid=14610] 1 contacts were notified. Next possible notification time: Wed Aug 12 20:19:06 2009
    [1250086746.882675] [032.0] [pid=14610] 1 contacts were notified.

    ==================================

  12. Hello….

    I have had problems setting up nagios with gnokii on debian (3).

    1: In the commands.cfg, the 1st parameter to gnokii MUST be –smssend. That is:

    (echo “blah” | gnokii –smssend +45**** –long 200) works but (echo “blah” | gnokii –long 200 –smssend +45**** ) does not work.

    2. Even though nagios is a member of the group dialout which has access to the device /devttyACM0 it does not work unless unless I give everyone access to the device??

  13. Can someone please let me know what modem they are using. I have tried both gsm-utils and gnokii with a teltonika ModemUSB/G10, with much luck! Any help would be appreciated.

    Thanks in advance.

  14. Hi all

    If you want to use gnokii command use: –sendsms and not –sendsms
    $ echo “Hello world!” | gnokii –sendsms +329999999999 -r
    Then it will work. ;-)

    Marius
    Greenland

    • I found out the problem :-)
      if you write two dash’s (-) (-) on this homepage it will become this –

      You have to write gnokii (-)(-) sendsms
      $ echo “Hello world!” | gnokii (-)(-)sendsms +329999999999 -r
      dash – dash – sendsms and not dash sendsms

  15. Im configuring SMS message for Nagios Notification.

    Can some help how to install
    gsm-utils

    Can someone give a repository for this package?

    Im very thank for your reply.

  16. Hi,

    Can some one give the directory to assign a permission for other user

    I execute this command in Centos 5 terminal give the error.

    [scorpuz@asuka ~]$ gnokii –identify
    GNOKII Version 0.6.0
    Please check permission on lock directory.
    Lock file error. Exiting.

    thanks.

  17. Hi,
    I’m using novatel GPRS modem and gammu. i can send sms frm command prompt. when nagios trigger “notify-sms”, sms are not sending. please help.

    Aslam

  18. Hi, i have about 1000 hosts to monitor, the problem now is that i dont want to be reminded after 3 minuts that a host is down. Im only after up and down alterations. Any ideas? =)

  19. hi guys,

    check your nagios user. nagios is using other user not root so even you config your gnokii and nagios well. the permission for dev/ttyACM0 and dev/bus/usb/* still owns by the root.
    to check your nagios user if it can send sms.

    #su nagios
    then
    echo “123″ | gnokii –sendsms +639162229355

    if not.check the permission for /dev/ttyACM0 it must be owned by nagios or a group which nagios are in.
    also you can change the permission by:

    chown -R nagios:nagios /dev/bus/usb/* chown -R nagios:nagios /dev/ttyACM0
    and
    chmod 750 -R /dev/bus/usb/*
    chmod 750 /dev/ttyACM0

    then try testing it
    goodluck guys

    thanks,
    loy from philippines

  20. Hello,
    I upgraded nagios2 to nagios3 and the sms notifications are not being sent out. But, the mail notifications are being sent.
    Before the upgrade everything was OK.
    In the nagios.log I got this two line:
    [1274637738] SERVICE NOTIFICATION: root;Mail2;HTTP;OK;service-notify-by-sms;HTTP OK: HTTP/1.1 200 OK – 298 bytes in 0.001 second response time
    [1274637738] SERVICE NOTIFICATION: root;Mail2;HTTP;OK;notify-by-email;HTTP OK: HTTP/1.1 200 OK – 298 bytes in 0.001 second response time

    The email is arrived but the SMS not.
    Could someone help me?
    Thanks, Garfy

  21. Hi ,

    If you have the [internal] sms gateway , how one should implement it in nagios for sms alerting?
    suppose the gatway details are like http://eai-k1.org:54456 ,
    what changes i do in commands.cfg , contacts.cfg and many more.???

    OR

    how to implement sms alerting with sms gateway??

    Thanks in advance.

  22. hello Ali, Aman Dhally, and all,

    i’ve followed comments from you until 47th comment, but still got the problem, i can’t get sms from nagios, but i can send sms manually from the command: echo “Hello world!” | gnokii –sendsms +xxxxxxxxxxxxx -r
    i’m using Fully Automated Nagios (FAN) 2.2.

    what else i can do? and where is the location of .gnorkiirc?

    BR,
    Ahmed

  23. New update after 2 years: ATTENTION!!! Make sure you use “gnokii –sendsms” and not “gnokii -sendsms” You need TWO dashes before “sendsms” not ONE!

  24. Good explanation of how to use a GSM modem to send SMS notifications for Nagios alerts.
    A different (non-hardware) option is to use web based services for folks that do not want to deal with installing and maintaining a modem. Of course both approaches have pros and cons.

    We’ve recently implemented support for sending Nagios alerts to iPhone/iPad and Android devices using push notifications (in addition to email and SMS).

    OpsGenie (http://www.opsgenie.com) is offered as a FREE service up to 2 users. How to configure Nagios is described here http://support.opsgenie.com/customer/portal/articles/780193-nagios-integration

  25. Hi,

    I am new to nagios. using my phone i am able to send the sms notification. but some of my sms notification gets fail
    can you please tell me how can i resend the same sms which have been failed.

    Regards
    yogesh

  26. Please add the following to your command-plugings.cfg:
    command[notify-host-by-sms]=/usr/bin/printf “%.120s” “Nagios – $NOTIFICATIONTYPE$ : Host $HOSTALIAS$ is $HOSTSTATE$ ($OUTPUT$)” | /usr/bin/gnokii –sendsms $CONTACTPAGER$ -r
    command[notify-service-by-sms]=/usr/bin/printf “%.120s” “Nagios – $NOTIFICATIONTYPE$ : $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ ($OUTPUT$)” | /usr/bin/gnokii –sendsms $CONTACTPAGER$ -r

  27. hi, i enable the debuging in nagios and got this .

    Host notification viability for contact ‘nagiosadmin’ PASSED.
    [1250077508.128750] [032.2] [pid=9969] ** Notifying contact ‘nagiosadmin’
    [1250077508.128762] [064.1] [pid=9969] Making callbacks (type 27)…
    [1250077508.128775] [064.1] [pid=9969] Making callbacks (type 28)…
    [1250077508.128795] [001.0] [pid=9969] get_raw_command_line()
    [1250077508.128814] [2320.2] [pid=9969] Raw Command Input: /usr/bin/printf “%.120s” “Nagios – $NOTIFICATIONTYPE$ : Host $HOSTALIAS$ is $HOSTSTATE$ ($OUTPUT$)” | /usr/bin/gnokii –sendsms $CONTACTPAGER$ -r
    [1250077508.128828] [2320.2] [pid=9969] Expanded Command Output: /usr/bin/printf “%.120s” “Nagios – $NOTIFICATIONTYPE$ : Host $HOSTALIAS$ is $HOSTSTATE$ ($OUTPUT$)” | /usr/bin/gnokii –sendsms $CONTACTPAGER$ -r
    [1250077508.128838] [032.2] [pid=9969] Raw notification command: /usr/bin/printf “%.120s” “Nagios – $NOTIFICATIONTYPE$ : Host $HOSTALIAS$ is $HOSTSTATE$ ($OUTPUT$)” | /usr/bin/gnokii –sendsms $CONTACTPAGER$ -r
    [1250077508.128850] [001.0] [pid=9969] process_macros()
    [1250077508.128860] [2048.1] [pid=9969] **** BEGIN MACRO PROCESSING ***********
    [1250077508.128869] [2048.1] [pid=9969] Processing: ‘/usr/bin/printf “%.120s” “Nagios – $NOTIFICATIONTYPE$ : Host $HOSTALIAS$ is $HOSTSTATE$ ($OUTPUT$)” | /usr/bin/gnokii –sendsms $CONTACTPAGER$ -r’
    [1250077508.128879] [2048.2] [pid=9969] Processing part: ‘/usr/bin/printf “%.120s” “Nagios – ‘
    [1250077508.128890] [2048.2] [pid=9969] Not currently in macro. Running output (35): ‘/usr/bin/printf “%.120s” “Nagios – ‘
    [1250077508.128900] [2048.2] [pid=9969] Processing part: ‘NOTIFICATIONTYPE’
    [1250077508.128911] [2048.2] [pid=9969] macro_x[29] (NOTIFICATIONTYPE) match.
    [1250077508.128921] [2048.2] [pid=9969] Processed ‘NOTIFICATIONTYPE’, Clean Options: 0, Free: 0
    [1250077508.128932] [2048.2] [pid=9969] Processed ‘NOTIFICATIONTYPE’, Clean Options: 0, Free: 0
    [1250077508.128942] [2048.2] [pid=9969] Cleaning options: global=3, local=0, effective=3
    [1250077508.128959] [2048.2] [pid=9969] Cleaned macro. Running output (43): ‘/usr/bin/printf “%.120s” “Nagios – RECOVERY’
    [1250077508.128974] [2048.2] [pid=9969] Just finished macro. Running output (43): ‘/usr/bin/printf “%.120s” “Nagios – RECOVERY’
    [1250077508.128990] [2048.2] [pid=9969] Processing part: ‘ : Host ‘
    [1250077508.129005] [2048.2] [pid=9969] Not currently in macro. Running output (51): ‘/usr/bin/printf “%.120s” “Nagios – RECOVERY : Host ‘
    [1250077508.129017] [2048.2] [pid=9969] Processing part: ‘HOSTALIAS’
    [1250077508.129028] [2048.2] [pid=9969] macro_x[1] (HOSTALIAS) match.
    [1250077508.129039] [2048.2] [pid=9969] Processed ‘HOSTALIAS’, Clean Options: 0, Free: 1
    [1250077508.129049] [2048.2] [pid=9969] Processed ‘HOSTALIAS’, Clean Options: 0, Free: 1
    [1250077508.129059] [2048.2] [pid=9969] Cleaning options: global=3, local=0, effective=3
    [1250077508.129070] [2048.2] [pid=9969] Cleaned macro. Running output (65): ‘/usr/bin/printf “%.120s” “Nagios – RECOVERY : Host Knowleadge web’
    [1250077508.129081] [2048.2] [pid=9969] Just finished macro. Running output (65): ‘/usr/bin/printf “%.120s” “Nagios – RECOVERY : Host Knowleadge web’
    [1250077508.129091] [2048.2] [pid=9969] Processing part: ‘ is ‘
    [1250077508.129101] [2048.2] [pid=9969] Not currently in macro. Running output (69): ‘/usr/bin/printf “%.120s” “Nagios – RECOVERY : Host Knowleadge web is ‘
    [1250077508.129111] [2048.2] [pid=9969] Processing part: ‘HOSTSTATE’
    [1250077508.129122] [2048.2] [pid=9969] macro_x[26] (HOSTSTATE) match.
    [1250077508.129133] [2048.2] [pid=9969] Processed ‘HOSTSTATE’, Clean Options: 0, Free: 1
    [1250077508.129165] [2048.2] [pid=9969] Processed ‘HOSTSTATE’, Clean Options: 0, Free: 1
    [1250077508.129182] [2048.2] [pid=9969] Cleaning options: global=3, local=0, effective=3
    [1250077508.129198] [2048.2] [pid=9969] Cleaned macro. Running output (71): ‘/usr/bin/printf “%.120s” “Nagios – RECOVERY : Host Knowleadge web is UP’
    [1250077508.129209] [2048.2] [pid=9969] Just finished macro. Running output (71): ‘/usr/bin/printf “%.120s” “Nagios – RECOVERY : Host Knowleadge web is UP’
    [1250077508.129219] [2048.2] [pid=9969] Processing part: ‘ (‘
    [1250077508.129229] [2048.2] [pid=9969] Not currently in macro. Running output (73): ‘/usr/bin/printf “%.120s” “Nagios – RECOVERY : Host Knowleadge web is UP (‘
    [1250077508.129240] [2048.2] [pid=9969] Processing part: ‘OUTPUT’
    [1250077508.129252] [2048.0] [pid=9969] WARNING: Could not find a macro matching ‘OUTPUT’!
    [1250077508.129263] [2048.2] [pid=9969] Processed ‘OUTPUT’, Clean Options: 0, Free: 1
    [1250077508.129273] [2048.0] [pid=9969] WARNING: An error occurred processing macro ‘OUTPUT’!
    [1250077508.129283] [2048.2] [pid=9969] Non-macro. Running output (73): ‘/usr/bin/printf “%.120s” “Nagios – RECOVERY : Host Knowleadge web is UP (‘
    [1250077508.129295] [2048.2] [pid=9969] Processing part: ‘)” | /usr/bin/gnokii –sendsms ‘
    [1250077508.129305] [2048.2] [pid=9969] Not currently in macro. Running output (112): ‘/usr/bin/printf “%.120s” “Nagios – RECOVERY : Host Knowleadge web is UP ($OUTPUT$)” | /usr/bin/gnokii –sendsms ‘
    [1250077508.129316] [2048.2] [pid=9969] Processing part: ‘CONTACTPAGER’
    [1250077508.129328] [2048.2] [pid=9969] macro_x[23] (CONTACTPAGER) match.
    [1250077508.129339] [2048.2] [pid=9969] Processed ‘CONTACTPAGER’, Clean Options: 0, Free: 1
    [1250077508.129349] [2048.2] [pid=9969] Processed ‘CONTACTPAGER’, Clean Options: 0, Free: 1
    [1250077508.129359] [2048.2] [pid=9969] Cleaning options: global=3, local=0, effective=3
    [1250077508.129371] [2048.2] [pid=9969] Cleaned macro. Running output (125): ‘/usr/bin/printf “%.120s” “Nagios – RECOVERY : Host Knowleadge web is UP ($OUTPUT$)” | /usr/bin/gnokii –sendsms +919910124897′
    [1250077508.129381] [2048.2] [pid=9969] Just finished macro. Running output (125): ‘/usr/bin/printf “%.120s” “Nagios – RECOVERY : Host Knowleadge web is UP ($OUTPUT$)” | /usr/bin/gnokii –sendsms +919910124897′
    [1250077508.129391] [2048.2] [pid=9969] Processing part: ‘ -r’
    [1250077508.129402] [2048.2] [pid=9969] Not currently in macro. Running output (129): ‘/usr/bin/printf “%.120s” “Nagios – RECOVERY : Host Knowleadge web is UP ($OUTPUT$)” | /usr/bin/gnokii –sendsms +919910124897 -r’
    [1250077508.129412] [2048.1] [pid=9969] Done. Final output: ‘/usr/bin/printf “%.120s” “Nagios – RECOVERY : Host Knowleadge web is UP ($OUTPUT$)” | /usr/bin/gnokii –sendsms +919910124897 -r’
    [1250077508.129422] [2048.1] [pid=9969] **** END MACRO PROCESSING *************
    [1250077508.129432] [032.2] [pid=9969] Processed notification command: /usr/bin/printf “%.120s” “Nagios – RECOVERY : Host Knowleadge web is UP ($OUTPUT$)” | /usr/bin/gnokii –sendsms +919910123883 -r
    [1250077508.129445] [001.0] [pid=9969] process_macros()
    [1250077508.129455] [2048.1] [pid=9969] **** BEGIN MACRO PROCESSING ***********
    [1250077508.129464] [2048.1] [pid=9969] Processing: ‘HOST NOTIFICATION: nagiosadmin;Knowleadge Web Server;$HOSTSTATE$;notify-host-by-sms;$HOSTOUTPUT$

    [1250077508.129474] [2048.2] [pid=9969] Processing part: ‘HOST NOTIFICATION: nagiosadmin;Knowleadge Web Server;’
    [1250077508.129485] [2048.2] [pid=9969] Not currently in macro. Running output (53): ‘HOST NOTIFICATION: nagiosadmin;Knowleadge Web Server;’
    [1250077508.129501] [2048.2] [pid=9969] Processing part: ‘HOSTSTATE’
    [1250077508.129512] [2048.2] [pid=9969] macro_x[26] (HOSTSTATE) match.
    [1250077508.129522] [2048.2] [pid=9969] Processed ‘HOSTSTATE’, Clean Options: 0, Free: 1
    [1250077508.129532] [2048.2] [pid=9969] Processed ‘HOSTSTATE’, Clean Options: 0, Free: 1
    [1250077508.129542] [2048.2] [pid=9969] Cleaning options: global=0, local=0, effective=0
    [1250077508.129567] [2048.2] [pid=9969] Uncleaned macro. Running output (55): ‘HOST NOTIFICATION: nagiosadmin;Knowleadge Web Server;UP’
    [1250077508.129578] [2048.2] [pid=9969] Just finished macro. Running output (55): ‘HOST NOTIFICATION: nagiosadmin;Knowleadge Web Server;UP’
    [1250077508.129588] [2048.2] [pid=9969] Processing part: ‘;notify-host-by-sms;’
    [1250077508.129598] [2048.2] [pid=9969] Not currently in macro. Running output (75): ‘HOST NOTIFICATION: nagiosadmin;Knowleadge Web Server;UP;notify-host-by-sms;’
    [1250077508.129609] [2048.2] [pid=9969] Processing part: ‘HOSTOUTPUT’
    [1250077508.129619] [2048.2] [pid=9969] macro_x[16] (HOSTOUTPUT) match.
    [1250077508.129630] [2048.2] [pid=9969] New clean options: 3
    [1250077508.129640] [2048.2] [pid=9969] Processed ‘HOSTOUTPUT’, Clean Options: 3, Free: 1
    [1250077508.129650] [2048.2] [pid=9969] Processed ‘HOSTOUTPUT’, Clean Options: 3, Free: 1
    [1250077508.129660] [2048.2] [pid=9969] Cleaning options: global=0, local=3, effective=3
    [1250077508.129672] [2048.2] [pid=9969] Cleaned macro. Running output (116): ‘HOST NOTIFICATION: nagiosadmin;Knowleadge Web Server;UP;notify-host-by-sms;PING OK – Packet loss = 0%, RTA = 0.94 ms’
    [1250077508.129683] [2048.2] [pid=9969] Just finished macro. Running output (116): ‘HOST NOTIFICATION: nagiosadmin;Knowleadge Web Server;UP;notify-host-by-sms;PING OK – Packet loss = 0%, RTA = 0.94 ms’
    [1250077508.129693] [2048.2] [pid=9969] Processing part: ‘

    [1250077508.129703] [2048.2] [pid=9969] Not currently in macro. Running output (117): ‘HOST NOTIFICATION: nagiosadmin;Knowleadge Web Server;UP;notify-host-by-sms;PING OK – Packet loss = 0%, RTA = 0.94 ms

    [1250077508.129715] [2048.1] [pid=9969] Done. Final output: ‘HOST NOTIFICATION: nagiosadmin;Knowleadge Web Server;UP;notify-host-by-sms;PING OK – Packet loss = 0%, RTA = 0.94 ms

    [1250077508.129724] [2048.1] [pid=9969] **** END MACRO PROCESSING *************
    [1250077508.129800] [064.1] [pid=9969] Making callbacks (type 9)…
    [1250077508.129813] [001.0] [pid=9969] my_system()
    [1250077508.129823] [256.1] [pid=9969] Running command ‘/usr/bin/printf “%.120s” “Nagios – RECOVERY : Host Knowleadge web is UP ($OUTPUT$)” | /usr/bin/gnokii –sendsms +919910124897 -r’…
    [1250077508.129902] [064.1] [pid=9969] Making callbacks (type 10)…
    [1250077508.130937] [001.0] [pid=10783] process_macros()
    [1250077508.130989] [001.0] [pid=10783] process_macros()
    [1250077508.131006] [001.0] [pid=10783] process_macros()
    [1250077508.131306] [001.0] [pid=10783] process_macros()
    [1250077508.131325] [001.0] [pid=10783] process_macros()
    [1250077508.131343] [001.0] [pid=10783] process_macros()
    [1250077508.141244] [256.1] [pid=9969] Execution time=0.011 sec, early timeout=0, result=2, output=(null)

  28. That could refer to a permission problem, please check permissions on your device, find out the owner and group of your /dev/ttyACM0 or may be /dev/ttyUSB0 ,
    and add nagios in that group.

  29. Hi ALI,

    Sorry for reply late,
    I saw that /dev/ttyACM0
    ————————————

    [root@app ~]# ls -l /dev/ttyACM0
    crw-rw—- 1 root uucp 166, 0 Aug 18 10:57 /dev/ttyACM0
    ————————————-
    Then I add Nagios and Nagios admin to the Group uucp

    [root@app ~]# cat /etc/group | grep uucp
    uucp:x:14:uucp,nagios,nagiosadmin
    ———————————–

    Still the problem is same, I am using CentOs 5,

    Now what else we can check and do ?

    Thanks

    Aman Dhally

  30. [ S O L V E D ] [ T O D A Y ]
    [ Finally It IS Working ]

    Hi Daniel,

    I just solved mine problem [ 5 minutes ago] after a long chase with Mr. Ali and Nagios Groups ..

    You just need to copy you working .gnokiirc to /etc/gnokiirc
    [ cp .gnokiirc /etc/gnokiirc ]

    and make sure nagios is member of uucp group

    [usermod -a -G uucp nagios]

    and after that it will work …

    and if work please let me know :)

    Regards

    Thanks a lot Ali :) and Nagios Group
    Aman Dhally
    amandhally@gmail.com

  31. Hello, Solution for me was the following:

    I had in command this in the beginning: /usr/bin/printf “%.120s” “Nagios – $NOTIFICATIONTYPE$ : Host $HOSTALIAS$ is $HOSTSTATE$ ($OUTPUT$)” | /usr/bin/gnokii –sendsms $CONTACTPAGER$ -r

    And removed “%.120s”
    After that it was working.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s