How to execute script instead of alert mail

hi,

I want to execute a perl script that will send sms alert to me instead of alert mails which are working fine.Taken following steps but no avail yet:

  1. updated contacts.cfg to include my pager:

define contact{ contact_name nadmin use generic-contact alias Nagios Admin email [email protected] pager 99xxx5247 # just hidden here }

  1. updated commands.cfg to include notification by sms but script didnt get called, even updated the notify-service-by-email to include my script instead of sending mails but not working. At last I am trying this to echo message to a temporary file:

[code]define command{
command_name notify-service-by-email
command_line /bin/echo “***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$” > tmp.txt
}

define command{
command_name notify-host-by-email
command_line /bin/echo “***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n” > tmp.txt
}
[/code]

It’s also not working. I’m just in need to call 'alertsms.pl $contactnumber$ $message$" script whenever there’s any status change in Nagios. Please let me know how should I proceed.

Regards,
JC

Help me understand what you are trying to do with the code you posted. I see you defined a number under ‘pager’ this will appear as $CONTACTPAGER$ in your command. This means that your command MUST be able to handle a phone number.

It might be easier to simply replace the email with your phone email ie [email protected] (whatever it is)

Maybe this link will help: nagios.sourceforge.net/docs/2_0/ … ntactpager


Stephen P. Luke
Sales Engineer
TruePath Technologies Inc.
Phone: 585-672-5481
Email: [email protected]