From: Florian Forster Date: Sun, 12 Oct 2014 15:32:47 +0000 (+0200) Subject: src/oping.c: Define thresholds for coloring green and yellow in a central place. X-Git-Tag: liboping-1.8.0~9 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=9365ae14cb196ba19f26611fd28d61957f07bf91;p=liboping.git src/oping.c: Define thresholds for coloring green and yellow in a central place. --- diff --git a/src/oping.c b/src/oping.c index 5e63392..1590bfe 100644 --- a/src/oping.c +++ b/src/oping.c @@ -95,6 +95,9 @@ # define OPING_YELLOW_HIST 5 # define OPING_RED_HIST 6 +double const threshold_green = 0.8; +double const threshold_yellow = 0.95; + static char const * const hist_symbols_utf8[] = { "▁", "▂", "▃", "▄", "▅", "▆", "▇", "█" }; static size_t const hist_symbols_utf8_num = sizeof (hist_symbols_utf8) @@ -1027,9 +1030,13 @@ static int update_graph_histogram (ping_context_t *ctx) /* {{{ */ if (has_colors () == TRUE) { - if ((ratio_this <= 0.5) || ((ratio_prev < 0.5) && (ratio_this > 0.5))) + if ((ratio_this <= threshold_green) + || ((ratio_prev < threshold_green) + && (ratio_this > threshold_green))) color = OPING_GREEN; - else if ((ratio_this <= 0.95) || ((ratio_prev < 0.95) && (ratio_this > 0.95))) + else if ((ratio_this <= threshold_yellow) + || ((ratio_prev < threshold_yellow) + && (ratio_this > threshold_yellow))) color = OPING_YELLOW; else color = OPING_RED; @@ -1413,11 +1420,13 @@ static void update_host_hook (pingobj_iter_t *iter, /* {{{ */ else ratio_prev = 0.0; - if ((ratio_this <= 0.5) || - ((ratio_prev < 0.5) && (ratio_this > 0.5))) + if ((ratio_this <= threshold_green) + || ((ratio_prev < threshold_green) + && (ratio_this > threshold_green))) color = OPING_GREEN; - else if ((ratio_this <= 0.95) || - ((ratio_prev < 0.95) && (ratio_this > 0.95))) + else if ((ratio_this <= threshold_yellow) + || ((ratio_prev < threshold_yellow) + && (ratio_this > threshold_yellow))) color = OPING_YELLOW; else color = OPING_RED;