Trap reset script

Thomas Guyot-Sionnest Thomas at zango.com
Tue Mar 13 21:54:01 CET 2007


Hi lists,

Some time ago I talked about using a script for resetting traps; I just made
one. Unfortunately Nagios::Config was way too buggy to work on complex
configs so I went up with a solution using Nagios::StatusLog.

The command looks like this:

./TrapReset.pl -c /path/to/nagios.cfg

It will look up the status and command files from the Nagios config, parse
the status and then force an active check for services matching these
criterias:

1. Should not be scheduled to be checked
2. Has active checks enabled

On my setup this roughly translate to all my traps (They all have the
following proprieties: check_period none; max_check_attempts 1; is_volatile
1; active_checks_enabled 1 )

Alternatively you can look in the code and replace:

if ($$log{'SERVICE'}{$host}{$service}{'should_be_scheduled'} == 0 &&
  $$log{'SERVICE'}{$host}{$service}{'active_checks_enabled'} == 1) {

With the following line (already there, commented-out):

  if ($service =~ /^.+Trap$/) {

Where '^.+Trap$' is the regexp to match. It will use the regexp to match
services on which to run a forced check. You can also change the command
sent, say if you want to submit passive check results instead.

This is by no way a finished product and I assume the user has at least
basic Perl programming skills to make this program suit his needs.

Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: TrapReset.pl
Type: application/octet-stream
Size: 1799 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/users/attachments/20070313/6c245f7a/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3076 bytes
Desc: not available
URL: <https://www.monitoring-lists.org/archive/users/attachments/20070313/6c245f7a/attachment.bin>
-------------- next part --------------
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys-and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
-------------- next part --------------
_______________________________________________
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