From afa7248c036ab4b0e4e4a87f5e1fd6816ea8fcce Mon Sep 17 00:00:00 2001 From: chris <> Date: Wed, 27 Mar 2002 19:04:19 +0000 Subject: [PATCH] "" --- iftop.c | 9 +++++---- ui.c | 16 +++++++++++++--- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/iftop.c b/iftop.c index 5d987c5..224987b 100644 --- a/iftop.c +++ b/iftop.c @@ -221,15 +221,16 @@ void packet_loop(void* ptr) { void usage(FILE *fp) { fprintf(fp, "iftop: display bandwidth usage on an interface by host\n" -"Options:\n" "\n" +"Synopsis: iftop -h | [-d] [-p] [-i interface] [-f filter code]\n" +"\n" +" -h display this message\n" " -d don't do hostname lookups\n" +" -p run in promiscuous mode (show traffic between other\n" +" hosts on the same network segment)\n" " -i interface listen on named interface (default: eth0)\n" " -f filter code use filter code to select packets to count\n" " (default: none, but only IP packets are counted)\n" -" -p run in promiscuous mode (show traffic between other\n" -" hosts on the same network segment)\n" -" -h display this message\n" "\n" "iftop, $Id$\n" ); diff --git a/ui.c b/ui.c index 44cf4b4..4fc718d 100644 --- a/ui.c +++ b/ui.c @@ -102,12 +102,11 @@ int history_length(const int d) { } void draw_line_totals(int y, host_pair_line* line) { - int j; + int j, t, L; char buf[10]; int x = (COLS - 8 * HISTORY_DIVISIONS); for(j = 0; j < HISTORY_DIVISIONS; j++) { - int t; t = history_length(j); readable_size(8 * line->sent[j] / t, buf, 10, 1024); mvaddstr(y, x, buf); @@ -116,7 +115,17 @@ void draw_line_totals(int y, host_pair_line* line) { mvaddstr(y+1, x, buf); x += 8; } + + t = history_length(BARGRAPH_INTERVAL); + mvchgat(y, 0, -1, A_NORMAL, 0, NULL); + L = get_bar_length(8 * line->sent[BARGRAPH_INTERVAL] / t); + if (L > 0) + mvchgat(y, 0, L + 1, A_REVERSE, 0, NULL); + mvchgat(y+1, 0, -1, A_NORMAL, 0, NULL); + L = get_bar_length(8 * line->recv[BARGRAPH_INTERVAL] / t); + if (L > 0) + mvchgat(y+1, 0, L + 1, A_REVERSE, 0, NULL); } void draw_totals(host_pair_line* totals) { @@ -260,7 +269,6 @@ void ui_print() { free(screen_line); } - draw_totals(&totals); y = LINES - 2; mvaddstr(y, 0, "sent peak: "); @@ -274,6 +282,8 @@ void ui_print() { mvaddstr(y, COLS - 8 * HISTORY_DIVISIONS - 10, "totals:"); + draw_totals(&totals); + refresh(); sorted_list_destroy(&screen_list);