Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have configured nagios SMS alert and it takes around one minute to send notification. I want to get SMS notification withing one/two second(s) after system/service failure. I could not find any way to send sms alert in a second. Can anybody help me???

Update Wednesday, 29 August 9:26:43 a.m GMT

define host{
    use                     generic-host            ; Name of host template to use
    host_name               localhost
    alias                   localhost
    address                 x.x.x.187
    check_command           check-host-alive
    normal_check_interval   1
    max_check_attempts      1
    retry_interval          1
    notification_interval   120
    notification_period     24x7
    notification_options    d,r
    contact_groups  admins
    }

New

I have configured sms with gammu-smsd. gammu-smsd configuration has been given below:

#vi /etc/gammu-smsdrc

 # Configuration file for Gammu SMS Daemon

 # Gammu library configuration, see gammurc(5)
[gammu]
 # Please configure this!
port = /dev/ttyACM0
connection = bluephonet
 # Debugging
logformat = textall

 # SMSD configuration, see gammu-smsdrc(5)
[smsd]
service = files
 #logfile = syslog
logfile = /var/log/gammu-smsd

 # Increase for debugging information
debuglevel = 0

 # Paths where messages are stored
inboxpath = /var/spool/gammu/inbox/
outboxpath = /var/spool/gammu/outbox/
sentsmspath = /var/spool/gammu/sent/

Contact:

#vi /etc/nagios3/conf.d/contacts_nagios2.cfg
 define contact{
         contact_name                    localhost
         alias                           localhost 
         service_notification_period     24x7
         host_notification_period        24x7
         service_notification_options    w,u,c,r
         host_notification_options       d,r
         service_notification_commands   notify-service-by-sms
         host_notification_commands      notify-host-by-sms
         pager                           +88xxxxxxxxxxx
 }
 define contactgroup{
         contactgroup_name       admins
         alias                   Nagios Administrators
         members                 localhost
 }

 #vi /etc/nagios3/conf.d/services_nagios2.cfg
 define service{
         use                             generic-service         
         host_name                       localhost
         service_description             SSH
         is_volatile                     0
         check_period                    24x7
         max_check_attempts              4
         normal_check_interval           5
         retry_check_interval            1
         contact_groups                  admins
         notification_interval           960
         notification_period             24x7
         check_command                   check_ssh
  }

Command:

define command{
        command_name    notify-host-by-sms
        command_line    /usr/bin/printf "%b" "Alert $HOSTNAME$ is $HOSTSTATE$" | /usr/bin/gammu --sendsms TEXT $CONTACTPAGER$

        }

define command{
        command_name    notify-service-by-sms
        command_line    /usr/bin/printf "%b" "Alert service $SERVICEDESC$ on $HOSTNAME$" is $SERVICESTATE$ | /usr/bin/gammu --sendsms TEXT $CONTACTPAGER$

        }

Log:

 #vi/var/log/gammu-smsd

    Wed 2012/08/29 16:00:30 gammu-smsd[927]: Error at init connection: Function not supported by phone. (NOTSUPPORTED[21])
    Wed 2012/08/29 16:00:30 gammu-smsd[927]: Going to 30 seconds sleep because of too much connection errors
    Wed 2012/08/29 16:01:00 gammu-smsd[927]: Starting phone communication...


#vi /var/log/nagios3/nagios.log



 [Wed Aug 29 15:59:34 2012] SERVICE NOTIFICATION: localhost;localhost;SSH;OK;notify-service-by-sms;SSH OK - OpenSSH_5.9p1 Debian-5ubuntu1 (protocol 2.0)
[Wed Aug 29 16:00:42 2012] SERVICE ALERT: localhost;SSH;CRITICAL;SOFT;1;Connection refused
[Wed Aug 29 16:00:52 2012] SERVICE ALERT: localhost;SSH;CRITICAL;SOFT;2;Connection refused
[Wed Aug 29 16:01:02 2012] SERVICE ALERT: localhost;SSH;CRITICAL;SOFT;3;Connection refused
[Wed Aug 29 16:01:12 2012] SERVICE ALERT: localhost;SSH;CRITICAL;HARD;4;Connection refused
[Wed Aug 29 16:01:12 2012] SERVICE NOTIFICATION: localhost;localhost;SSH;CRITICAL;notify-service-by-email;Connection refused
[Wed Aug 29 16:01:19 2012] SERVICE NOTIFICATION: localhost;localhost;SSH;CRITICA
share|improve this question
    
Without configuration files, how can we help? –  quanta Aug 29 '12 at 7:59
1  
grep ^interval_length /path/to/nagios.cfg? –  quanta Aug 29 '12 at 8:08
    
interval_length=1s –  Jerry Aug 29 '12 at 8:10
    
"1s" or just "1"? –  quanta Aug 29 '12 at 8:11
2  
You haven't even told us the mechanism used to send the SMS messages. Do you have an internal system? Do you send via an external provider, in which case the delay may be through them? etc. You really need to give us something to work with. –  John Gardeniers Aug 29 '12 at 9:34

2 Answers 2

up vote 1 down vote accepted

Convert nagios.log timestamp to a human-readable format:

perl -pe 's/(\d+)/localtime($1)/e' nagios.log

[Wed Aug 29 16:58:30 2012] SERVICE ALERT: localhost;SSH;CRITICAL;HARD;4;Connection refused
[Wed Aug 29 16:58:30 2012] SERVICE NOTIFICATION: localhost;localhost;SSH;CRITICAL;notify-service-by-email;Connection refused
[Wed Aug 29 16:58:38 2012] SERVICE NOTIFICATION: localhost;localhost;SSH;CRITICAL;notify-service-by-sms;Connection refused

You can see that it send an email notification immediately and takes only... 8 seconds to send a SMS. The delay (as @John Gardeniers pointed out) is in your SMS system, not Nagios.

share|improve this answer
    
thanks, I have visited list of phones supported by Gammu library. my phone was included in that list. How can I choose a perfect phone which will not create any problem. you can suggest me any other options. My company asked me that which phone should they buy for this SMS notification purpose?? –  Jerry Aug 29 '12 at 10:55
    
look for it with google. planty of answer when I tried it –  Anarko_Bizounours Aug 29 '12 at 13:22

With gammu-smsd running you cant use "gammu --sendsms" you need to use gammu-smsd-inject. You need something like this

define command{
        command_name    notify-host-by-sms
        command_line    /usr/bin/gammu-smsd-inject TEXT $CONTACTPAGER$ -text "Alert $HOSTNAME$ is $HOSTSTATE$"
        }

define command{
        command_name    notify-service-by-sms
        command_line    /usr/bin/gammu-smsd-inject TEXT $CONTACTPAGER$ -text "Alert service $SERVICEDESC$ on $HOSTNAME$ is $SERVICESTATE$"
        }
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.