PDA

View Full Version : traffic count



shtik
17th July 2004, 05:31 AM
hi,

i'm on dsl and wonder if there is a program in linux which will count the amount of transferred and received bytes over my internet connection (used via router, so no dial-up program will work). it would be nice to know if it makes sense to switch towards a volume based price model, so i need to know how much traffic do i need.

any ideas?

shtik

ilja
17th July 2004, 05:41 AM
How many computers do you have?
If only one: http://dmr.ath.cx/net/darkstat/ looks nice. Rpms you can get here (http://dag.wieers.com/packages/darkstat/) Or with yum/apt using DAG Repository.

rogue
17th July 2004, 05:42 AM
The quick and easy way would be to look at the RX/TX bytes from /sbin/ifconfig... the fields roll over like an odometer (it's a 32 bit int) so you might need to watch for that.

shtik
17th July 2004, 09:35 AM
darkstat looks nice! also it's build to run on a router, and my pc is not a router, i hope it will work. i'm using a switch to share my internet connection, so hopefully it will simply recognize only the traffic my computer creates ...

the solution w/ ifconfig seems to be a very basic working version, but in my case it won't help since i would like to make a monthly statistic, and ifconfig values are reseted with every reboot.

so, i would like to give darkstat a try, how could i manage to start it automatically on boot (as root user)? is it possible to make an entry in /etc/rc.d/rc.local, or is it better to make an init script or something similar?

thanks for helping
shtik

rogue
17th July 2004, 11:38 AM
Reboot... what's that? ;)

[rogue@nicotine rogue]$ uptime
5:32pm up 173 days, 17:23, 1 user, load average: 0.03, 0.01, 0.08

I'd go with an init script... this topic (http://www.fedoraforum.org/forum/showthread.php?t=18584) should help get you started.

shtik
19th July 2004, 01:45 AM
nice uptime, i usually don't get values over 4h ...

thanks for the hint with initscripts, unfortunatly it won't start darkstat, my script looks like following:



#!/bin/bash
# darkstat network analyzer (paket sniffer)
# chkconfig: 345 95 80
# description: Darkstat is a network analyzer

# Source function library.
. /etc/rc.d/init.d/functions
prog="darkstat"

case "$1" in
start)
echo -n $"Starting $prog"
daemon /usr/sbin/darkstat --detach
touch /var/lock/subsys/darkstat
echo
;;
stop)
echo -n $"Shutting down darkstat"
killproc darkstat
rm -f /var/lock/subsys/darkstat
echo
;;
restart)
# insert commands to run when this script is restarted
$0 stop
$0 start
;;
reload)
# usually the same as restart
$0 restart
;;
*)
# all other options
echo "Usage: $0 {start|stop|restart|reload}"
esac


it's listed in runlevels 3-5, it even says status ok when changing rl, but it doesn't start darkstat, maybe you could help me with this one, too? -thanks

shtik

kosmosik
19th July 2004, 01:54 AM
http://robert.cheramy.net/ipfm/
http://scripfm.sourceforge.net/

Szpak
19th July 2004, 04:01 AM
I agree with Kosmosik. ipfm and scr_ipfm are nice tools. Additionally I can recommend lstat (http://lstat.sf.net/) I you want to have time dependent stats.

Szpak