Acknowledging alerts with SMS.

nagios at mm.quex.org nagios at mm.quex.org
Thu Oct 21 07:44:14 CEST 2004


On Wed, Oct 20, 2004 at 02:14:00PM -0700, Jason Martin wrote:
> On Wed, Oct 20, 2004 at 01:53:51PM -0700, John David wrote:
>> anyone else out there know if an external command
>> exists for acknowledging a problem?  is this even the
>> right direction?
> There necessairily must be a external command for it as the
> CGI's offer this functionality. It seems like it would be a
> fairily simple matter to set up a procmail recipe to receive
> emails and post the appropriate line into the external command
> file.  I haven't seen this done yet but it should be fairily
> strightforward.  

You just need to add a line or two of text to Nagios' command pipe.
The format is one of:

 [$timestamp] ACKNOWLEDGE_SVC_PROBLEM;$host;$service;1;$txt
 [$timestamp] ADD_SVC_COMMENT;$host;$service;1;$author;$txt

to acknowledge service problems, or:

 [$timestamp] ACKNOWLEDGE_HOST_PROBLEM;$host;1;$txt
 [$timestamp] ADD_HOST_COMMENT;$host;1;$author;$txt

Replace the variables as you'd expect.  The '1' in the acknowledgement
command determines whether or not to notify people of the ack; the '1'
in the comment command is the "persistent" flag, so you can change that
to 0 if you don't want the comment to persist between Nagios restarts.

If you don't add the comment, then it won't appear in the web interface
like it does if you use the CGI to acknowledge a problem.

The timestamp is the number of seconds since the epoch. In Perl, you
can get this using 'time'; from a shell, you could use  date +%s

Just write the lines to the Nagios command pipe, and Nagios will do
your bidding. The only tricky part is getting the host & service
name.  The SMS service we use is actually an email-to-SMS gateway,
and it's also an SMS-to-email gateway.  Outgoing SMS are each sent
with a different number, and replies to the SMS are sent back to
us as emails to whatever address originally sent the email to the
gateway.

 i.e.  foo at our.com -> +6141xxxx at sms.gateway -> SMS to +6141xxxx
 then, SMS reply -> sms.gateway -> foo at our.com

I have a simple table in a database with unique ID's for each of
the host/service pairs that we've sent a message for (generated
on the fly if needed).  When the reply comes back, we just match
the ID against the table to get the host + service to send to
Nagios, which makes replying via SMS (or email) very easy.

Even if you don't have the luxury of an SMS gateway that knows
which message you're replying to, you could use the same idea to
generate short unique ID's for messages, and then have the responder
include the ID in their message.  Depending on the type of phone (or
other device) being used to respond, you could make the ID's easier
to type by using numbers, the first alpha character for each number.
If everyone has "predictive text", using a random dictionary word
might be easiest.


-------------------------------------------------------
This SF.net email is sponsored by: IT Product Guide on ITManagersJournal
Use IT products in your business? Tell us what you think of them. Give us
Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more
http://productguide.itmanagersjournal.com/guidepromo.tmpl
_______________________________________________
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