From 3ec07bbb0f6f67215eceb3952efb97032bd4c1a9 Mon Sep 17 00:00:00 2001 From: Burt P Date: Mon, 31 Jul 2017 01:18:13 -0500 Subject: network: fix network statistics * Each key name must be unique, so using stat values as keys causes problems if two stats have the same stat value. * Show all stats, not just those in the form "%d %explaination" Signed-off-by: Burt P --- modules/network.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'modules/network.c') diff --git a/modules/network.c b/modules/network.c index 72baa9c0..f27a159a 100644 --- a/modules/network.c +++ b/modules/network.c @@ -80,6 +80,7 @@ void scan_statistics(gboolean reload) FILE *netstat; gchar buffer[256]; gchar *netstat_path; + int line = 0; SCAN_START(); @@ -99,22 +100,16 @@ void scan_statistics(gboolean reload) __statistics = h_strdup_cprintf("[%s]\n", __statistics, tmp); - g_free(tmp); - } else if (isdigit(buffer[4])) { - gchar *tmp1 = buffer + 4, - *tmp2 = tmp1; - while (*tmp2 && !isspace(*tmp2)) tmp2++; - *tmp2 = 0; - tmp2++; + } else { + gchar *tmp = buffer; - *tmp2 = toupper(*tmp2); + while (*tmp && isspace(*tmp)) tmp++; - __statistics = h_strdup_cprintf("%s=%s\n", + __statistics = h_strdup_cprintf(" #%d=%s\n", __statistics, - g_strstrip(tmp1), - g_strstrip(tmp2)); + line++, tmp); } } -- cgit v1.2.3