What am i doing wrong?


#1

Hello…

I have written a perl script and droped it into /usr/bin/ and named it nag_sms which is a script i have written to send data to our sms text server.

I have added the following to the miscommands.cfg

‘host-notify-by-sms’ command definition

define command{
command_name host-notify-by-sms
command_line usr/bin/nag_sms ‘$HOSTNAME$’ ‘$HOSTSTATE$’ ‘$HOSTADDRESS$’ ‘$CONTACTEMAIL$’ ‘$DATETIME$’

}

‘notify-by-sms’ command definition

define command{
command_name notify-by-sms
command_line usr/bin/nag_sms ‘$HOSTNAME$’ ‘$HOSTSTATE$’ ‘$HOSTADDRESS$’ ‘$CONTACTEMAIL$’ ‘$DATETIME$’

}

I have added the following to the contacts.cfg

‘Flandercan’ contact definition

define contact{
contact_name flanderp_sms
alias flanderp_sms
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-by-sms
host_notification_commands host-notify-by-sms
email
}

i have then added flanderp_sms to the admin group and when i watch the log file i see the following

[1109003952] SERVICE NOTIFICATION: flanderp_sms;ned-linux;PING;OK;notify-by-sms;PING OK - Packet loss = 0%, RTA = 0.36 ms

The command seems to run perfect, however it doesnt actually run the script.

If from the command line i type

usr/bin/nag_sms ‘$HOSTNAME$’ ‘$HOSTSTATE$’ ‘$HOSTADDRESS$’ ‘$CONTACTEMAIL$’ ‘$DATETIME$’

The script runs and does what it should

where have i gone wrong

any help much appres

thanks
Paul


#2

are the permissions correctly for the nagios user to run the script?
try su - nagios and try running it again.

Luca


#3

Thanks for replying.

Yes that works fine, nagios user does have permision to execute the script.

Thanks
Paul


#4

Change
command_line usr/bin/nag_sms
to command_line /usr/bin/nag_sms
is all I can see.


#5

I have a similar problem with my nagios installation. Did you eventually find a solution to your sms notifications problem?


#6

As stated previously, the definition in misccommands.cfg is wrong.
define command{
command_name host-notify-by-sms
command_line usr/bin/nag_sms ‘$HOSTNAME$’ ‘$HOSTSTATE$’ ‘$HOSTADDRESS$’ ‘$CONTACTEMAIL$’ '$DATETIME$'
should be
command_line /usr/bin/nag_sms ‘$HOSTNAME$’ ‘$HOSTSTATE$’ ‘$HOSTADDRESS$’ ‘$CONTACTEMAIL$’ ‘$DATETIME$’

I would also think that if he ran /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg that it would actually tell him, that this may be a problem.