Updated units display (again). This time goes up to GB.
Spec file to 0.8.
This commit is contained in:
2
TODO
2
TODO
@@ -1,6 +1,8 @@
|
|||||||
Things to do for iftop
|
Things to do for iftop
|
||||||
$Id$
|
$Id$
|
||||||
|
|
||||||
|
* Turn off services resolution.
|
||||||
|
|
||||||
* IP types other than v4?
|
* IP types other than v4?
|
||||||
|
|
||||||
* Which average to use for the bar graph? Show several and peaks? Colours?
|
* Which average to use for the bar graph? Show several and peaks? Colours?
|
||||||
|
|||||||
@@ -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.8pre1
|
Version: 0.8
|
||||||
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.8pre1.tar.gz
|
Source0: http://www.ex-parrot.com/~pdw/iftop/download/iftop-0.8.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>
|
||||||
|
|||||||
44
ui.c
44
ui.c
@@ -27,6 +27,9 @@
|
|||||||
/* 1, 15 and 60 seconds */
|
/* 1, 15 and 60 seconds */
|
||||||
int history_divs[HISTORY_DIVISIONS] = {1, 5, 20};
|
int history_divs[HISTORY_DIVISIONS] = {1, 5, 20};
|
||||||
|
|
||||||
|
#define UNIT_DIVISIONS 4
|
||||||
|
char* unit_bits[UNIT_DIVISIONS] = { "b", "K", "M", "G"};
|
||||||
|
char* unit_bytes[UNIT_DIVISIONS] = { "B", "KB", "MB", "GB"};
|
||||||
|
|
||||||
typedef struct host_pair_line_tag {
|
typedef struct host_pair_line_tag {
|
||||||
addr_pair ap;
|
addr_pair ap;
|
||||||
@@ -63,27 +66,26 @@ int screen_line_compare(void* a, void* b) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void readable_size(float n, char* buf, int bsize, int ksize, int bytes) {
|
void readable_size(float n, char* buf, int bsize, int ksize, int bytes) {
|
||||||
if(n >= 100 * ksize * ksize) {
|
|
||||||
snprintf(buf, bsize, " %4.0f%s", n / (ksize * ksize), bytes ? "MB" : "M");
|
int i = 0;
|
||||||
}
|
int size = 1;
|
||||||
else if(n >= 10 * ksize * ksize) {
|
|
||||||
snprintf(buf, bsize, " %4.1f%s", n / (ksize * ksize), bytes ? "MB" : "M");
|
while(1) {
|
||||||
}
|
if(n < size * ksize || i >= UNIT_DIVISIONS - 1) {
|
||||||
if(n >= ksize * ksize) {
|
snprintf(buf, bsize, " %4.0f%s", n / size, bytes ? unit_bytes[i] : unit_bits[i]);
|
||||||
snprintf(buf, bsize, " %4.2f%s", n / (ksize * ksize), bytes ? "MB" : "M" );
|
break;
|
||||||
}
|
}
|
||||||
else if(n >= 100 * ksize) {
|
i++;
|
||||||
snprintf(buf, bsize, " %4.0f%s", n / ksize, bytes ? "KB" : "K" );
|
size *= ksize;
|
||||||
}
|
if(n < size * 10) {
|
||||||
else if(n >= 10 * ksize) {
|
snprintf(buf, bsize, " %4.2f%s", n / size, bytes ? unit_bytes[i] : unit_bits[i]);
|
||||||
snprintf(buf, bsize, " %4.1f%s", n / ksize, bytes ? "KB" : "K" );
|
break;
|
||||||
}
|
}
|
||||||
else if(n >= ksize) {
|
else if(n < size * 100) {
|
||||||
snprintf(buf, bsize, " %4.2f%s", n / ksize, bytes ? "KB" : "K" );
|
snprintf(buf, bsize, " %4.1f%s", n / size, bytes ? unit_bytes[i] : unit_bits[i]);
|
||||||
}
|
break;
|
||||||
else {
|
}
|
||||||
snprintf(buf, bsize, " %4.0f%s", n, bytes ? "B" : "b");
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user