[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Patch for avg flow rate logging problem
Hi there,
being new on this list (and with Iptraf altogether) I hope this isn't any
known old problem or user error, but there seems to be a bug with Iptraf
(flow rate) logging.
It happens with (at least) Iptraf 2.7.0 while logging interface statistics
into a file, the flow rate is always 0.00 kbits/sec (or kbytes/sec).
A similar issue touching this problem was on the list in May 2002, but the
flow rate problems mentioned there seem to have an influence on some
interactive monitoring screen only, and not with log files like I have
encountered.
http://archives.seul.org/iptraf/users/May-2002/msg00001.html
I'm using Iptraf always in the background to log all network traffic
through a firewall, it is started like this:
iptraf -f -B -i eth1
Anyway, here is a little patch which I think fixes the problem:
--- ../iptraf-2.7.0/src/tcptable.c Wed May 8 04:36:27 2002
+++ src/tcptable.c Sat Jan 11 13:37:24 2003
@@ -447,25 +447,26 @@
static char message[60];
time_t interval;
- interval = time(NULL) / (float) (entry->conn_starttime - time(NULL));
+ interval = time(NULL) - entry->conn_starttime;
if (opts->actmode == KBITS) {
strcpy(rateunit, "kbits/s");
if (interval > 0)
- rate = (float) (entry->bcount * 8 / 1000) / (float)
interval;
+ rate = ((float)entry->bcount*8.0f/1000.0f) /
(float)interval;
else
rate = 0.00;
} else {
strcpy(rateunit, "kbytes/s");
if (interval > 0)
- rate = (float) (entry->bcount / 1024) / (float) interval;
+ rate = ((float)entry->bcount/1024.0f) / (float)interval;
else
rate = 0.00;
}
snprintf(message, 60, "avg flow rate %.2f %s", rate, rateunit);
+
return message;
}
--
Kimmo Mösö phone: +358-40-5336628
Kastanjakuja 3 B 46 email: kmoso@nospam-cc.hut.fi
01710 Vantaa, Finland http://www.hut.fi/~kmoso/