diff options
author | Burt P <pburt0@gmail.com> | 2017-07-31 01:18:13 -0500 |
---|---|---|
committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2017-08-04 09:22:06 -0700 |
commit | 3ec07bbb0f6f67215eceb3952efb97032bd4c1a9 (patch) | |
tree | 2cc66890e905f2f692facd1aff69cb3a3a71e26a /modules/network.c | |
parent | d82217183f0fc34bc7d33b545121a88be78985ef (diff) |
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 <pburt0@gmail.com>
Diffstat (limited to 'modules/network.c')
-rw-r--r-- | modules/network.c | 17 |
1 files changed, 6 insertions, 11 deletions
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("<b> </b>#%d=%s\n", __statistics, - g_strstrip(tmp1), - g_strstrip(tmp2)); + line++, tmp); } } |