summaryrefslogtreecommitdiffstats
path: root/plugins/check_fping.c
diff options
context:
space:
mode:
authorSubhendu Ghosh <sghosh@users.sourceforge.net>2002-06-19 05:11:52 (GMT)
committerSubhendu Ghosh <sghosh@users.sourceforge.net>2002-06-19 05:11:52 (GMT)
commitf4c6f7f09305c1c9916da6ac4f7aadcb31e319e0 (patch)
treebec7f042f90eac26b30122806846fc6a0e3f13b7 /plugins/check_fping.c
parentd36016a7adf28424d7f4adaa50612c41f1937c3b (diff)
downloadmonitoring-plugins-f4c6f7f09305c1c9916da6ac4f7aadcb31e319e0.tar.gz
more POSIX return value comparison related code fixes
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@55 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'plugins/check_fping.c')
-rw-r--r--plugins/check_fping.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/plugins/check_fping.c b/plugins/check_fping.c
index f6531a5..9a2dd55 100644
--- a/plugins/check_fping.c
+++ b/plugins/check_fping.c
@@ -93,21 +93,22 @@ main (int argc, char **argv)
93 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) { 93 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_process)) {
94 if (verbose) 94 if (verbose)
95 printf ("%s", input_buffer); 95 printf ("%s", input_buffer);
96 status = max (status, textscan (input_buffer)); 96 status = max_state (status, textscan (input_buffer));
97 } 97 }
98 98
99 /* If we get anything on STDERR, at least set warning */ 99 /* If we get anything on STDERR, at least set warning */
100 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) { 100 while (fgets (input_buffer, MAX_INPUT_BUFFER - 1, child_stderr)) {
101 status = max (status, STATE_WARNING); 101 status = max_state (status, STATE_WARNING);
102 if (verbose) 102 if (verbose)
103 printf ("%s", input_buffer); 103 printf ("%s", input_buffer);
104 status = max (status, textscan (input_buffer)); 104 status = max_state (status, textscan (input_buffer));
105 } 105 }
106 (void) fclose (child_stderr); 106 (void) fclose (child_stderr);
107 107
108 /* close the pipe */ 108 /* close the pipe */
109 if (spclose (child_process)) 109 if (spclose (child_process))
110 status = max (status, STATE_WARNING); 110 /* need to use max_state not max */
111 status = max_state (status, STATE_WARNING);
111 112
112 printf ("FPING %s - %s\n", state_text (status), server_name); 113 printf ("FPING %s - %s\n", state_text (status), server_name);
113 114
@@ -166,8 +167,27 @@ textscan (char *buf)
166 state_text (status), server_name, loss, rta); 167 state_text (status), server_name, loss, rta);
167 168
168 } 169 }
170 else if(strstr (buf, "xmt/rcv/%loss") ) {
171 /* no min/max/avg if host was unreachable in fping v2.2.b1 */
172 losstr = strstr (buf, "=");
173 losstr = 1 + strstr (losstr, "/");
174 losstr = 1 + strstr (losstr, "/");
175 loss = strtod (losstr, NULL);
176 if (loss == 100)
177 status = STATE_CRITICAL;
178 else if (cpl != UNKNOWN_PACKET_LOSS && loss > cpl)
179 status = STATE_CRITICAL;
180 else if (wpl != UNKNOWN_PACKET_LOSS && loss > wpl)
181 status = STATE_WARNING;
182 else
183 status = STATE_OK;
184
185 terminate (status, "FPING %s - %s (loss=%f%% )\n",
186 state_text (status), server_name, loss );
187
188 }
169 else { 189 else {
170 status = max (status, STATE_WARNING); 190 status = max_state (status, STATE_WARNING);
171 } 191 }
172 192
173 return status; 193 return status;