I need to keep statistics of daily network traffic for a linux machine (CentOS 5).
Is there a way to do it using standard/native tools or utilities?
Or do I have to dowload special software for that?
Thanks.
|
I need to keep statistics of daily network traffic for a linux machine (CentOS 5). Is there a way to do it using standard/native tools or utilities? Thanks.
| |||||||||||
feedback
|
|
What Zypher was saying about rrdtool (and anything else that uses it as a backend - MRTG, Cacti etc) is probably correct. RRDTool is designed to be an 'averaged' historical trending analysis tool. It averages and stores counters in increasingly non-resolute increments increments the further back in time it goes. This is, however, configurable by setting up the RRAs approriately. I confess to knowing absolutely nothing about configuring these, however, and have never personally had luck getting them right beyond my standard set (15 minutes, 8 hours, 1 week, 1 month, 1 year). I would recommend looking into configuring the RRAs to expect daily input and feed it your bandwidth counter from netstat. You'll get some very nice historical data and insight into your usage patterns. To answer your current problem, about making sure you don't exceed a daily bandwidth limit; I would recommend grabbing the netstat counters daily for the interface in question. You can compare yesterday's traffic at time t with today's counters at time t and find out how much was transferred. A simple script with a flat text-file storage of the previous value would probably suffice. You could then disable the interface if you detect exceeded bandwidth or monitor it throughout the day and notify an admin if you are approaching your limit. To get the input bytes on an OSX system you can use the following set of commands:
Conversely, output can be obtained with:
You could pop the relevant counters into a flat file stored somewhere and compare it with:
Just adjust the netstat processing to match your system (since I know you're not running OSX). | ||||
|
feedback
|
|
The sysstat package contains the sar utility. Sar is a extremely configurable system "profiler", for lack of a better term, that collects various statistics at predefined intervals (cron). These are stored in binary files, one for each day, that are typically rotated weekly, but that is configurable. The sar program can be used to pull the statistics out of these files, and those results can easily be graphed with any office program or gnuplot (my personal preference). http://pagesperso-orange.fr/sebastien.godard/ <= Sar information | |||
|
feedback
|
|
You want MRTG which is a network monitoring tool, its the thing that produces all the network graphs you see around the web (with rdtool to turn the numbers into pictures) If you don't want to set it up, or just need something simpler, you can use iptables to record data transfer. | |||
|
feedback
|
|
I also suggest using VnStat
| |||
|
feedback
|
|
I used mrtg, it's a very nice solution, and there are other tool that seems to be interesting and that give a lot of information about traffic named ntop a network probe, here find a link about installing ntop on CentOS | |||
|
feedback
|
|
Either MRTG or Cacti. Cacti is a pain to set up, but gives some very pretty graphs. MRTG is easy to set a basic plot up, but for anything pretty or complicated, it's pretty tough. | |||
|
feedback
|
|
Munin is another nice RRD-based tool that's very easy to set up; the default network stats are quite basic, but it's easy to add additional plugins. I've attached a copy of the daily and weekly stats on one of my servers; you also get monthly and yearly stats on a different page. | |||
|
feedback
|
|
Vnstat is a great console based daily / weekly / monthly traffic monitor. It even allows you to monitor the traffic in realtime which is handy. It uses very few system resources too ;) | |||
|
feedback
|
|
Some months ago I tested some of the tools listed in this page but found a problem with them that caused me to remove them. Consider the following situation: At work there is a server which connects to the Internet via eth0. This is not a very busy server, so normally the traffic going through eth0 is 0 bytes per second. From home I connect to the work server and run iptraf on the work server. iptraf sends its results to my laptop at home through my work server's eth0. Therefore eth0 instantly becomes busy, even though the only traffic passing through it is iptraf traffic. i.e. using iptraf through a network interface that iptraf is monitoring skews its statistics. Beware then, some of these tools should be used only on a console which is directly connected to the computer being monitored. Off-topic: I have enjoyed reading this page and all the helpful comments made by contributors. This is the sort of forum that makes using GNU/Linux fun and productive. Leo | |||
|
feedback
|