From 246868dd98b913ff6c989216a49d395305c13da6 Mon Sep 17 00:00:00 2001 From: Vadim Kochan Date: Mon, 13 Jul 2015 23:03:08 +0300 Subject: flowtop: Show total numbers of flows Count flows which might be showed and show this number on the top status line. Signed-off-by: Vadim Kochan Signed-off-by: Tobias Klauser --- flowtop.c | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) (limited to 'flowtop.c') diff --git a/flowtop.c b/flowtop.c index fb42bc4..083d16b 100644 --- a/flowtop.c +++ b/flowtop.c @@ -951,6 +951,8 @@ static void presenter_screen_update(WINDOW *screen, struct flow_list *fl, int skip_lines) { int maxy; + int skip_left = skip_lines; + unsigned int flows = 0; unsigned int line = 3; struct flow_entry *n; @@ -968,15 +970,6 @@ static void presenter_screen_update(WINDOW *screen, struct flow_list *fl, wclear(screen); clear(); - mvwprintw(screen, 1, 2, "Kernel netfilter flows for %s%s%s%s%s%s" - "[+%d]", what & INCLUDE_TCP ? "TCP, " : "" , - what & INCLUDE_UDP ? "UDP, " : "", - what & INCLUDE_SCTP ? "SCTP, " : "", - what & INCLUDE_DCCP ? "DCCP, " : "", - what & INCLUDE_ICMP && what & INCLUDE_IPV4 ? "ICMP, " : "", - what & INCLUDE_ICMP && what & INCLUDE_IPV6 ? "ICMP6, " : "", - skip_lines); - rcu_read_lock(); n = rcu_dereference(fl->head); @@ -985,17 +978,20 @@ static void presenter_screen_update(WINDOW *screen, struct flow_list *fl, "Is netfilter running?)"); for (; n; n = rcu_dereference(n->next)) { - if (maxy <= 0) - goto skip; - if (presenter_get_port(n->port_src, n->port_dst, 0) == 53) goto skip; if (presenter_flow_wrong_state(n)) goto skip; - if (skip_lines > 0) { - skip_lines--; + /* count only flows which might be showed */ + flows++; + + if (maxy <= 0) + goto skip; + + if (skip_left > 0) { + skip_left--; goto skip; } @@ -1010,6 +1006,15 @@ skip: continue; } + mvwprintw(screen, 1, 2, "Kernel netfilter flows(%u) for %s%s%s%s%s%s" + "[+%d]", flows, what & INCLUDE_TCP ? "TCP, " : "" , + what & INCLUDE_UDP ? "UDP, " : "", + what & INCLUDE_SCTP ? "SCTP, " : "", + what & INCLUDE_DCCP ? "DCCP, " : "", + what & INCLUDE_ICMP && what & INCLUDE_IPV4 ? "ICMP, " : "", + what & INCLUDE_ICMP && what & INCLUDE_IPV6 ? "ICMP6, " : "", + skip_lines); + rcu_read_unlock(); wrefresh(screen); -- cgit v1.2.3-54-g00ecf