personalize notification commands

Philipp Geschke nagios at pgmail.net
Fri Jul 4 15:58:49 CEST 2008


Hello,

Nelson Serafica schrieb:
> I want to set nagios to send a txt message if there is a down or 
> critical status. I setup a nagios for testing to another box instead of 
> playing in the stable nagios that was runnin. I already have email 
> notification but sometimes I don't open my email in midnight so I need 
> an alert ans I choose sms. I have an officemate who have a linux box and 
> setup a url where if I visit the url it will send a txt message. Here is 
> the sample url:
> 
> http://x.x.x.x/testserver?page=sms_sendsmsmessage&multi_recipients=+123456789&smsmessage=testing&username=nagios&NOEXPIRE
> 
> 123456789 = sms contact number
> testing = message of the sms
> 
> Now, I have setup in commands.cfg the ff:
> 
> define command{
>         command_name    notify-by-txt
>         command_line    /usr/bin/printf "%b" "Service: 
> $SERVICEDESC$\nHost: $HOSTNAME$\nAddress: $HOSTADDRESS$\nState: 
> $SERVICESTATE$\nInfo: $SERVICE
> OUTPUT$\nDate: $LONGDATETIME$" |/usr/bin/links 
> "http://x.x.x.x/testserver?page=sms_sendsmsmessage&multi_recipients=+123456789&smsmessage=$HOSTNAME&&username=nagios&NOEXPIRE 
> &"
>         }
> 
> Then I set my contacts.cfg
> 
> define contact{
>         contact_name                    nagios-admin
>         alias                           Nagios Admin
>         service_notification_period     24x7
>         host_notification_period        24x7
>         service_notification_options    w,u,c,r
>         host_notification_options       d,r
>         service_notification_commands   notify-by-txt
>         host_notification_commands      notify-by-txt
>         pager                           
> http://x.x.x.x/testserver?page=sms_sendsmsmessage&multi_recipients=+123456789&smsmessage=testing&username=nagios&NOEXPIRE
>         }
> 
> I see the logs in nagios the notify-by-txt but I don't receive a sms 
> message. But when I command it via shell, I receive a sms message.
> 
> Could someone direct me to right commands in notification commands? Can 
> I set a sample script just to test notification commands?

You could try to use a debug wrapper script, that will log, what nagios actually executes.
Something close to this should do:

#!/bin/sh
echo `date` >> /tmp/plugin_debugger
echo $* >>  /tmp/plugin_debugger

Not sure this will work, please try yourself.
By executing this as the notification command it should log what actually was executed by nagios.
That way you can see, if nagios fills your macros with the correct information.

Also make sure that you run your shell tests as the nagios user, not as root.


Regards,
Philipp

-------------------------------------------------------------------------
Sponsored by: SourceForge.net Community Choice Awards: VOTE NOW!
Studies have shown that voting for your favorite open source project,
along with a healthy diet, reduces your potential for chronic lameness
and boredom. Vote Now at http://www.sourceforge.net/community/cca08
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null





More information about the Users mailing list