LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices



Reply
 
Search this Thread
Old 03-29-2009, 04:30 PM   #1
MartenH
Member
 
Registered: Jul 2005
Location: Lund, Sweden
Distribution: Mandriva
Posts: 74

Rep: Reputation: 17
Tracking amount of sent/received data


Hello,

I'm looking for a way of logging and recovering the total amount of data sent and received for a network interface. The code I currently use resets after a certain period of time which is not desired.

I'm looking for something that even after a reboot will tell me how much data has been received and sent on that interface since the server was first taken into use (i.e. from the time a solution was implemented).

This is my current code
Code:
echo $(/sbin/ifconfig eth1 | grep 'RX bytes' | head -n1 | awk '{print $3 $4}' | cut -d '(' -f2 | cut -d ')' -f1
Code:
echo $(/sbin/ifconfig eth1 | grep 'RX bytes' | head -n1 | awk '{print $7 $8}' | cut -d '(' -f2 | cut -d ')' -f1)
 
Old 03-29-2009, 06:31 PM   #2
TB0ne
Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 15,091

Rep: Reputation: 2718Reputation: 2718Reputation: 2718Reputation: 2718Reputation: 2718Reputation: 2718Reputation: 2718Reputation: 2718Reputation: 2718Reputation: 2718Reputation: 2718
Quote:
Originally Posted by MartenH View Post
Hello,

I'm looking for a way of logging and recovering the total amount of data sent and received for a network interface. The code I currently use resets after a certain period of time which is not desired.

I'm looking for something that even after a reboot will tell me how much data has been received and sent on that interface since the server was first taken into use (i.e. from the time a solution was implemented).

This is my current code
Code:
echo $(/sbin/ifconfig eth1 | grep 'RX bytes' | head -n1 | awk '{print $3 $4}' | cut -d '(' -f2 | cut -d ')' -f1
Code:
echo $(/sbin/ifconfig eth1 | grep 'RX bytes' | head -n1 | awk '{print $7 $8}' | cut -d '(' -f2 | cut -d ')' -f1)
Check into MRTG and/or RRDTOOL. They can be a bear to set up, but keep good track of such things, and give you good looking graphs to boot.

If you want a quick-and-dirty solution, fire up MySQL, define a database and table (very easy to do), and shovel those values into a table, say every minute or so. I.E:, under MySQL prompt, "create database NetworkStats;", "use NetworkStats;", "create table traffic (DateTime char(26), IF char(10), RX int, TX int);". Then your script can just append a mysql command-line insert, and shove a record in every time it runs.

Use OpenOffice Spreadsheet or Excel to make an ODBC connection to it, for graphing, trending, etc. Can keep as much data as you've got disk space for.
 
Old 03-29-2009, 07:44 PM   #3
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,004

Rep: Reputation: 67
pv is a nice tool as well.
 
Old 04-01-2009, 02:05 PM   #4
MartenH
Member
 
Registered: Jul 2005
Location: Lund, Sweden
Distribution: Mandriva
Posts: 74

Original Poster
Rep: Reputation: 17
It looks like I will have to look into RRDTOOL which I have seen in use in other places. Does anyone happen to know a good basic tutorial on how to configure it?

It seems I need to define which interface to listen to somehwere, and prefferably the site should be accesible from outside of my network (even if the rest of my website server should).
 
  


Reply


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
managing the amount of data that is logged paranoid times Linux - Security 3 02-09-2007 03:46 PM
generate large amount of traffic data Mr_C Linux - Networking 3 03-10-2006 12:38 AM
HP laserjet 6p stalls with large amount of data simjii Mandriva 0 11-10-2005 04:32 PM
calculate amount of data transferred to certain ip addresses dtra Linux - Software 0 11-07-2005 08:57 PM
Bash Scripting - Waiting for a certain amount of data welby Programming 12 05-12-2004 01:40 PM


All times are GMT -5. The time now is 11:49 PM.

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