Alert when Host/Service is UP

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
userctx
Posts: 4
Joined: Fri Nov 16, 2012 5:04 am

Alert when Host/Service is UP

Post by userctx »

Hello everyone,

We have the following scenario: We are deploying some 3G Routers and we want that Nagios shows an alert when they are connected/working.

So we would like to see a normal state (up) of these hosts (routers) when they are DOWN or UNREACHABLE and we would like to see that they are in a critical state when they are UP (responding to check_ping).

It's possible to do this?


Thank you in advance.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Alert when Host/Service is UP

Post by slansing »

I would recommend using the negate plugin:

Code: Select all

/usr/local/nagios/libexec/negate 
negate v1989 (nagios-plugins 1.4.13)
Copyright (c) 2002-2008 Nagios Plugin Development Team
<[email protected]>

Negates the status of a plugin (returns OK for CRITICAL and vice-versa).
Additional switches can be used to control which state becomes what.


Usage:negate [-t timeout] [-owcu STATE] [-s] <definition of wrapped plugin>

Options:
-h, --help
Print detailed help screen
-V, --version
Print version information
-t, --timeout=INTEGER
Seconds before connection times out (default: 11)
Keep timeout longer than the plugin timeout to retain CRITICAL status.
-o, --ok=STATUS
-w, --warning=STATUS
-c, --critical=STATUS
-u, --unknown=STATUS
STATUS can be 'OK', 'WARNING', 'CRITICAL' or 'UNKNOWN' without single
quotes. Numeric values are accepted. If nothing is specified, permutes
OK and CRITICAL.
-s, --substitute
Substitute output text as well. Will only substitute text in CAPITALS

Examples:
negate /usr/local/nagios/libexec/check_ping -H host
Run check_ping and invert result. Must use full path to plugin
negate -w OK -c UNKNOWN /usr/local/nagios/libexec/check_procs -a 'vi negate.c'
This will return OK instead of WARNING and UNKNOWN instead of CRITICAL

Notes:
This plugin is a wrapper to take the output of another plugin and invert it.
The full path of the plugin must be provided.
If the wrapped plugin returns OK, the wrapper will return CRITICAL.
If the wrapped plugin returns CRITICAL, the wrapper will return OK.
Otherwise, the output state of the wrapped plugin is unchanged.
userctx
Posts: 4
Joined: Fri Nov 16, 2012 5:04 am

Re: Alert when Host/Service is UP

Post by userctx »

Thank you very much, I will try that.


Regards.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Alert when Host/Service is UP

Post by slansing »

Sounds good, let us know if it works out for you!
userctx
Posts: 4
Joined: Fri Nov 16, 2012 5:04 am

Re: Alert when Host/Service is UP

Post by userctx »

Hello,

Yes, It worked succesfully against a Windows Server with nsclient++

But we tested with the same configuration with a router and it didn't worked, it shows "CRITICAL - Plugin timed out after 22 seconds". Logically, there is no Nagios client for routers...

Please tell me if necessarily the negate "plugin" needs the nsclient or I'm doing something wrong.


Thank you in advance.
agriffin
Posts: 876
Joined: Mon May 09, 2011 9:36 am

Re: Alert when Host/Service is UP

Post by agriffin »

You're probably doing something wrong, since the negate plugin does not require an agent like nsclient. Could you post the problematic service/host definition for the router?
Locked