diff --git a/server/include/log.h b/server/include/log.h index 375c3d394..fcc8b4e18 100644 --- a/server/include/log.h +++ b/server/include/log.h @@ -78,7 +78,11 @@ void info(const char *fmt, ...) /** Printf alike warning message. */ void warn(const char *fmt, ...) __attribute__ ((format(printf, 1, 2))); - + +/** Printf alike statistics message. */ +void stats(const char *fmt, ...) + __attribute__ ((format(printf, 1, 2))); + /** Print error and exit. */ void error(const char *fmt, ...) __attribute__ ((format(printf, 1, 2))); diff --git a/server/src/hist.c b/server/src/hist.c index f0856d2f7..5a93b7ccb 100644 --- a/server/src/hist.c +++ b/server/src/hist.c @@ -103,23 +103,16 @@ double hist_stddev(struct hist *h) void hist_print(struct hist *h) { INDENT - info("Total: %u values", h->total); - info("Highest value: %f", h->highest); - info("Lowest value: %f", h->lowest); - info("Mean: %f", hist_mean(h)); - info("Variance: %f", hist_var(h)); - info("Standard derivation: %f", hist_stddev(h)); - if (h->higher > 0) - warn("Missed: %u values above %f", h->higher, h->high); - if (h->lower > 0) - warn("Missed: %u values below %f", h->lower, h->low); + stats("Counted values: %u (%u between %f and %f)", h->total, h->total-h->higher-h->lower, h->high, h->low); + stats("Highest: %f Lowest: %f", h->highest, h->lowest); + stats("Mu: %f Sigma2: %f Sigma: %f", hist_mean(h), hist_var(h), hist_stddev(h)); if (h->total - h->higher - h->lower > 0) { - hist_plot(h); - char *buf = hist_dump(h); - info("Matlab: %s", buf); + stats("Matlab: %s", buf); free(buf); + + hist_plot(h); } } @@ -137,13 +130,15 @@ void hist_plot(struct hist *h) } /* Print plot */ - info("%3s | %9s | %5s | %s", "#", "Value", "Occur", "Plot"); + stats("%9s | %5s | %s", "Value", "Count", "Plot"); line(); for (int i = 0; i < h->length; i++) { int bar = HIST_HEIGHT * ((double) h->data[i] / max); + if (bar == 0) + continue; - info("%3u | %+9g | " "%5u" " | %.*s", i, VAL(h, i), h->data[i], bar, buf); + stats("%+9g | " "%5u" " | %.*s", VAL(h, i), h->data[i], bar, buf); } } diff --git a/server/src/hooks.c b/server/src/hooks.c index 65468d096..456ff0cc5 100644 --- a/server/src/hooks.c +++ b/server/src/hooks.c @@ -377,12 +377,12 @@ int hook_stats(struct path *p, struct hook *h, int when) char *buf = path_print(p); if (p->received > 0) - log_print(STATS, "%-40s|%10.2g|%10.2f|%10u|%10u|%10u|%10u|%10u|%10u|%10u|", buf, + stats("%-40s|%10.2g|%10.2f|%10u|%10u|%10u|%10u|%10u|%10u|%10u|", buf, p->hist_owd.last, 1 / p->hist_gap_msg.last, p->sent, p->received, p->dropped, p->skipped, p->invalid, p->overrun, list_length(p->current) ); else - log_print(STATS, "%-40s|%10s|%10s|%10u|%10u|%10u|%10u|%10u|%10u|%10s|", buf, "", "", + stats("%-40s|%10s|%10s|%10u|%10u|%10u|%10u|%10u|%10u|%10s|", buf, "", "", p->sent, p->received, p->dropped, p->skipped, p->invalid, p->overrun, "" ); @@ -398,7 +398,7 @@ void hook_stats_header() { #define UNIT(u) "(" YEL(u) ")" - log_print(STATS, "%-40s|%19s|%19s|%19s|%19s|%19s|%19s|%19s|%10s|%10s|", "Source " MAG("=>") " Destination", + stats("%-40s|%19s|%19s|%19s|%19s|%19s|%19s|%19s|%10s|%10s|", "Source " MAG("=>") " Destination", "OWD" UNIT("S") " ", "Rate" UNIT("p/S") " ", "Sent" UNIT("p") " ", diff --git a/server/src/log.c b/server/src/log.c index f99a33e1e..87b263283 100644 --- a/server/src/log.c +++ b/server/src/log.c @@ -136,6 +136,15 @@ void warn(const char *fmt, ...) va_end(ap); } +void stats(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + log_vprint(STATS, fmt, ap); + va_end(ap); +} + void error(const char *fmt, ...) { va_list ap; diff --git a/server/src/socket.c b/server/src/socket.c index fded7353b..b45113429 100644 --- a/server/src/socket.c +++ b/server/src/socket.c @@ -266,7 +266,7 @@ int socket_write(struct node *n, struct msg *pool, int poolsize, int first, int if (bytes < 0) serror("Failed send"); - debug(10, "Sent packet of %u bytes: %u samples a %u values per sample", bytes, cnt, (bytes / cnt) / 4 - 4); + debug(17, "Sent packet of %u bytes: %u samples a %u values per sample", bytes, cnt, (bytes / cnt) / 4 - 4); return sent; }