summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 773dbf0)
raw | patch | inline | side by side (parent: 773dbf0)
author | Barak A. Pearlmutter <barak+git@cs.nuim.ie> | |
Thu, 1 Sep 2011 12:22:05 +0000 (13:22 +0100) | ||
committer | Barak A. Pearlmutter <barak+git@cs.nuim.ie> | |
Mon, 5 Sep 2011 08:01:05 +0000 (09:01 +0100) |
The number of unreturned packets in excess of 50% is summed over all
hosts. If this is nonzero, this count plus 1 is the process exit
status.
hosts. If this is nonzero, this count plus 1 is the process exit
status.
src/oping.c | patch | blob | history |
diff --git a/src/oping.c b/src/oping.c
index 79d7569db279b8a1d04eeb8b2ced4e3669179188..5b75dae02efe461849361c8716d9e493b5c6690e 100644 (file)
--- a/src/oping.c
+++ b/src/oping.c
#endif
} /* }}} void update_host_hook */
+/* returns the number of significant failures: sum over hosts of
+ unreturned packets exceeding 50% of the number sent, rounding up. */
static int post_loop_hook (pingobj_t *ping) /* {{{ */
{
pingobj_iter_t *iter;
+ /* failures to report: sum over hosts of number of failed
+ returns above 50% */
+ int failure_count = 0;
#if USE_NCURSES
endwin ();
context_get_packet_loss (context),
context->latency_total);
+ {
+ /* threshold for counting failed returns is 50%, rounding up */
+ int threshold = (context->req_sent + 1) / 2;
+ if (context->req_rcvd < threshold)
+ failure_count += threshold - context->req_rcvd;
+ }
+
if (context->req_rcvd != 0)
{
double average;
context_destroy (context);
}
- return (0);
+ return (failure_count);
} /* }}} int post_loop_hook */
int main (int argc, char **argv) /* {{{ */
opt_count--;
} /* while (opt_count != 0) */
- post_loop_hook (ping);
+ status = post_loop_hook (ping);
ping_destroy (ping);
- return (0);
+ if (status)
+ return (EXIT_FAILURE + status);
+ else
+ return (EXIT_SUCCESS);
} /* }}} int main */
/* vim: set fdm=marker : */