Page 1 of 2
Ping without warning/critical possible (check if up/down)?
Posted: Mon Jul 22, 2013 7:50 pm
by jobst
Hi.
Is it possible to have a ping that does not create warnings/critical?
I used to use a different monitoring solution but now switching over to Nagios.
There used to be a test called "dialup" that would indicated a greyed out button instead of red when it was not turned on.
Is it possible to do the same in Nagios?
Jobst
Re: Ping without warning/critical possible (check if up/down
Posted: Tue Jul 23, 2013 1:27 pm
by lmiltchev
There is no such an option in nagios. I am not sure if I understand what is the reasoning behind this... If you exceed the warning/critical thresholds, you have a problem, and nagios will let you know. What's the difference if you see "a greyed out button instead of red" (or yellow)? Why do you need this functionality?
Re: Ping without warning/critical possible (check if up/down
Posted: Tue Jul 23, 2013 7:12 pm
by jobst
Hi.
thanks for the reply lmiltchev.
It's for workstations,laptops,mobiles and tablets - this way I (and others) can see who's in, not in, already in and/or whether they have returned from an external meeting - so we know whether to redirect phone calls or not. The feature has been good in our other solution.
The thing with marking it as yellow raises alarm bells, having a fourth state "dialup" (or whatever one wants to call it) makes it possible to see "ok this service/host is down but - it's not important but good to know".
jobst
Re: Ping without warning/critical possible (check if up/down
Posted: Wed Jul 24, 2013 10:52 am
by sreinhardt
Well, to avoid some things, you can disable notifications for these hosts\services. Alternatively, a simple script to run the ping check and if nothing is returned, set the service to unknown(grey) would not be terribly difficult. Would that work for you?
Re: Ping without warning/critical possible (check if up/down
Posted: Wed Jul 31, 2013 9:44 pm
by jobst
Sorry, late reply ... been busy.
Thanks for the reply, sreinhardt, but that does not work.
If you set the script to return STATE_UNKNOWN (3) it will be flagged as down and red ... I am not sure whether this is a bug.
What I did is make a template that points to my own script for "check_command". If I return ok, its green, but i I return unknown its red.
The Status information does return "UNKNOWN" and my text, but the status is still red.
I even tried it with a dummy command, same result.
Good idea, though.
Jobst
Re: Ping without warning/critical possible (check if up/down
Posted: Thu Aug 01, 2013 11:12 am
by lmiltchev
If you set the script to return STATE_UNKNOWN (3) it will be flagged as down and red ...
Is the check returning "3"? Can you run it in the command line, then run:
Re: Ping without warning/critical possible (check if up/down
Posted: Thu Aug 01, 2013 11:27 am
by yancy
jobst,
It's very easy to customize your own plugin to use instead of check_ping
This one should do the trick.
Code: Select all
#!/usr/bin/env python
from optparse import OptionParser
import sys
import os
#collect arguments
def parse_args():
usage = "usage: %prog -h host [--help]"
parser = OptionParser(usage=usage)
parser.add_option("-t", "--target_host",
action="store", type="string",
help="target IP or hostname")
(options, args) = parser.parse_args()
if not options.target_host:
parser.error("Must give a hostname.\n use --help for options")
else:
return (options, args)
(options, args) = parse_args()
#run ping check on host
response = os.system("ping -c 1 " + options.target_host + "> /dev/null 2>&1")
#and then check the response...
if response == 0:
print options.target_host, 'is in the office!'
sys.exit(0)
else:
print options.target_host, 'is out of the office!'
sys.exit(0)
here is an example run from the command line
Code: Select all
./check_in_office.py -t 192.168.5.90
192.168.5.90 is in the office!
./check_in_office.py -t 192.168.1.1
192.168.1.1 is out of the office!
the key to making sure it stays as a status of "OK" instead of warning is we always exit with 0 (sys.exit(0))
-Yancy
Re: Ping without warning/critical possible (check if up/down
Posted: Fri Aug 02, 2013 1:02 am
by jobst
lmiltchev wrote:If you set the script to return STATE_UNKNOWN (3) it will be flagged as down and red ...
Is the check returning "3"? Can you run it in the command line, then run:
Hi lmiltchev
This is the last part of the script:
Code: Select all
/bin/ping -c 1 -W 3 $ipaddress > /dev/null 2> /dev/null
if [ $? -eq 0 ]; then
echo "OK: machine $name ($ipaddress) is alive."
exit $STATE_OK
else
echo "UNKNOWN: machine $name ($ipaddress) not turned on."
exit $STATE_UNKNOWN
fi
This is the output of the commandline
Code: Select all
[root /src/nagios-plugins-1.4.16/plugins-scripts] #>./check_no_failure_ping.sh -i 192.168.0.249 -n blah
UNKNOWN: machine blah (192.168.0.249) not turned on.
[root /src/nagios-plugins-1.4.16/plugins-scripts] #>echo $?
3
[root /src/nagios-plugins-1.4.16/plugins-scripts] #>
But if I do that under the "hosts" section (host details for all host groups) the status turns red.
Now I did a little bit of research to find why (note I put all source code below /src, as I did for nagios-3.5.0.tar.gz)
Looking at /src/nagios/cgi/status.c, line 2198 "if(temp_status->status" there is no such thing as "unknown" only "pending,up,down and unreachable".
I gather, that it is not possible to to return a state of "unknown" for a host, because if you search for any define like "HOST_UNKNOWN" it does not exist, only HOST_DOWN,HOST_UP,HOST_PENDING and HOST_UNREACHABLE. Putting and HOST_UNREACHABLE value of 2 turns it red as it does if you return 3 out of the script.
It would be nice if a state of unknown would exist as lots of printers, laptops, mobile devices, workstations etc don't need to go red if they are not ping-able.
I know I could simply return a "STATUS_OK" as exit code and put something like "The machine is not turned on", but then you need to read 30 hosts ... not including the servers.
Not sure whether I can set "STATUS_PENDING" or "HOST_PENDING"?
jobst
Re: Ping without warning/critical possible (check if up/down
Posted: Fri Aug 02, 2013 9:27 am
by yancy
jobst,
http://nagiosplug.sourceforge.net/devel ... html#AEN76
plugin return codes do include unknown (exit with 3). This is usually reserved for handling exceptions however.
-Yancy
Re: Ping without warning/critical possible (check if up/down
Posted: Sat Aug 03, 2013 8:04 pm
by jobst
Yancy, I know what the return codes are ... that is not my problem.
If you look at the code above you can see I return 3 and it is the value being returned properly (as shown by the debug echo $?).
Jobst