netcount is a package for logging and displaying PPP network traffic on Linux machines. Logging is done via a small shell script which is called during the ip-up, ip-down and system startup processes and from cron, while analysis and printing is done by a program written in Python.
The following snippet shows an example of its typical output:
Date Time Rx Bytes Tx Bytes Rx Tx Length
Mon -02-03 8:53:46 2.412 0.114MB 9.77 0.46kB/s 0:04:07h
Mon -02-03 10:43:33 0.009 0.005MB 0.04 0.02kB/s 0:03:41h
[...]
Mon -02-03 20:54:16 0.851 0.181MB 0.93 0.20kB/s 0:15:17h
Mon -02-03 21:14:51 0.719 0.120MB 0.79 0.13kB/s 0:15:08h
Mon -02-03 22:37:29 0.267 0.045MB 0.70 0.12kB/s 0:06:18h
Mon -02-03 22:55:11 0.050 0.008MB 0.21 0.03kB/s 0:03:51h
Mon -02-03 23:04:50 0.152 0.022MB 0.49 0.07kB/s 0:05:12h
Mon -02-03 23:10:29 0.091 0.020MB 0.35 0.08kB/s 0:04:19h
Mon -02-03 23:37:31 2.011 0.100MB 5.80 0.29kB/s 0:05:47h
Mon -02-03 23:43:18 0.000 0.000MB 0.00 0.00kB/s 0:00:01h
-------------------------------------------------------------------------------
Mon -02-03 11.619 1.149MB 1.48 0.15kB/s 2:10:39h
7.92% 67.50%
|
The display is highly customizable. You can select from different types of records as well as from different columns to print. netcount shows, among other things, network uptime, byte counts and transmission speeds (either as Tx and Rx bytes or summed up). Command line options also allow you to select from per-connection summaries as well as from daily and monthly summaries and from uptime and byte count percentages with respect to a daily and monthly total. These settings can be made permanent through the use of a configuration file which is written using a simple command line option.
netcount uses the kernel's ppp0 counter (found in /proc/net/dev), so packet filtering does not need to be installed. It is safe against this counter's overflow, so there is no 2 or 4 GiB limit. It should work under any flavor of Linux, including other families than the x86 systems.
You might want to have a look at its man page to see more of its features. See below for installation, download and version history.
nstat is an X application which comes with netcount. Depending on PPP network state, it shows one of the following four symbolic icons:
| PPP networking is off (pppd not running) | |
| ready for dialing out (and for auto dialing, if configured) | |
| on line, currently no traffic | |
| on line, traffic going through the PPP interface |
The numbers beneath the icon show the connection time in hh:mm:ss format. Clicking on the window pops up an option menu, which, depending on permissions and network state, allows you to select from starting pppd, terminating pppd, hanging up and exiting nstat.
Besides displaying and changing pppd's state, nstat offers several options which might be useful in some situations like automatically restarting pppd if it dies or hanging up after an idle time just before the end of the current minute. You can look them up here in the man page.
nstat is packaged with netcount since they share the same logging facility.
There isn't much congruence among distributions on the system services netcount and nstat use — there are many different ways in which they are implemented. A Makefile is provided which does the installation for the Debian, RedHat, SuSE, Mandrake and Slackware distributions. For other systems, you can do a manual installation which is described as well.
You may want to have a look at the INSTALL file for installation
details, especially the prerequisites, beforehand. Or you might want
to see the netcount man
page and the nstat man
page for their features and weaknesses.
netcount and nstat cannot be used if more than one PPP connection is run at the same time. They don't cooperate with ipppd (the ISDN pppd daemon) but work with ISDN CAPI interfaces.
If you want to download netcount (which
includes nstat), here it is as a gzipped tar file. Current
version is
v0.8i. Run it through tar xvzf
netcount-x.xx.tar.gz, then cd to the
newly created netcount-x.xx directory and
follow the instructions found in the file
INSTALL.
netcount is published under the terms and conditions of the GPL, version 2.
I hope you'll find this package useful. You can reach me at hcz@hczim.de.
Since netcount and nstat are packaged together, they share a common version numbering scheme.
2004-11-28 Warning to Debian users: The pppd version now in sid/unstable (2.4.2+20040428-5 0) introduced changes in the behaviour of environment variables which break netcount. For now, you better stay with the versions found in the testing or stable distributions.
2004-12-29 The forementioned pppd now has been moved to
sarge. If you get ridiculously high traffic counts, you've
possibly have been bitten by this.
Unfortunately, pppd --version doesn't reflect
any change and netcount also has no other chance to detect
the change at runtime. For now, you'd better
not update your ppp package but stay with
2.4.2+20040428-3. Things are being discussed with the
author.
distro-detect.sh was missing
from the distribution. Sorry for that.grep boot-down
/var/log/netcount/netcount.log, you definitely
should install it. This is the only known severe bug. It
seems to have evolved partly due to changes in the
kernel's scheduler and faster systems, but may have other
causes too.exit 0 now removed before
appending new content to script files.make uninstall now also cleans up
netcount parts in foreign script files