Koozali.org: home of the SME Server

measure gateway traffic?

Rob Wellesley

measure gateway traffic?
« on: June 30, 2003, 04:47:28 PM »
Hi all

I need a way to monitor total traffic sent and recieved thru the external NIC.

ISP's charge for traffic at a bytes per month rate. I would like to be able to have a process monitor traffic from, say, July 10 to August 10 and then report on the volume for that month, reset, and start again. Ideally, I would be able to set an "alarm" limit at which a message would be generated indicating that a preset limit for the month had already been reached.

Any one got any any ideas??

Cheers..  Rob

Michiel Blotwijk

Re: measure gateway traffic?
« Reply #1 on: June 30, 2003, 05:45:38 PM »
I suggst you search this forum. This topic pops up every three weeks or so.
M.

Dave Liquorice

Re: measure gateway traffic?
« Reply #2 on: June 30, 2003, 05:55:14 PM »
Hi Rob,

Quick 'n dirty:

ifconfig {your_external_port_name} will return how much data has passed through that interface since  boot up. It should be fairly easy to write a bit of Perl to parse that, store the relevant values in a file between runs and do the maths and/or generate an e-mail on subsequent runs. Call it every day or WHY via cron.

The hard bit will be producing correct information if the server gets rebooted, firstly something will have to placed into the shutdown sequence to store the value before the system stops. Also the assumption that if the value from ifconfig is less than the stored value the system has been rebooted, so just add the current and stored value, isn't 100% safe.

Cheers
Dave.

jonathan storey

Re: measure gateway traffic?
« Reply #3 on: June 30, 2003, 06:52:55 PM »
You'll also need to take into account the up, down nature of the ppp device if you're not using a fixed ip - could log to a file every 5 mins, or when the link goes down.

Dave Liquorice

Re: measure gateway traffic?
« Reply #4 on: June 30, 2003, 07:17:04 PM »
Ah, I was thinking of my connection which is permenant rather than dialup... Could add something to ip-down but is that before or after the interface disappears?

Cheers
Dave.

krusty

Re: measure gateway traffic?
« Reply #5 on: July 03, 2003, 04:40:59 PM »
Why not try Netprobe?  With this you can monitor traffic in and out through either eth0 or eth1 or eth2 or all of them as long as the server is not rebooted you can view the quantities downloaded or uploaded and copy and save the files. These reports can be wiewed in a web browser on a windows machine within the same network.'



http://mirror.contribs.org/smeserver/contribs/cbharda/howto/netprobe-howto.htm

krusty

Re: measure gateway traffic?
« Reply #6 on: July 03, 2003, 04:50:46 PM »
by the way there is one small problem with the file for netprobe to start up on reboot. It doesn't work unless you delete the script and rewrite it on the machine you are running netprobe on. Once you do this it works as you are told. So enjoy!

Cyrus Bharda

Re: measure gateway traffic?
« Reply #7 on: July 04, 2003, 02:32:21 AM »
Krusty,

Yeah that was my bad, edited in in windows notepad before uploading it, I will upload a working file asap to contribs.org.

Cyrus Bharda

Rob Wellesley

Re: measure gateway traffic?
« Reply #8 on: July 04, 2003, 04:15:48 AM »
Dave Liquorice wrote:

> ifconfig {your_external_port_name} will return how much data
> has passed through that interface since  boot up.

IFCONFIG appears to report how many packets rather than bytes have passed thru the interface? Packets can be of varying size i think?

rob

Dave Liquorice

Re: measure gateway traffic?
« Reply #9 on: July 04, 2003, 05:11:30 AM »
> IFCONFIG appears to report how many packets rather than bytes
> have passed thru the interface? Packets can be of varying size i
> think?

Packets do vary in size but the last line of each interface as reported by ifconfig has:

RX bytes:150584097 (143.6 Mb)  TX bytes:38348807 (36.5 Mb)

Cheers
Dave.

Rob Wellesley

Re: measure gateway traffic?
« Reply #10 on: July 04, 2003, 06:08:07 AM »
Dave Liquorice wrote:

> Packets do vary in size but the last line of each interface
> as reported by ifconfig has:
>
> RX bytes:150584097 (143.6 Mb)  TX bytes:38348807 (36.5 Mb)

Hmmm

Mine has...

[root@winux-server /root]# ifconfig
eth0      Link encap:Ethernet  HWaddr 00:10:5A:85:FA:7A
          inet addr:192.168.1.1  Bcast:192.168.1.255  Mask:255.255.255.0
          EtherTalk Phase 2 addr:65280/242
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7971637 errors:0 dropped:0 overruns:16 frame:0
          TX packets:7316466 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:100
          Interrupt:11 Base address:0xdc00

eth1      Link encap:Ethernet  HWaddr 00:40:CA:29:97:CB
          inet addr:203.79.122.199  Bcast:203.79.122.255  Mask:255.255.255.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:8939264 errors:0 dropped:0 overruns:0 frame:0
          TX packets:1741494 errors:0 dropped:0 overruns:0 carrier:0
          collisions:1579 txqueuelen:100
          Interrupt:11 Base address:0xe000

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          EtherTalk Phase 2 addr:0/0
          UP LOOPBACK RUNNING  MTU:3924  Metric:1
          RX packets:246009 errors:0 dropped:0 overruns:0 frame:0
          TX packets:246009 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0

Dave Liquorice

Re: measure gateway traffic?
« Reply #11 on: July 04, 2003, 11:36:01 AM »
In the abscence of -v or --version:

64761 Apr 12  2002 ifconfig

SME v5.6u4

Cheers
Dave.

Rob Wellesley

Re: measure gateway traffic?
« Reply #12 on: July 04, 2003, 01:01:52 PM »
Dave Liquorice wrote:

> 64761 Apr 12  2002 ifconfig
>
> SME v5.6u4

Ron replied...

[root@winux-server /root]# ifconfig --version
net-tools 1.57
ifconfig 1.40 (2000-05-21)

SME v5.1.2u3

Dave Liquorice

Re: measure gateway traffic?
« Reply #13 on: July 05, 2003, 12:03:28 AM »
I'm sure I tried --version before but this time I got:

[root@srvr1 root]# ifconfig --version
net-tools 1.60
ifconfig 1.42 (2001-04-13)

Oh well, another reason to upgrade to one of the current and recomended versions of SME?

Cheers
Dave.