Nagios sending notification to a script...

Paul Haygarth pah at campana.com
Wed Jul 6 23:40:37 CEST 2005


Content removed...
 
># "nemir" contact definition
>define contact{
>         contact_name                    nemir
>         alias                           Nemir Nemiria
>         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      notify-by-sms
>         email                           nemri at ex...
>         }
> 
> 
> # "notify-by-sms" command definition
> define command{
>         command_name    notify-by-sms
>         command_line    /usr/local/nagios/send_sms "$NOTIFICATIONTYPE$
with 
> $SERVICEDESC$ at $HOSTADDRESS$ State: $SERVICESTATE$" &&
/usr/bin/printf 
> "%b" "Notification Type: $NOTIFICATIONTYPE$\n\nService:
$SERVICEDESC$\nHost: 
> $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState:
$SERVICESTATE$\n\nDate/Time: 
> $DATETIME$\n\nAdditional Info:\n\n$OUTPUT$" | /usr/bin/mail -s "** 
> $NOTIFICATIONTYPE$ alert - $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$
**" 
> $CONTACTEMAIL$
>         }
> 
> # cat /usr/local/nagios/send_sms
> for x in 6135551416
> do
> echo $1 | /usr/local/bin/gnokii --sendsms $x
> sleep 10
> done
> echo `id -un` `date +%c` $x $1 >> /usr/local/nagios/logs
> 

 

 

I ran into a similar problem, where we were running a script to filter
out certain timeout Alerts, so we wouldn't get excess false
Notifications, during our Network instability.

What I had to do was pipe the information into the script, instead of
using it as a command line variable.  So you could try changing your
stuff to

look like this:

 

# "notify-by-sms" command definition
 define command{
         command_name    notify-by-sms
         command_line    /usr/bin/printf "$NOTIFICATIONTYPE$ with
$SERVICEDESC$ 
 at $HOSTADDRESS$ State: $SERVICESTATE$" | /usr/local/nagios/send_sms &&

 /usr/bin/printf "%b" "Notification Type: $NOTIFICATIONTYPE$\n\nService:

 $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: 
 $SERVICESTATE$\n\nDate/Time: $DATETIME$\n\nAdditional
Info:\n\n$OUTPUT$" | 
 /usr/bin/mail -s "** $NOTIFICATIONTYPE$ alert -
$HOSTALIAS$/$SERVICEDESC$ is 
 $SERVICESTATE$ **" $CONTACTEMAIL$
         }
 
 # cat /usr/local/nagios/send_sms
 read smstxt
 for x in 6135551416
 do
 echo $smstxt | /usr/local/bin/gnokii --sendsms $x
 sleep 10
 done
 echo `id -un` `date +%c` $x $smstxt >> /usr/local/nagios/logs
 
 

 

Paul



 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20050706/4bc81547/attachment.html>


More information about the Users mailing list