Nagios sending notification to a script...

Marc Powell marc at ena.com
Tue Apr 19 21:23:45 CEST 2005



> -----Original Message-----
> From: nagios-users-admin at lists.sourceforge.net [mailto:nagios-users-
> admin at lists.sourceforge.net] On Behalf Of nemir nemiria
> Sent: Tuesday, April 19, 2005 12:20 PM
> To: nagios-users at lists.sourceforge.net
> Subject: [Nagios-users] Nagios sending notification to a script...
> 

[contact definition removed]

> # '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
> 
> 
> 
> The plan is that it sends out an email to me and an sms to the
everyone in
> the team in case of an alert.   I upgraded a couple of weeks back and
now
> it
> doesn't send this sms, though the email is functioning just fine.
> 
> I log in as nagios and use the script and it works perfectly.   The
logs
> indicate that nagios sent the string to the script correctly (see
below),
> just for some reason when the nagios daemon sends the alert to the
script
> it
> deoesn't want to send the sms.
> 
> I cleared the log and then tripped the alerts by shutting down one of
my
> DNS
> services.  Note that the last two lines are repeated with different
times.
> The first two sent no sms, the second was sent by me as the nagios
user
> using the same command as the nagios notification would have sent to
the
> script.  You can see they produce exactly the same entry in the log,
but
> the command line use of the script successfully sends the sms.
> 
> 
> nagios Wed 20 Apr 2005 01:56:04 EST 6135551416 PROBLEM with DNS at
> 202.138.213.100 State: CRITICAL
> nagios Wed 20 Apr 2005 02:15:54 EST 6135551416 RECOVERY with DNS at
> 202.138.213.100 State: OK
> nagios Wed 20 Apr 2005 02:18:02 EST 6135551416 RECOVERY with DNS at
> 202.138.213.100 State: OK
> 
> 
> I can't think of how I can isolate this further.. And so I can't see
what
> to
> do next to try to resolve the porblem.

Well, it seems clear that the nagios part is working correctly. You _do_
get the email that is the second half of your notification script and it
does appear to be passing the correct information to your send_sms
script as it gets logged at the end. That would imply that the failure
is somewhere in your for...done loop. The loop itself seems to be
unnecessary as there is only one phone number but other than that it's
pretty generic leaving the echo to gnokii as the next most likely
culprit.

I would try two things... enclose the argument to echo in quotes --

echo "$1" | /usr/local/bin/gnokii --sendsms $x

and/or see if gnokii is spitting out anything interesting --

echo $1 | /usr/local/bin/gnokii --sendsms $x >/tmp/gnokii.log 2>&1

--
Marc


-------------------------------------------------------
This SF.Net email is sponsored by: New Crystal Reports XI.
Version 11 adds new functionality designed to reduce time involved in
creating, integrating, and deploying reporting solutions. Free runtime info,
new features, or free trial, at: http://www.businessobjects.com/devxi/728
_______________________________________________
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