check snmp logic

Jim Avery jim at jimavery.me.uk
Thu Aug 29 18:30:44 CEST 2013


On 29 Aug 2013 02:46, "Mark Campbell" <mcc171 at psu.edu> wrote:
>
> So I need to utilize some logic in my service checks.
>
> I have a chiller that if it is not running the discharge temp is not of
> concern.  However if it is running the discharge temp needs to be lower
> than 50 degrees.
>
> Is there a way to have the check snmp utilize some logic that says if
> running = 0 then ignore discharge temp.  If running = 1 then discharge
> temp must be <50 degrees?

Yes, I did something similar recently where I wanted to check for existence
of an orphaned file only if ftp failed on another server.

The command definition looked like this:

define command {
  command_name check-for-orphan
  command_line   if $USER1$/check_ftp -H $ARG1$ $ARG2$ $USER10$ then
$USER1$/check_multi -s $HOSTADDRESS$ $ARG3$ $USER10$ else exit 0 $USER10$ fi
  register 1
}

Obviously you won't be using check_ftp and check_multi (probably check_snmp
or your own custom plugins instead) but hopefully you can see now how you
can do something similar to run the second check only if the first returns
an ok state (I'm presuming your first check will return an ok state if
running=1 and the second returns ok if temperature < 50 degrees).

Where you see $USER10$ here, that refers to a macro in your
/usr/local/nagios/etc/resource.cfg file that gives you a semi-colon like so:

$USER10$=;

It's a bit of a kludge to allow you to have a multi-line command in a
Nagios command definition.

Note that during the time that the first check returns a non-ok state, the
service check will be in an OK state (the exit 0) but will have null
output.  I guess you could put another line with echo "something" in there
if you want it to say something meaningful.

I hope that makes some sense...

By the way, please don't blame me if this method breaks in some future
version of Nagios - I'm using 3.3.1 on this one.

Cheers,

Jim
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-lists.org/archive/users/attachments/20130829/c458506d/attachment.html>
-------------- next part --------------
------------------------------------------------------------------------------
Learn the latest--Visual Studio 2012, SharePoint 2013, SQL 2012, more!
Discover the easy way to master current and previous Microsoft technologies
and advance your career. Get an incredible 1,500+ hours of step-by-step
tutorial videos with LearnDevNow. Subscribe today and save!
http://pubads.g.doubleclick.net/gampad/clk?id=58040911&iu=/4140/ostg.clktrk
-------------- 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