LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices



Reply
 
Search this Thread
Old 05-29-2006, 05:23 AM   #1
cdhgee
Member
 
Registered: Oct 2003
Location: St Paul, MN
Distribution: Fedora 8, Fedora 9
Posts: 513

Rep: Reputation: 30
Need software to monitor network usage


I use a broadband ADSL service that has a monthly usage cap. As my Linux machine generates most of the traffic, I would like to use it to monitor my usage.

Can anyone suggest some software that would be able to monitor my network usage?

Regards
David Gee
 
Old 05-29-2006, 07:28 AM   #2
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,038

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
The newer ADSL modems hava a web interface that you can use to configure the modem. If you have one of these, somewhere in all those pages is a running tally of bytes uploaded/dowwnloaded since the last reset. Usually you can also reset the counters to zero (eg at the beginning of your accounting period). For my zoom X5, I click on Advanced Settings, then ATM Status, to see a whole load of statistics.
This has the advantage that it monitors your connection, rather than one specific machine.

HTH
 
Old 05-29-2006, 06:27 PM   #3
cdhgee
Member
 
Registered: Oct 2003
Location: St Paul, MN
Distribution: Fedora 8, Fedora 9
Posts: 513

Original Poster
Rep: Reputation: 30
Hadn't thought of that. The router does have a stats page, but it only shows packet counts, not byte counts, and as packets vary in size that's not overly useful, so I think it may have to be some software after all.
 
Old 07-30-2006, 11:12 AM   #4
cmsps
LQ Newbie
 
Registered: Jul 2006
Location: sheffield, uk
Distribution: fedora 18
Posts: 9

Rep: Reputation: 2
Simple solution

I have this in /etc/ppp/ip-down.local:

Code:
#!/bin/sh
#
# ip-down.local - called to add stats to /var/log/net 
#
# Sat Oct  8 16:12:58 BST 2005
#

echo `date; /sbin/ifconfig $1 |
        sed -n '7s/([^)]*)//gp'` >> /var/log/net
It takes the RX/TX info from line seven of the ifconfig command for your ppp device and puts it into a logging file.

I use this command to display the totals:

Code:
#!/bin/sh
#
# netStats RE - display stats for RE in /var/log/net
#
# Sat Dec 17 16:03:48 GMT 2005
#


# usage - display usage message
#
usage () {
  echo "Usage: $NAME [ RE ]"
  exit 1
}


NAME=`basename $0`
if [ $# -lt 2 ]
then    re=$1
else    usage
fi
awk "/$re/"'{ rx += substr( $8, 7)
              tx += substr( $10, 7)
            }
     END    { rxm = rx / (1024 * 1024)
              rxg = rxm / 1024
              txm = tx / (1024 * 1024)
              txg = txm / 1024
              printf "RX: %0.1f Mb (%0.1f Gb)  ", rxm, rxg
              printf "TX: %0.1f Mb (%0.1f Gb)\n", txm, txg
            }
' /var/log/net
For example:

Code:
     $ netStats Jun
     RX: 4941.2 Mb (4.8 Gb)  TX: 489.1 Mb (0.5 Gb)
     $
Hope this helps,

Peter
 
Old 07-30-2006, 12:54 PM   #5
tredegar
LQ 5k Club
 
Registered: May 2003
Location: London, UK
Distribution: Debian "Jessie"
Posts: 6,038

Rep: Reputation: 373Reputation: 373Reputation: 373Reputation: 373
Neat script Peter, and rather good for a "First post"! I am sure others will find it useful.
Welcome to LQ!
 
Old 01-12-2007, 12:25 PM   #6
cmsps
LQ Newbie
 
Registered: Jul 2006
Location: sheffield, uk
Distribution: fedora 18
Posts: 9

Rep: Reputation: 2
Post Firestarter script

After I installed Firestarter the ip-down.local script stopped working, probably because firestarter destroys ppp0 when it closes down.

Here is the latest version:
Code:
#!/bin/sh
#
# ip-down.local - called to add stats to /var/log/net 
#
# Fri Dec 29 20:19:37 GMT 2006
#

echo `date` RX bytes:$BYTES_RCVD TX bytes:$BYTES_SENT >> /var/log/net

Last edited by cmsps; 04-01-2011 at 02:37 PM. Reason: bug spotted and fixed after five years!
 
  


Reply

Tags
adsl, bandwidth, monitor, network


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to programmatically monitor a process memory usage? thanhvn Programming 14 02-20-2009 02:15 AM
Using nmap to monitor programs usage AGazzaz Linux - Networking 1 05-17-2006 12:21 PM
how to monitor kernel udp buffer usage? coontie Linux - Networking 0 11-17-2004 12:29 PM
monitor partition usage mikmok Linux - Newbie 3 08-17-2004 09:44 AM
Network Monitor Software supertechmyers Linux - Networking 2 03-30-2004 11:00 PM


All times are GMT -5. The time now is 03:00 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration