LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (http://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Tracking amount of sent/received data (http://www.linuxquestions.org/questions/linux-newbie-8/tracking-amount-of-sent-received-data-715327/)

MartenH 03-29-2009 04:30 PM

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)

TB0ne 03-29-2009 06:31 PM

Quote:

Originally Posted by MartenH (Post 3491843)
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.

trist007 03-29-2009 07:44 PM

pv is a nice tool as well.

MartenH 04-01-2009 02:05 PM

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).


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