Re: [Nagios-users] check snmp logic

2013-08-29 Thread Jim Avery
On 29 Aug 2013 02:46, "Mark Campbell"  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
--
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___
Nagios-users mailing list
Nagios-users@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

Re: [Nagios-users] check snmp logic

2013-08-28 Thread Ben Sykes

 
Do you mean you want to check the result of one OID and make that treat
another OID's values differently?

Personally if I faced that problem - I would probably code a custom check
in Bash using snmpget from snmputils that did some nested If statements, or
use Net::SNMP from Perl and check it that way. Quite simple to write a
Nagios plugin - it's all about the exit values - 0 is OK, 1 is Warning, 2
is Critical, 3 is Unknown.

You may be able to use warning states generated by the first to define a
dependency on the second but it will be complicated to change the
thresholds dynamically via that method, at best you'd be able to suppress a
warning or other state from the 2nd but you couldn't have differential
thresholds between the two states of the first service without some work or
hackery (e.g. having an event trigger fire off that changes the
configuration file and reloads nagios)

I would just code it into a plugin (assuming you or someone on your team
can code)


Something like this perl pseudo code...

use Net::SNMP;

$snmp = Net::SNMP->session(-hostname => $ipaddress, -community => "public",
-version => 'snmpv2c');

@oids = qw/1.2.3.4 1.2.3.5/;

$res = $snmp->get_request(-varbindlist => \@oids);
unless(defined($res))
{
   print "UNKNOWN - no response\n";
   exit(3);
}

$firstoidval = $res->{$oids[0]};
$secondoidval = $res->{$oids[1]};

if ($firstoidval == 1)  #running?
{
   if ($secondoidval > 50) { print "CRITICAL - running and temp above
critical threshold"; exit(2); }
   if ($secondoidval > 45) { print "WARNING"; exit(1); }
   else { print "OK"; exit(0): }
}
elsif ($firstoidval == 0)  #notrunning?
{
   if ($secondoidval > 40) { print "CRITICAL"; exit(2); }
   if ($secondoidval > 35) { print "WARNING"; exit(1); }
   else { print "OK"; exit(0): }
}


Logic probably differs a bit, but you get the gist...


Cheers

Ben



ben sykes
consultant

m. +61 404 308 201
e. ben.sy...@transpire.com.auimage:
On Thu, Aug 29, 2013 at 11:27 AM, Mark Campbell  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?
>
> THe other option I thought of was using dependencies.  Anyone have
> suggestions on that?
>
>
>
>
> --
> 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
> ___
> Nagios-users mailing list
> Nagios-users@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
>




legal disclaimer:

This email, including any attachments, may be confidential or privileged, and 
is sent for the personal attention of the intended recipient. If you have 
received this email in error, please delete it immediately. The views expressed 
are not necessarily those of Transpire Pty Ltd. Transpire is not liable for the 
effects of any virus which may be contained in this email.<><><>--
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___
Nagios-users mailing list
Nagios-users@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

[Nagios-users] check snmp logic

2013-08-28 Thread Mark Campbell
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?

THe other option I thought of was using dependencies.  Anyone have 
suggestions on that?



--
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
___
Nagios-users mailing list
Nagios-users@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