aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Holger Weiss <holger@zedat.fu-berlin.de> 2013-08-18 20:36:42 +0200
committerGravatar Holger Weiss <holger@zedat.fu-berlin.de> 2013-08-18 20:36:42 +0200
commit6d6f090eaa384aab6677953e6ea378dc228ac667 (patch)
treeed30c85e26415a0ebe1e79789d8c190fddb7d3cf
parentc7c1102fcba72eed4e0a52a700d591fca0a0f668 (diff)
parent96ec686004b13a76eac081db5d0883db6ae08963 (diff)
downloadmonitoring-plugins-6d6f090eaa384aab6677953e6ea378dc228ac667.tar.gz
Merge branch 'fping' of https://github.com/lairsdragon/nagios-plugins
* 'fping' of https://github.com/lairsdragon/nagios-plugins: check_fping error handling enhanced, generates UNKNOWN on fping parameter error (i.e. wrong interface, missing perms ..) Closes #61.
-rw-r--r--plugins/check_fping.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/plugins/check_fping.c b/plugins/check_fping.c
index fde1d798..c7cce97d 100644
--- a/plugins/check_fping.c
+++ b/plugins/check_fping.c
@@ -74,6 +74,7 @@ main (int argc, char **argv)
/* normaly should be int result = STATE_UNKNOWN; */
int status = STATE_UNKNOWN;
+ int result = 0;
char *fping_prog = NULL;
char *server = NULL;
char *command_line = NULL;
@@ -146,10 +147,24 @@ main (int argc, char **argv)
(void) fclose (child_stderr);
/* close the pipe */
- if (spclose (child_process))
+ if (result = spclose (child_process))
/* need to use max_state not max */
status = max_state (status, STATE_WARNING);
+ if (result > 1 ) {
+ status = max_state (status, STATE_UNKNOWN);
+ if (result == 2) {
+ die (STATE_UNKNOWN, _("FPING UNKNOWN - IP address not found\n"));
+ }
+ if (result == 3) {
+ die (STATE_UNKNOWN, _("FPING UNKNOWN - invalid commandline argument\n"));
+ }
+ if (result == 4) {
+ die (STATE_UNKNOWN, _("FPING UNKNOWN - failed system call\n"));
+ }
+
+ }
+
printf ("FPING %s - %s\n", state_text (status), server_name);
return status;
@@ -175,6 +190,10 @@ textscan (char *buf)
"host");
}
+ else if (strstr (buf, "Operation not permitted") || strstr (buf, "No such device") ) {
+ die (STATE_UNKNOWN, _("FPING UNKNOWN - %s parameter error\n"),
+ "host");
+ }
else if (strstr (buf, "is down")) {
die (STATE_CRITICAL, _("FPING CRITICAL - %s is down\n"), server_name);