*** empty log message ***
This commit is contained in:
5
CHANGES
5
CHANGES
@@ -1,6 +1,11 @@
|
||||
Change log for iftop
|
||||
$Id$
|
||||
|
||||
0.12
|
||||
|
||||
Added 1-line display options.
|
||||
Added display scrolling.
|
||||
|
||||
0.11 08/01/03
|
||||
|
||||
Added support for token ring networks
|
||||
|
||||
7
TODO
7
TODO
@@ -1,9 +1,7 @@
|
||||
Things to do for iftop
|
||||
$Id$
|
||||
|
||||
* 1-line per host display
|
||||
|
||||
* Up and down arrows to scroll through host list
|
||||
* Attempt to assign direction based on IP of selected interface for DLT_RAW.
|
||||
|
||||
* Search for BSD interface names - need to know what to look for.
|
||||
|
||||
@@ -18,6 +16,3 @@ $Id$
|
||||
|
||||
* Configurable refresh rates.
|
||||
|
||||
* Filtering of items included in diplay
|
||||
|
||||
* Attempt to assign direction based on IP of selected interface for DLT_RAW.
|
||||
|
||||
@@ -17,7 +17,7 @@ dnl
|
||||
AC_INIT(iftop.c)
|
||||
AC_CONFIG_AUX_DIR(config)
|
||||
AM_CONFIG_HEADER(config.h)
|
||||
AM_INIT_AUTOMAKE(iftop, "0.11")
|
||||
AM_INIT_AUTOMAKE(iftop, "0.12pre1")
|
||||
|
||||
AC_DEFINE_UNQUOTED(IFTOP_VERSION, "$VERSION", [The iftop version number])
|
||||
|
||||
|
||||
25
iftop.8
25
iftop.8
@@ -128,6 +128,12 @@ machine.
|
||||
\fBS\fP or \fBD\fP toggle the display of source and destination ports
|
||||
respectively. \fBp\fP will toggle port display on/off.
|
||||
|
||||
.SH DISPLAY TYPE
|
||||
|
||||
\fBt\fP cycles through the four line display modes; the default 2-line display,
|
||||
with sent and received traffic on separate lines, and 3 1-line displays, with
|
||||
sent, received, or total traffic shown.
|
||||
|
||||
.SH DISPLAY ORDER
|
||||
|
||||
By default, the display is ordered according to the 10s average (2nd column).
|
||||
@@ -140,7 +146,8 @@ source or destination hostname respectively.
|
||||
\fBl\fP allows you to enter a POSIX extended regular expression that will be
|
||||
used to filter hostnames shown in the display. This is a good way to quickly
|
||||
limit what is shown on the display. Note that this happens at a much later
|
||||
stage than filter code, and does not affect what is actually captured.
|
||||
stage than filter code, and does not affect what is actually captured. Display
|
||||
filters DO NOT affect the totals at the bottom of the screen.
|
||||
|
||||
.SH PAUSE DISPLAY / FREEZE ORDER
|
||||
|
||||
@@ -150,6 +157,11 @@ stage than filter code, and does not affect what is actually captured.
|
||||
traffic between hosts not shown on the screen at the time will not be shown at
|
||||
all, although it will be included in the totals at the bottom of the screen.
|
||||
|
||||
.SH SCROLL DISPLAY
|
||||
|
||||
\fBj\fP and \fBk\fP will scroll the display of hosts. This feature is most
|
||||
useful when the display order is frozen (see above).
|
||||
|
||||
.SH FILTER CODE
|
||||
|
||||
\fBf\fP allows you to edit the filter code whilst iftop running. This
|
||||
@@ -170,11 +182,12 @@ you, but is included in the totals.
|
||||
|
||||
A more subtle explanation comes about when running in promiscuous mode
|
||||
without specifying a \fB-N\fP option. In this case there is no easy way
|
||||
to assign the direction of traffic between two other hosts. For the
|
||||
purposes of the main display this is done in an arbitrary fashion (by
|
||||
ordering of IP addresses), but for the sake of totals all traffic
|
||||
between other hosts is accounted as incoming, because that's what it is
|
||||
from the point of view of your interface.
|
||||
to assign the direction of traffic between two third parties. For the purposes
|
||||
of the main display this is done in an arbitrary fashion (by ordering of IP
|
||||
addresses), but for the sake of totals all traffic between other hosts is
|
||||
accounted as incoming, because that's what it is from the point of view of your
|
||||
interface. The \fB-N\fP option allows you to specify an arbitrary network
|
||||
boundary, and to show traffic flowing across it.
|
||||
|
||||
\fBPeak totals don't add up\fP
|
||||
|
||||
|
||||
2
iftop.h
2
iftop.h
@@ -20,7 +20,7 @@ typedef struct {
|
||||
int last_write;
|
||||
} history_type;
|
||||
|
||||
void tick(void);
|
||||
void tick(int print);
|
||||
|
||||
void *xmalloc(size_t n);
|
||||
void *xcalloc(size_t n, size_t m);
|
||||
|
||||
@@ -98,6 +98,8 @@ static void set_defaults() {
|
||||
options.sort = OPTION_SORT_DIV2;
|
||||
options.screenfilter = NULL;
|
||||
options.freezeorder = 0;
|
||||
options.linedisplay = OPTION_LINEDISPLAY_TWO_LINE;
|
||||
options.screen_offset = 0;
|
||||
}
|
||||
|
||||
static void die(char *msg) {
|
||||
|
||||
11
options.h
11
options.h
@@ -26,6 +26,13 @@ typedef enum {
|
||||
OPTION_SORT_DEST
|
||||
} option_sort_t;
|
||||
|
||||
typedef enum {
|
||||
OPTION_LINEDISPLAY_TWO_LINE,
|
||||
OPTION_LINEDISPLAY_ONE_LINE_BOTH,
|
||||
OPTION_LINEDISPLAY_ONE_LINE_RECV,
|
||||
OPTION_LINEDISPLAY_ONE_LINE_SENT
|
||||
} option_linedisplay_t;
|
||||
|
||||
typedef struct {
|
||||
/* interface on which to listen */
|
||||
char *interface;
|
||||
@@ -52,6 +59,10 @@ typedef struct {
|
||||
char* screenfilter;
|
||||
int freezeorder;
|
||||
|
||||
int screen_offset;
|
||||
|
||||
option_linedisplay_t linedisplay;
|
||||
|
||||
} options_t;
|
||||
|
||||
#endif /* __OPTIONS_H_ */
|
||||
|
||||
162
ui.c
162
ui.c
@@ -38,6 +38,7 @@
|
||||
" r - toggle DNS host resolution P - pause display\n"\
|
||||
" s - toggle show source host h - toggle this help display\n"\
|
||||
" d - toggle show destination host b - toggle bar graph display\n"\
|
||||
" t - cycle line display mode j/k - scroll display\n"\
|
||||
" f - edit filter code\n"\
|
||||
"Port display: l - set screen filter\n"\
|
||||
" R - toggle service resolution ! - shell command\n"\
|
||||
@@ -245,30 +246,60 @@ int history_length(const int d) {
|
||||
return history_divs[d] * RESOLUTION;
|
||||
}
|
||||
|
||||
void draw_line_totals(int y, host_pair_line* line) {
|
||||
int j, L;
|
||||
void draw_line_total(float n, int y, int x) {
|
||||
char buf[10];
|
||||
readable_size(n, buf, 10, 1024, options.bandwidth_in_bytes);
|
||||
mvaddstr(y, x, buf);
|
||||
}
|
||||
|
||||
void draw_bar(float n, int y) {
|
||||
int L;
|
||||
mvchgat(y, 0, -1, A_NORMAL, 0, NULL);
|
||||
L = get_bar_length(8 * n);
|
||||
if (L > 0)
|
||||
mvchgat(y, 0, L + 1, A_REVERSE, 0, NULL);
|
||||
}
|
||||
|
||||
void draw_line_totals(int y, host_pair_line* line, option_linedisplay_t linedisplay) {
|
||||
int j;
|
||||
int x = (COLS - 8 * HISTORY_DIVISIONS);
|
||||
|
||||
for(j = 0; j < HISTORY_DIVISIONS; j++) {
|
||||
readable_size(line->sent[j], buf, 10, 1024, options.bandwidth_in_bytes);
|
||||
mvaddstr(y, x, buf);
|
||||
switch(linedisplay) {
|
||||
case OPTION_LINEDISPLAY_TWO_LINE:
|
||||
draw_line_total(line->sent[j], y, x);
|
||||
draw_line_total(line->recv[j], y+1, x);
|
||||
break;
|
||||
case OPTION_LINEDISPLAY_ONE_LINE_SENT:
|
||||
draw_line_total(line->sent[j], y, x);
|
||||
break;
|
||||
case OPTION_LINEDISPLAY_ONE_LINE_RECV:
|
||||
draw_line_total(line->recv[j], y, x);
|
||||
break;
|
||||
case OPTION_LINEDISPLAY_ONE_LINE_BOTH:
|
||||
draw_line_total(line->recv[j] + line->sent[j], y, x);
|
||||
break;
|
||||
}
|
||||
|
||||
readable_size(line->recv[j], buf, 10, 1024, options.bandwidth_in_bytes);
|
||||
mvaddstr(y+1, x, buf);
|
||||
x += 8;
|
||||
x += 8;
|
||||
}
|
||||
|
||||
if(options.showbars) {
|
||||
mvchgat(y, 0, -1, A_NORMAL, 0, NULL);
|
||||
L = get_bar_length(8 * line->sent[BARGRAPH_INTERVAL] );
|
||||
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] );
|
||||
if (L > 0)
|
||||
mvchgat(y+1, 0, L + 1, A_REVERSE, 0, NULL);
|
||||
switch(linedisplay) {
|
||||
case OPTION_LINEDISPLAY_TWO_LINE:
|
||||
draw_bar(line->sent[BARGRAPH_INTERVAL],y);
|
||||
draw_bar(line->recv[BARGRAPH_INTERVAL],y+1);
|
||||
break;
|
||||
case OPTION_LINEDISPLAY_ONE_LINE_SENT:
|
||||
draw_bar(line->sent[BARGRAPH_INTERVAL],y);
|
||||
break;
|
||||
case OPTION_LINEDISPLAY_ONE_LINE_RECV:
|
||||
draw_bar(line->recv[BARGRAPH_INTERVAL],y);
|
||||
break;
|
||||
case OPTION_LINEDISPLAY_ONE_LINE_BOTH:
|
||||
draw_bar(line->recv[BARGRAPH_INTERVAL] + line->sent[BARGRAPH_INTERVAL],y);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -279,7 +310,7 @@ void draw_totals(host_pair_line* totals) {
|
||||
char buf[10];
|
||||
int x = (COLS - 8 * HISTORY_DIVISIONS);
|
||||
y++;
|
||||
draw_line_totals(y, totals);
|
||||
draw_line_totals(y, totals, OPTION_LINEDISPLAY_TWO_LINE);
|
||||
y += 2;
|
||||
for(j = 0; j < HISTORY_DIVISIONS; j++) {
|
||||
readable_size((totals->sent[j] + totals->recv[j]) , buf, 10, 1024, options.bandwidth_in_bytes);
|
||||
@@ -513,44 +544,69 @@ void ui_print() {
|
||||
mvaddstr(y,0,HELP_MESSAGE);
|
||||
}
|
||||
else {
|
||||
int i = 0;
|
||||
|
||||
while(i < options.screen_offset && ((nn = sorted_list_next_item(&screen_list, nn)) != NULL)) {
|
||||
i++;
|
||||
}
|
||||
|
||||
/* Screen layout: we have 2 * HISTORY_DIVISIONS 6-character wide history
|
||||
* items, and so can use COLS - 12 * HISTORY_DIVISIONS to print the two
|
||||
* host names. */
|
||||
|
||||
while((y < LINES - 5) && ((nn = sorted_list_next_item(&screen_list, nn)) != NULL)) {
|
||||
int x = 0, L;
|
||||
if(i == 0 || nn != NULL) {
|
||||
while((y < LINES - 5) && ((nn = sorted_list_next_item(&screen_list, nn)) != NULL)) {
|
||||
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) {
|
||||
L = (COLS - 8 * HISTORY_DIVISIONS - 4) / 2;
|
||||
if(L > HOSTNAME_LENGTH) {
|
||||
L = HOSTNAME_LENGTH;
|
||||
}
|
||||
if(y < LINES - 5) {
|
||||
L = (COLS - 8 * HISTORY_DIVISIONS - 4) / 2;
|
||||
if(L > HOSTNAME_LENGTH) {
|
||||
L = HOSTNAME_LENGTH;
|
||||
}
|
||||
|
||||
sprint_host(host1, &(screen_line->ap.src), screen_line->ap.src_port, screen_line->ap.protocol, L);
|
||||
sprint_host(host2, &(screen_line->ap.dst), screen_line->ap.dst_port, screen_line->ap.protocol, L);
|
||||
if(!screen_filter_match(host1) && !screen_filter_match(host2)) {
|
||||
continue;
|
||||
}
|
||||
sprint_host(host1, &(screen_line->ap.src), screen_line->ap.src_port, screen_line->ap.protocol, L);
|
||||
sprint_host(host2, &(screen_line->ap.dst), screen_line->ap.dst_port, screen_line->ap.protocol, L);
|
||||
if(!screen_filter_match(host1) && !screen_filter_match(host2)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mvaddstr(y, x, host1);
|
||||
x += L;
|
||||
mvaddstr(y, x, host1);
|
||||
x += L;
|
||||
|
||||
mvaddstr(y, x, " => ");
|
||||
mvaddstr(y+1, x, " <= ");
|
||||
switch(options.linedisplay) {
|
||||
case OPTION_LINEDISPLAY_TWO_LINE:
|
||||
mvaddstr(y, x, " => ");
|
||||
mvaddstr(y+1, x, " <= ");
|
||||
break;
|
||||
case OPTION_LINEDISPLAY_ONE_LINE_BOTH:
|
||||
mvaddstr(y, x, "<=> ");
|
||||
break;
|
||||
case OPTION_LINEDISPLAY_ONE_LINE_SENT:
|
||||
mvaddstr(y, x, " => ");
|
||||
break;
|
||||
case OPTION_LINEDISPLAY_ONE_LINE_RECV:
|
||||
mvaddstr(y, x, " <= ");
|
||||
break;
|
||||
}
|
||||
|
||||
x += 4;
|
||||
x += 4;
|
||||
|
||||
|
||||
mvaddstr(y, x, host2);
|
||||
mvaddstr(y, x, host2);
|
||||
|
||||
draw_line_totals(y, screen_line);
|
||||
draw_line_totals(y, screen_line, options.linedisplay);
|
||||
|
||||
}
|
||||
y += 2;
|
||||
}
|
||||
if(options.linedisplay == OPTION_LINEDISPLAY_TWO_LINE) {
|
||||
y += 2;
|
||||
}
|
||||
else {
|
||||
y += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -831,6 +887,34 @@ void ui_loop() {
|
||||
options.sort = OPTION_SORT_DEST;
|
||||
showhelp("Sort by dest");
|
||||
break;
|
||||
case 'j':
|
||||
options.screen_offset++;
|
||||
ui_print();
|
||||
break;
|
||||
case 'k':
|
||||
if(options.screen_offset > 0) {
|
||||
options.screen_offset--;
|
||||
ui_print();
|
||||
}
|
||||
break;
|
||||
case 't':
|
||||
options.linedisplay = (options.linedisplay + 1) % 4;
|
||||
switch(options.linedisplay) {
|
||||
case OPTION_LINEDISPLAY_TWO_LINE:
|
||||
showhelp("Two lines per host");
|
||||
break;
|
||||
case OPTION_LINEDISPLAY_ONE_LINE_SENT:
|
||||
showhelp("Sent traffic only");
|
||||
break;
|
||||
case OPTION_LINEDISPLAY_ONE_LINE_RECV:
|
||||
showhelp("Received traffic only");
|
||||
break;
|
||||
case OPTION_LINEDISPLAY_ONE_LINE_BOTH:
|
||||
showhelp("One line per host");
|
||||
break;
|
||||
}
|
||||
ui_print();
|
||||
break;
|
||||
case 'f': {
|
||||
char *s;
|
||||
dontshowdisplay = 1;
|
||||
|
||||
Reference in New Issue
Block a user