summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorHolger Weiss <holger@zedat.fu-berlin.de>2013-08-18 18:36:42 (GMT)
committerHolger Weiss <holger@zedat.fu-berlin.de>2013-08-18 18:36:42 (GMT)
commit6d6f090eaa384aab6677953e6ea378dc228ac667 (patch)
treeed30c85e26415a0ebe1e79789d8c190fddb7d3cf /plugins
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.
Diffstat (limited to 'plugins')
-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 fde1d79..c7cce97 100644
--- a/plugins/check_fping.c
+++ b/plugins/check_fping.c
@@ -74,6 +74,7 @@ main (int argc, char **argv)
74/* normaly should be int result = STATE_UNKNOWN; */ 74/* normaly should be int result = STATE_UNKNOWN; */
75 75
76 int status = STATE_UNKNOWN; 76 int status = STATE_UNKNOWN;
77 int result = 0;
77 char *fping_prog = NULL; 78 char *fping_prog = NULL;
78 char *server = NULL; 79 char *server = NULL;
79 char *command_line = NULL; 80 char *command_line = NULL;
@@ -146,10 +147,24 @@ main (int argc, char **argv)
146 (void) fclose (child_stderr); 147 (void) fclose (child_stderr);
147 148
148 /* close the pipe */ 149 /* close the pipe */
149 if (spclose (child_process)) 150 if (result = spclose (child_process))
150 /* need to use max_state not max */ 151 /* need to use max_state not max */
151 status = max_state (status, STATE_WARNING); 152 status = max_state (status, STATE_WARNING);
152 153
154 if (result > 1 ) {
155 status = max_state (status, STATE_UNKNOWN);
156 if (result == 2) {
157 die (STATE_UNKNOWN, _("FPING UNKNOWN - IP address not found\n"));
158 }
159 if (result == 3) {
160 die (STATE_UNKNOWN, _("FPING UNKNOWN - invalid commandline argument\n"));
161 }
162 if (result == 4) {
163 die (STATE_UNKNOWN, _("FPING UNKNOWN - failed system call\n"));
164 }
165
166 }
167
153 printf ("FPING %s - %s\n", state_text (status), server_name); 168 printf ("FPING %s - %s\n", state_text (status), server_name);
154 169
155 return status; 170 return status;
@@ -175,6 +190,10 @@ textscan (char *buf)
175 "host"); 190 "host");
176 191
177 } 192 }
193 else if (strstr (buf, "Operation not permitted") || strstr (buf, "No such device") ) {
194 die (STATE_UNKNOWN, _("FPING UNKNOWN - %s parameter error\n"),
195 "host");
196 }
178 else if (strstr (buf, "is down")) { 197 else if (strstr (buf, "is down")) {
179 die (STATE_CRITICAL, _("FPING CRITICAL - %s is down\n"), server_name); 198 die (STATE_CRITICAL, _("FPING CRITICAL - %s is down\n"), server_name);
180 199