From c07e45a4c8f1881383d0f0321c4ed7fcdd137925 Mon Sep 17 00:00:00 2001 From: Oliver Jowett Date: Fri, 23 Jan 2015 02:03:57 +0000 Subject: [PATCH] Report CPU in integer milliseconds, makes it a bit easier to process. --- net_io.c | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/net_io.c b/net_io.c index 9fc434c..78d8726 100644 --- a/net_io.c +++ b/net_io.c @@ -876,25 +876,30 @@ static char * appendStatsJson(char *p, p += snprintf(p, end-p, "},\"http_requests\":%u", st->http_requests); } - p += snprintf(p, end-p, - ",\"cpr\":{\"global_ok\":%u" - ",\"global_bad\":%u" - ",\"global_skipped\":%u" - ",\"local_ok\":%u" - ",\"local_skipped\":%u" - ",\"filtered\":%u}" - ",\"cpu\":{\"demod\":%d.%09ld,\"reader\":%d.%09ld,\"background\":%d.%09ld}" - ",\"messages\":%u}", - st->cpr_global_ok, - st->cpr_global_bad, - st->cpr_global_skipped, - st->cpr_local_ok, - st->cpr_local_skipped, - st->cpr_filtered, - (int)st->demod_cpu.tv_sec, (long)st->demod_cpu.tv_nsec, - (int)st->reader_cpu.tv_sec, (long)st->reader_cpu.tv_nsec, - (int)st->background_cpu.tv_sec, (long)st->background_cpu.tv_nsec, - st->messages_total); + { + uint64_t demod_cpu_millis = (uint64_t)st->demod_cpu.tv_sec*1000UL + st->demod_cpu.tv_nsec/1000000UL; + uint64_t reader_cpu_millis = (uint64_t)st->reader_cpu.tv_sec*1000UL + st->reader_cpu.tv_nsec/1000000UL; + uint64_t background_cpu_millis = (uint64_t)st->background_cpu.tv_sec*1000UL + st->background_cpu.tv_nsec/1000000UL; + + p += snprintf(p, end-p, + ",\"cpr\":{\"global_ok\":%u" + ",\"global_bad\":%u" + ",\"global_skipped\":%u" + ",\"local_ok\":%u" + ",\"local_skipped\":%u" + ",\"filtered\":%u}" + ",\"cpu\":{\"demod\":%llu,\"reader\":%llu,\"background\":%llu}" + ",\"messages\":%u}", + st->cpr_global_ok, + st->cpr_global_bad, + st->cpr_global_skipped, + st->cpr_local_ok, + st->cpr_local_skipped, + st->cpr_filtered, + (unsigned long long)demod_cpu_millis, + (unsigned long long)reader_cpu_millis, + (unsigned long long)background_cpu_millis, + st->messages_total); return p; }