Added overall peak and total.
This commit is contained in:
2
Makefile
2
Makefile
@@ -74,3 +74,5 @@ nodepend:
|
|||||||
rm -f depend
|
rm -f depend
|
||||||
|
|
||||||
# DO NOT DELETE
|
# DO NOT DELETE
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
4
iftop.8
4
iftop.8
@@ -19,9 +19,9 @@ if none is specified, and displays a table of current bandwidth usage by pairs
|
|||||||
of hosts.
|
of hosts.
|
||||||
|
|
||||||
When run, \fBiftop\fP displays, for each pair of hosts, the rate at which data
|
When run, \fBiftop\fP displays, for each pair of hosts, the rate at which data
|
||||||
is sent and received averaged over 1, 5 and 20 second intervals. The direction
|
is sent and received averaged over 2, 10 and 40 second intervals. The direction
|
||||||
of data flow is indicated by arrows, <= and =>. In addition, a simple bar graph
|
of data flow is indicated by arrows, <= and =>. In addition, a simple bar graph
|
||||||
shows the 5-second average. The pairs of hosts which consume the most bandwidth
|
shows the 10-second average. The pairs of hosts which consume the most bandwidth
|
||||||
are displayed at the top of the screen, and totals for all hosts are shown at
|
are displayed at the top of the screen, and totals for all hosts are shown at
|
||||||
the bottom of the screen.
|
the bottom of the screen.
|
||||||
|
|
||||||
|
|||||||
56
ui.c
56
ui.c
@@ -145,11 +145,12 @@ void ui_print() {
|
|||||||
char hostname[HOSTNAME_LENGTH];
|
char hostname[HOSTNAME_LENGTH];
|
||||||
static char *line;
|
static char *line;
|
||||||
static int lcols;
|
static int lcols;
|
||||||
int peaksent = 0;
|
int peaksent = 0, peakrecv = 0, peaktotal = 0;
|
||||||
int peakrecv = 0;
|
|
||||||
int y = 0;
|
int y = 0;
|
||||||
|
int i;
|
||||||
sorted_list_type screen_list;
|
sorted_list_type screen_list;
|
||||||
host_pair_line totals;
|
host_pair_line totals;
|
||||||
|
history_type history_totals;
|
||||||
|
|
||||||
if (!line || lcols != COLS) {
|
if (!line || lcols != COLS) {
|
||||||
xfree(line);
|
xfree(line);
|
||||||
@@ -174,6 +175,7 @@ void ui_print() {
|
|||||||
draw_bar_scale();
|
draw_bar_scale();
|
||||||
|
|
||||||
memset(&totals, 0, sizeof totals);
|
memset(&totals, 0, sizeof totals);
|
||||||
|
memset(&history_totals, 0, sizeof history_totals);
|
||||||
|
|
||||||
while(hash_next_item(history, &n) == HASH_STATUS_OK) {
|
while(hash_next_item(history, &n) == HASH_STATUS_OK) {
|
||||||
history_type* d = (history_type*)n->rec;
|
history_type* d = (history_type*)n->rec;
|
||||||
@@ -184,6 +186,7 @@ void ui_print() {
|
|||||||
|
|
||||||
screen_line = xcalloc(1, sizeof *screen_line);
|
screen_line = xcalloc(1, sizeof *screen_line);
|
||||||
screen_line->ap = (addr_pair*)n->key;
|
screen_line->ap = (addr_pair*)n->key;
|
||||||
|
|
||||||
|
|
||||||
for(i = 0; i < HISTORY_LENGTH; i++) {
|
for(i = 0; i < HISTORY_LENGTH; i++) {
|
||||||
int j;
|
int j;
|
||||||
@@ -195,7 +198,9 @@ void ui_print() {
|
|||||||
totals.recv[j] += d->recv[ii];
|
totals.recv[j] += d->recv[ii];
|
||||||
|
|
||||||
screen_line->sent[j] += d->sent[ii];
|
screen_line->sent[j] += d->sent[ii];
|
||||||
|
|
||||||
if(d->promisc == 1) {
|
if(d->promisc == 1) {
|
||||||
|
/* Treat all promisc traffic as incoming */
|
||||||
totals.recv[j] += d->sent[ii];
|
totals.recv[j] += d->sent[ii];
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
@@ -204,16 +209,30 @@ void ui_print() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(d->recv[ii] > peakrecv)
|
history_totals.recv[ii] += d->recv[ii];
|
||||||
peakrecv = d->recv[ii];
|
if(d->promisc == 1) {
|
||||||
if(d->sent[ii] > peaksent)
|
/* Treat all promisc traffic as incoming */
|
||||||
peaksent = d->sent[ii];
|
history_totals.recv[ii] += d->sent[ii];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
history_totals.sent[ii] += d->sent[ii];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sorted_list_insert(&screen_list, screen_line);
|
sorted_list_insert(&screen_list, screen_line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for(i = 0; i < HISTORY_LENGTH; i++) {
|
||||||
|
if(history_totals.recv[i] > peakrecv) {
|
||||||
|
peakrecv = history_totals.recv[i];
|
||||||
|
}
|
||||||
|
if(history_totals.sent[i] > peaksent) {
|
||||||
|
peaksent = history_totals.sent[i];
|
||||||
|
}
|
||||||
|
if(history_totals.recv[i] + history_totals.sent[i] > peaktotal) {
|
||||||
|
peaktotal = history_totals.recv[i] + history_totals.sent[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
y = 3;
|
y = 3;
|
||||||
|
|
||||||
@@ -226,7 +245,7 @@ void ui_print() {
|
|||||||
int x = 0, L;
|
int x = 0, L;
|
||||||
host_pair_line* screen_line = (host_pair_line*)nn->data;
|
host_pair_line* screen_line = (host_pair_line*)nn->data;
|
||||||
|
|
||||||
if(y < LINES - 5) {
|
if(y < LINES - 4) {
|
||||||
int t;
|
int t;
|
||||||
|
|
||||||
L = (COLS - 8 * HISTORY_DIVISIONS - 4) / 2;
|
L = (COLS - 8 * HISTORY_DIVISIONS - 4) / 2;
|
||||||
@@ -273,14 +292,27 @@ void ui_print() {
|
|||||||
|
|
||||||
|
|
||||||
y = LINES - 2;
|
y = LINES - 2;
|
||||||
mvaddstr(y, 0, "sent peak: ");
|
|
||||||
mvaddstr(y+1, 0, "recv ");
|
mvaddstr(y, 0, "total: ");
|
||||||
|
mvaddstr(y+1, 0, " peak: ");
|
||||||
|
|
||||||
|
readable_size((totals.recv[0] + totals.sent[0]) * 8 / RESOLUTION, line, 10, 1024);
|
||||||
|
mvaddstr(y, 8, line);
|
||||||
|
|
||||||
|
readable_size(peaktotal * 8 / RESOLUTION, line, 10, 1024);
|
||||||
|
mvaddstr(y+1, 8, line);
|
||||||
|
|
||||||
|
readable_size((peakrecv + peaksent) * 8 / RESOLUTION, line, 10, 1024);
|
||||||
|
mvaddstr(y+1, 8, line);
|
||||||
|
|
||||||
|
mvaddstr(y, 17, "sent: peak: ");
|
||||||
|
mvaddstr(y+1, 17, "recv: ");
|
||||||
|
|
||||||
readable_size(peaksent * 8 / RESOLUTION, line, 10, 1024);
|
readable_size(peaksent * 8 / RESOLUTION, line, 10, 1024);
|
||||||
mvaddstr(y, 15, line);
|
mvaddstr(y, 30, line);
|
||||||
|
|
||||||
readable_size(peakrecv * 8 / RESOLUTION, line, 10, 1024);
|
readable_size(peakrecv * 8 / RESOLUTION, line, 10, 1024);
|
||||||
mvaddstr(y+1, 15, line);
|
mvaddstr(y+1, 30, line);
|
||||||
|
|
||||||
mvaddstr(y, COLS - 8 * HISTORY_DIVISIONS - 10, "totals:");
|
mvaddstr(y, COLS - 8 * HISTORY_DIVISIONS - 10, "totals:");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user