LinuxQuestions.org
Review your favorite Linux distribution.
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, 03:30 PM   #1
MartenH
Member
 
Registered: Jul 2005
Location: Lund, Sweden
Distribution: Debian
Posts: 78

Rep: Reputation: 23
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, 05:31 PM   #2
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 25,644

Rep: Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651Reputation: 7651
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, 06:44 PM   #3
trist007
Senior Member
 
Registered: May 2008
Distribution: Slackware
Posts: 1,049

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

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

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:47 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
Open Source Consulting | Domain Registration