nagios with sms notification

so finaly I finished seting up nagios on my server to monitor themselves and in case of a problem send me an SMS.
I found a plugin to send the sms on the nagios exchange site but that didn't quite work out of the box.
First problem is that the URL creation will never work, the URL for the message is created before the session id is assigned to the variable, this can't work! The second problem is that the message is sent "as is" for example "Server xy is down" this won't work either! The text has to be url_encoded ( in php, or uri_encode in perl ) so I created a patch which you can download here.
Then the description of the usage on the site is not correct 

define command{
command_name service_notify_with_sms
command_line /usr/lib/nagios/plugins/notify_sms -a 1012345 -u myusername_for_gw -p mypassword_for_gw -m '$NOTIFICATIONTYPE$: $HOSTNAME$ is $SERVICESTATE$ ($SERVICEOUTPUT$)' -t $CONTACTPAGER$
}

It should be $OUTPUT$ and not $SERVICEOUTPUT$ but this was the rather minor problem.

Comments

  1. Gravatar
    Jeremy Jackson
    August 27th, 2007 | 19:12

    The version 1.1 on nagiosexchange.org:

    -puts username/password on commandline where any logged in user can see it,
    -Clickatell API has an option to authenticate for each message, instead of opening a session, which only requires 1 HTTP request. I’ll try it out.

  2. Gravatar
    March 4th, 2008 | 10:59
  3. Gravatar
    March 5th, 2008 | 7:55

    “Clickatell API has an option to authenticate for each message, instead of opening a session, which only requires 1 HTTP request. I’ll try it out.” — how is the procedure for these? Im having a hard time configuring my nagios for clickatell.. Please help. Thanks!!

  4. Gravatar
    March 5th, 2008 | 9:40

    Not sure, I am using it with authentication when sending each message since I don’t have users on my system so I don’t really care about password showing :)

  5. Gravatar
    March 6th, 2008 | 11:11

    You sent an alert without using those plugins check this url http://www.gnu.org/software/wget/manual/html_node/HTTP-Options.html
    from their example: http://api.clickatell.com/http/sendmsg?user=xxxxx&password=xxxxx&api_id=xxxxx&to=448311234567&text=Meet+me+at+home you can simply replace xxxx item with information you got and do this to your command config:

    define command{
    command_name service_notify_with_sms
    command_line wget –post-data “user=myusername&password=mypassword$api_id=XXXXXXX&to=’$NOTIFICATIONTYPE$: $HOSTNAME$ is $SERVICESTATE$ ($SERVICEOUTPUT$)’ -t $CONTACTPAGER$
    }

    I HOPE THIS COULD HELP!! :D

  6. Gravatar
    March 6th, 2008 | 11:14

    Sorry but this is the right command:

    # clickatell alert ‘host-notify-by-sms’ command definition
    define command{
    command_name host_notify_with_sms
    command_line wget –post-data “user=myusername&password=mypassword&api_id=xxxxxx&to=$CONTACTPAGER$&text= -m ‘$NOTIFICATION$ $HOSTNAME$ is $HOSTSTATE$ ($HOSTOUTPUT$)’” http://api.clickatell.com/http/sendmsg
    }

    ENJOY!!

  7. Gravatar
    iknewitalready
    June 5th, 2008 | 5:46

    Hi cristian!
    can you tell me how can i apply your patch? should i replace some text in the old notify_sms or what?
    Would be really thankful to you… also my email address is iknewitalready@gmail.com, i would be really greatful if you could add me (on msn, google talk, and on yahoo its iknewit_already) i need a little guidance…

  8. Gravatar
    June 5th, 2008 | 8:18

    You can download the complete patched file here: http://livadaru.net/cristian/downloads/notify_sms

  9. Gravatar
    iknewitalready
    June 26th, 2008 | 5:14

    What are the correct “define command”s for the service and host?

Leave a reply

Powered by WP Hashcash