spec file now generated with correct version number.
This commit is contained in:
1
CHANGES
1
CHANGES
@@ -8,6 +8,7 @@ Added service resolution toggle ("R")
|
|||||||
Added on-line help ("h")
|
Added on-line help ("h")
|
||||||
More fixes to rate display
|
More fixes to rate display
|
||||||
Improved interface selection (excludes lo:* and vmnet*)
|
Improved interface selection (excludes lo:* and vmnet*)
|
||||||
|
Added bandwidth-in-bytes option.
|
||||||
|
|
||||||
0.8
|
0.8
|
||||||
|
|
||||||
|
|||||||
6
Makefile
6
Makefile
@@ -59,7 +59,7 @@ uninstall:
|
|||||||
$(CC) $(CFLAGS) -c -o $@ $<
|
$(CC) $(CFLAGS) -c -o $@ $<
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f *~ *.o core iftop
|
rm -f *~ *.o core iftop iftop.spec
|
||||||
|
|
||||||
tarball: depend $(SRCS) $(HDRS) $(TXTS) $(SPECFILE)
|
tarball: depend $(SRCS) $(HDRS) $(TXTS) $(SPECFILE)
|
||||||
mkdir iftop-$(VERSION)
|
mkdir iftop-$(VERSION)
|
||||||
@@ -76,4 +76,8 @@ depend: $(SRCS)
|
|||||||
nodepend:
|
nodepend:
|
||||||
rm -f depend
|
rm -f depend
|
||||||
|
|
||||||
|
iftop.spec: iftop.spec.in Makefile
|
||||||
|
sed 's/__VERSION__/$(VERSION)/' < iftop.spec.in > iftop.spec
|
||||||
|
|
||||||
|
|
||||||
include depend
|
include depend
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
Summary: iftop - provides realtime bandwith usage on an interface
|
Summary: iftop - provides realtime bandwith usage on an interface
|
||||||
Name: iftop
|
Name: iftop
|
||||||
Version: 0.8
|
Version: __VERSION__
|
||||||
Release: 1
|
Release: 1
|
||||||
License: GPL
|
License: GPL
|
||||||
Group: Applications/Internet
|
Group: Applications/Internet
|
||||||
Source0: http://www.ex-parrot.com/~pdw/iftop/download/iftop-0.8.tar.gz
|
Source0: http://www.ex-parrot.com/~pdw/iftop/download/iftop-__VERSION__.tar.gz
|
||||||
URL: http://www.ex-parrot.com/~pdw/iftop/
|
URL: http://www.ex-parrot.com/~pdw/iftop/
|
||||||
Buildroot: %{_tmppath}/%{name}-%{version}-%(id -u -n)
|
Buildroot: %{_tmppath}/%{name}-%{version}-%(id -u -n)
|
||||||
Packager: Riku Meskanen <mesrik@cc.jyu.fi>
|
Packager: Riku Meskanen <mesrik@cc.jyu.fi>
|
||||||
@@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
options_t options;
|
options_t options;
|
||||||
|
|
||||||
char optstr[] = "+i:f:n:dhpbP";
|
char optstr[] = "+i:f:n:dhpbBP";
|
||||||
|
|
||||||
/* Global options. */
|
/* Global options. */
|
||||||
|
|
||||||
@@ -94,6 +94,7 @@ static void set_defaults() {
|
|||||||
options.aggregate_dest = 0;
|
options.aggregate_dest = 0;
|
||||||
options.paused = 0;
|
options.paused = 0;
|
||||||
options.showhelp = 0;
|
options.showhelp = 0;
|
||||||
|
options.bandwidth_in_bytes = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void die(char *msg) {
|
static void die(char *msg) {
|
||||||
@@ -156,6 +157,7 @@ static void usage(FILE *fp) {
|
|||||||
" -p run in promiscuous mode (show traffic between other\n"
|
" -p run in promiscuous mode (show traffic between other\n"
|
||||||
" hosts on the same network segment)\n"
|
" hosts on the same network segment)\n"
|
||||||
" -b don't display a bar graph of traffic\n"
|
" -b don't display a bar graph of traffic\n"
|
||||||
|
" -B Display bandwidth in bytes\n"
|
||||||
" -i interface listen on named interface\n"
|
" -i interface listen on named interface\n"
|
||||||
" -f filter code use filter code to select packets to count\n"
|
" -f filter code use filter code to select packets to count\n"
|
||||||
" (default: none, but only IP packets are counted)\n"
|
" (default: none, but only IP packets are counted)\n"
|
||||||
@@ -207,6 +209,9 @@ void options_read(int argc, char **argv) {
|
|||||||
options.showbars = 0;
|
options.showbars = 0;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case 'B':
|
||||||
|
options.bandwidth_in_bytes = 1;
|
||||||
|
break;
|
||||||
|
|
||||||
case '?':
|
case '?':
|
||||||
fprintf(stderr, "iftop: unknown option -%c\n", optopt);
|
fprintf(stderr, "iftop: unknown option -%c\n", optopt);
|
||||||
|
|||||||
@@ -10,11 +10,6 @@
|
|||||||
#include <netinet/in.h>
|
#include <netinet/in.h>
|
||||||
#include <arpa/inet.h>
|
#include <arpa/inet.h>
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
OPTION_AGGREGATE_OFF,
|
|
||||||
OPTION_AGGREGATE_SRC,
|
|
||||||
OPTION_AGGREGATE_DEST
|
|
||||||
} option_aggregate_t;
|
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
OPTION_PORTS_OFF,
|
OPTION_PORTS_OFF,
|
||||||
@@ -43,6 +38,7 @@ typedef struct {
|
|||||||
int aggregate_dest;
|
int aggregate_dest;
|
||||||
int paused;
|
int paused;
|
||||||
int showhelp;
|
int showhelp;
|
||||||
|
int bandwidth_in_bytes;
|
||||||
|
|
||||||
} options_t;
|
} options_t;
|
||||||
|
|
||||||
|
|||||||
23
ui.c
23
ui.c
@@ -47,7 +47,7 @@
|
|||||||
int history_divs[HISTORY_DIVISIONS] = {1, 5, 20};
|
int history_divs[HISTORY_DIVISIONS] = {1, 5, 20};
|
||||||
|
|
||||||
#define UNIT_DIVISIONS 4
|
#define UNIT_DIVISIONS 4
|
||||||
char* unit_bits[UNIT_DIVISIONS] = { "b", "K", "M", "G"};
|
char* unit_bits[UNIT_DIVISIONS] = { "b", "Kb", "Mb", "Gb"};
|
||||||
char* unit_bytes[UNIT_DIVISIONS] = { "B", "KB", "MB", "GB"};
|
char* unit_bytes[UNIT_DIVISIONS] = { "B", "KB", "MB", "GB"};
|
||||||
|
|
||||||
typedef struct host_pair_line_tag {
|
typedef struct host_pair_line_tag {
|
||||||
@@ -89,6 +89,11 @@ void readable_size(float n, char* buf, int bsize, int ksize, int bytes) {
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
float size = 1;
|
float size = 1;
|
||||||
|
|
||||||
|
/* Convert to bits? */
|
||||||
|
if(bytes == 0) {
|
||||||
|
n *= 8;
|
||||||
|
}
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
if(n < size * 1000 || i >= UNIT_DIVISIONS - 1) {
|
if(n < size * 1000 || i >= UNIT_DIVISIONS - 1) {
|
||||||
snprintf(buf, bsize, " %4.0f%s", n / size, bytes ? unit_bytes[i] : unit_bits[i]);
|
snprintf(buf, bsize, " %4.0f%s", n / size, bytes ? unit_bytes[i] : unit_bits[i]);
|
||||||
@@ -140,7 +145,7 @@ static void draw_bar_scale(int* y) {
|
|||||||
for (i = 1; i <= scale[rateidx].max; i *= scale[rateidx].interval) {
|
for (i = 1; i <= scale[rateidx].max; i *= scale[rateidx].interval) {
|
||||||
char s[40], *p;
|
char s[40], *p;
|
||||||
int x;
|
int x;
|
||||||
readable_size(i, s, sizeof s, 1000, 0);
|
readable_size(i / 8, s, sizeof s, 1000, 0);
|
||||||
p = s + strspn(s, " ");
|
p = s + strspn(s, " ");
|
||||||
x = get_bar_length(i);
|
x = get_bar_length(i);
|
||||||
mvaddch(*y + 1, x, ACS_BTEE);
|
mvaddch(*y + 1, x, ACS_BTEE);
|
||||||
@@ -171,10 +176,10 @@ void draw_line_totals(int y, host_pair_line* line) {
|
|||||||
|
|
||||||
for(j = 0; j < HISTORY_DIVISIONS; j++) {
|
for(j = 0; j < HISTORY_DIVISIONS; j++) {
|
||||||
t = history_length(j);
|
t = history_length(j);
|
||||||
readable_size(8 * line->sent[j] / t, buf, 10, 1024, 0);
|
readable_size(line->sent[j] / t, buf, 10, 1024, options.bandwidth_in_bytes);
|
||||||
mvaddstr(y, x, buf);
|
mvaddstr(y, x, buf);
|
||||||
|
|
||||||
readable_size(8 * line->recv[j] / t, buf, 10, 1024, 0);
|
readable_size(line->recv[j] / t, buf, 10, 1024, options.bandwidth_in_bytes);
|
||||||
mvaddstr(y+1, x, buf);
|
mvaddstr(y+1, x, buf);
|
||||||
x += 8;
|
x += 8;
|
||||||
}
|
}
|
||||||
@@ -462,13 +467,13 @@ void ui_print() {
|
|||||||
mvaddstr(y, 0, "total: ");
|
mvaddstr(y, 0, "total: ");
|
||||||
mvaddstr(y+1, 0, " peak: ");
|
mvaddstr(y+1, 0, " peak: ");
|
||||||
|
|
||||||
readable_size((totals.recv[0] + totals.sent[0]) * 8 / RESOLUTION, line, 10, 1024, 0);
|
readable_size((totals.recv[0] + totals.sent[0]) / RESOLUTION, line, 10, 1024, options.bandwidth_in_bytes);
|
||||||
mvaddstr(y, 8, line);
|
mvaddstr(y, 8, line);
|
||||||
|
|
||||||
readable_size(peaktotal * 8 / RESOLUTION, line, 10, 1024, 0);
|
readable_size(peaktotal / RESOLUTION, line, 10, 1024, options.bandwidth_in_bytes);
|
||||||
mvaddstr(y+1, 8, line);
|
mvaddstr(y+1, 8, line);
|
||||||
|
|
||||||
readable_size((peakrecv + peaksent) * 8 / RESOLUTION, line, 10, 1024, 0);
|
readable_size((peakrecv + peaksent) / RESOLUTION, line, 10, 1024, options.bandwidth_in_bytes);
|
||||||
mvaddstr(y+1, 8, line);
|
mvaddstr(y+1, 8, line);
|
||||||
|
|
||||||
mvaddstr(y, 18, "TX: ");
|
mvaddstr(y, 18, "TX: ");
|
||||||
@@ -484,10 +489,10 @@ void ui_print() {
|
|||||||
/* Peak traffic */
|
/* Peak traffic */
|
||||||
mvaddstr(y, 33, "peaks: ");
|
mvaddstr(y, 33, "peaks: ");
|
||||||
|
|
||||||
readable_size(peaksent * 8 / RESOLUTION, line, 10, 1024, 0);
|
readable_size(peaksent / RESOLUTION, line, 10, 1024, options.bandwidth_in_bytes);
|
||||||
mvaddstr(y, 39, line);
|
mvaddstr(y, 39, line);
|
||||||
|
|
||||||
readable_size(peakrecv * 8 / RESOLUTION, line, 10, 1024, 0);
|
readable_size(peakrecv / RESOLUTION, line, 10, 1024, options.bandwidth_in_bytes);
|
||||||
mvaddstr(y+1, 39, line);
|
mvaddstr(y+1, 39, line);
|
||||||
|
|
||||||
mvaddstr(y, COLS - 8 * HISTORY_DIVISIONS - 8, "totals:");
|
mvaddstr(y, COLS - 8 * HISTORY_DIVISIONS - 8, "totals:");
|
||||||
|
|||||||
Reference in New Issue
Block a user