LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Articles > Jeremy's Magazine Articles
User Name
Password

Notices

By jeremy at 2005-05-04 21:35
Track Bandwidth Usage with RTG
Tech Support
Written by Jeremy Garcia

I'd like to monitor bandwidth usage. What should I use?

If you're interested in monitoring bandwidth and have done a little research, you probably have run across MRTG, RRDtool, and Cricket. While these three packages are all fantastic and popular tools, you should also consider a lesser known tool named RTG. (Learn about all of your options, and then choose the utility that best suits your needs.) As of this writing, the current version of RTG, which is available from http://rtg.sourceforge.net and is licensed under the GPL, is 0.7.4.

Designed for enterprises and service providers that need to collect time-series SNMP data from a large number of targets, RTG is a flexible, scalable, high-performance SNMP statistics monitoring system. All collected data is inserted into a relational database that provides a common interface for applications to generate complex queries and reports. Currently the only officially supported database is MySQL, but PostgreSQL support is available in CVS.
Written in C, RTG runs as a multi-threaded daemon, making it extremely lightweight and fast. Unlike tools such as MRTG, it does no data averaging. The up-side to this is that you can get information from arbitrary time intervals and get exact information suitable for billing. The downside is that, as time goes on, you have more and more data to store (MRTG data files never grow due to the data consolidation algorithm it uses).
Installation is the usual ./configure && make && make install. You�ll need the MySQL libraries, often called mysql-devel by distributions, and Net-SNMP libraries to perform the install. After the make install is complete, run the included script to create the necessary MySQL database, tables, and user.

Code:
$ /usr/local/rtg/etc/createdb mysql_root_password
Now that the database is setup, add any routers you want to monitor to /usr/local/rtg/etc/routers. The format is device:community:bits, where device is the DNS name or IP address of the device you�d like to monitor, community is the SNMP community name, and bits is an optional parameter to allow you to change the default behavior of using 32-bit SNMP counters. After you�ve entered each device on its own line, run /usr/local/rtg/etc/rtgtargmkr.pl, which creates a targets.cfg file.
You are now ready to run the RTG poller:

Code:
$ /usr/local/rtg/bin/rtgpoll -v -t /usr/local/rtg/etc/targets.cfg
If the poller fails to find a configuration file, it creates one named rtg.conf in the current directory. (You may need to edit this file if your installation is non-standard.) By default, rtgpoll stays in the foreground. Once you have everything configured and working correctly, add the appropriate line to run rtgpoll in the background to your startup scripts.
Now that you have the poller running, take a look at the data. RTG provides a variety of web scripts to display the information. Additionally, since the data is simply stored in the database, you are free to write a script in your preferred language to present the data in a way that� most useful to you.
For this article, let�s assume that you already have a PHP-enabled web server running. First, copy the included scripts to a directory accessible from your web server.

Code:
# cp /usr/local/rtg/web/* /var/www/html/rtg/
# cp /usr/local/rtg/bin/rtgplot /var/www/html/rtg/rtgplot.cgi
You can now view Interactive Reports at http:// your_machine /rtg/rtg.php; 95th percentile queries at http:// your_machine /rtg/95.php; and MRTG-style overview and daily, weekly, and monthly plots at http:// your_machine /rtg/view.php.
You can also call rtgplot.cgi directly by passing in the appropriate parameters.
Additionally, RTG provides a command-line Perl script that yields plain, text reports. For instance, typing $./report.pl customername 01/01/2005 01/02/2005
generates a report like that shown in Figure One.

Code:
FIGURE ONE: The output of RTG�s reporting script

customername Traffic
Period: [01/01/2005 00:00:00 to 01/03/2005 00:00:00]

                                In      Out  Avg In Avg Out   Util   Util  Max In Max Out Max Ut Max Ut
Connection                  MBytes   MBytes    Mbps    Mbps   In %   Out%    Mbps    Mbps    In%   Out%
----------------------------------------------------------------------------------------------------------
Ethernet0/1  x.x.x.x           106      212    0.08    0.16   0.80   1.60    0.70    0.90   7.00   14.20

Total:                         106      212    0.08    0.16   0.80   1.60    0.70    0.90   7.00   14.20
By using the included scripts and leveraging the ability to write your own custom scripts, RTG will quickly and easily allow you to not only monitor bandwidth usage, but also setup billing scripts, trigger alerts based on custom monitoring thresholds and almost anything else you can imagine.

by tormented_one on Wed, 2005-05-04 22:49
Awesome Thanks!

by sridhar11 on Thu, 2006-08-24 09:14
this tutorial also good documentation with step by step guide For all admins and users


  



All times are GMT -5. The time now is 03:32 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