samedi, mars 15, 2008
Install MRTG on ubuntu : a tutorial
In this post, I show how to install and use MRTG, a graphical tool to monitor the traffic load on network-links.
The manipulations described here apply to linux Ubuntu 7.10 Gusty.
As prerequisite, perl and apache need to be installed.
To get MRTG and its database rrdtool, install the binary packages:
To check the install, just type "mrtg" as root in a console. (tip: on Ubuntu, "type sudo -s" to keep a console logged as root and not to have to precede each line with "sudo")
You may get the following error occurred:
Then just type:
If you type "mrtg" again, you should have no output, because it waits for a config file in parameter.
MRTG gets its data from an SNMP server, so you need one.
If you decide to analyze a router, make sure SNMP is enable. If you monitor your local machine,
You may need to install "snmpd"
To install the server :
apt-get install snmpd
and the client :
apt-get install snmp
After snmpd install, you can check it is running
ps -A | grep snmpd
To configure SNMP, you can either edit /etc/snmp/snmpd.conf
or more simply run the following command:
snmpconf -g basic_setup
This utility prompts questions about the equipment to monitor with SNMP and generates the config file.
Restart snmpd :
/etc/init.d/snmpd restart
And type the following command to check if you to retrieve the SNMP values:
snmpwalk -v 1 -c public localhost system
Now we're ready to use MRTG. First generate the config file with the command:
cfgmaker 127.0.0.1 --output test.cfg
Edit the generated file "test.cfg" and check the WorkDir setting, it should be already set. If not, do it:
WorkDir: /var/www/mrtg
A few line later, it should contqin an entry for each network interface MRTG has found querying SNMP.
Then add the folowing settings:
Refresh is to tell the browser to refresh every 300 seconds.
Interval , in minutes, the interval to query
logformat :rrdtool tells mrtg to save data in rrdtool database
RunAsDaemon : so the process runs as a service
Then start mrtg, by typing as root
If everything is ok, you will get
Check now in /var/www/mrtg, you should have a rrdtool database file. It is name with the IP address and the network interface. In my case:
127.0.0.1_3.rrd
type to see the content:
rrdtool info 127.0.0.1_3.rrd
It should display something like:
At least, setup 14all to generate the graphics.
Download it from http://my14all.sourceforge.net/
Choose to download : 14all.cgi v1.1p25
Rename the file with an extension .cgi and place it in the Apache cgi-bin directory :
/var/www/cgi-bin together with the MRTG config file.
In your browser:
http://localhost/cgi-bin/14all.cgi?cfg=test.cfg
You should see a page with graphs showing the traffic analysis of your network interface.
Here I am surfing for one hour on internet:
As an alternative to 14all, you may also check router2cgi
It works exactly the same but it is richer.
The manipulations described here apply to linux Ubuntu 7.10 Gusty.
As prerequisite, perl and apache need to be installed.
To get MRTG and its database rrdtool, install the binary packages:
apt_get install mrtg
apt_get install rrdtool
apt-get install librrds-perl
To check the install, just type "mrtg" as root in a console. (tip: on Ubuntu, "type sudo -s" to keep a console logged as root and not to have to precede each line with "sudo")
You may get the following error occurred:
-----------------------------------------------------------------------
ERROR: Mrtg will most likely not work properly when the environment
variable LANG is set to UTF-8. Please run mrtg in an environment
where this is not the case. Try the following command to start:
env LANG=C /usr/bin/mrtg
-----------------------------------------------------------------------
Then just type:
export LANG=C
If you type "mrtg" again, you should have no output, because it waits for a config file in parameter.
MRTG gets its data from an SNMP server, so you need one.
If you decide to analyze a router, make sure SNMP is enable. If you monitor your local machine,
You may need to install "snmpd"
To install the server :
apt-get install snmpd
and the client :
apt-get install snmp
After snmpd install, you can check it is running
ps -A | grep snmpd
To configure SNMP, you can either edit /etc/snmp/snmpd.conf
or more simply run the following command:
snmpconf -g basic_setup
This utility prompts questions about the equipment to monitor with SNMP and generates the config file.
Restart snmpd :
/etc/init.d/snmpd restart
And type the following command to check if you to retrieve the SNMP values:
snmpwalk -v 1 -c public localhost system
Now we're ready to use MRTG. First generate the config file with the command:
cfgmaker 127.0.0.1 --output test.cfg
Edit the generated file "test.cfg" and check the WorkDir setting, it should be already set. If not, do it:
WorkDir: /var/www/mrtg
A few line later, it should contqin an entry for each network interface MRTG has found querying SNMP.
Then add the folowing settings:
Refresh: 300
Interval: 5
logformat: rrdtool
RunAsDaemon: Yes
Refresh is to tell the browser to refresh every 300 seconds.
Interval , in minutes, the interval to query
logformat :rrdtool tells mrtg to save data in rrdtool database
RunAsDaemon : so the process runs as a service
Then start mrtg, by typing as root
mrtg test.cfg
If everything is ok, you will get
Daemonizing MRTG ...
Check now in /var/www/mrtg, you should have a rrdtool database file. It is name with the IP address and the network interface. In my case:
127.0.0.1_3.rrd
type to see the content:
rrdtool info 127.0.0.1_3.rrd
It should display something like:
ds[ds0].type = "COUNTER"
ds[ds0].minimal_heartbeat = 600
ds[ds0].min = 0.0000000000e+00
ds[ds0].max = 1.2500000000e+06
ds[ds0].last_ds = "14331604"
ds[ds0].value = 1.2166000000e+03
At least, setup 14all to generate the graphics.
Download it from http://my14all.sourceforge.net/
Choose to download : 14all.cgi v1.1p25
Rename the file with an extension .cgi and place it in the Apache cgi-bin directory :
/var/www/cgi-bin together with the MRTG config file.
In your browser:
http://localhost/cgi-bin/14all.cgi?cfg=test.cfg
You should see a page with graphs showing the traffic analysis of your network interface.
Here I am surfing for one hour on internet:
As an alternative to 14all, you may also check router2cgi
It works exactly the same but it is richer.
Commentaires:
<< Accueil
buy tramadol without rx information on tramadol 50mg tablets - buy tramadol online no prescription usa
http://ranchodelastortugas.com/#30416 alprazolam 1mg side effects - is xanax good for opiate withdrawal
Enregistrer un commentaire
Abonnement Publier les commentaires [Atom]
<< Accueil
Abonnement Articles [Atom]