1. Revision: 2
Date: 2010-12-20
MRTG
Configuration in Nagios
ICT4RD-TANZANIA
Isafjordsgatan 39, Kista
http://csd.xen.ssvl.kth.se/csdlive/content/buruca
Page 1 of 5
Buruca Team – Building Rural Africa
ICT 4 Rural Development
2. Document History
Revision Number Revision Date Summary of Author(s)
changes
2 2010-12-20 The document was Narayanan
modified Anandpadmanabhan
Page 2 of 5
Buruca Team – Building Rural Africa
ICT 4 Rural Development
3. Table of Contents
1. Configuration of MRTG in Nagios……………………………………..……………….4
2. Solution for errors..................................................................................................... 5
Page 3 of 5
Buruca Team – Building Rural Africa
ICT 4 Rural Development
4. 1. The configuration of the Nagios for MRTG is done as follows
STEP1: Goto Services.cfg [1] and add the following documents for enabling MRTG
analysis
define service{
use generic-service ; Inherit values from a template
host_name localhost
service_description Bandwidth Usage
check_command
check_local_mrtgtraf!/var/lib/mrtg/127.0.0.1_1.log!AVG!1000000,2000000!5000000,
5000000!10
}
##ROUTER AT TTCL
define service{
use generic-service ; Inherit values from a template
host_name router-at-TTCL-eth0
service_description Port 1 Bandwidth Usage
check_command check_local_mrtgtraf!/var/lib/mrtg/196.43.72.33_6.log!AVG!
1000000,2000000!5000000,5000000!10
}
##BUNDA
define service{
use generic-service ; Inherit values from a template
host_name router-at-bunda-eth1
service_description Port 1 Bandwidth Usage
check_command check_local_mrtgtraf!/var/lib/mrtg/196.43.72.34_1.log!AVG!
1000000,2000000!5000000,5000000!10
}
define service{
use generic-service ; Inherit values from a template
host_name router-at-bunda-eth4
service_description Port 1 Bandwidth Usage
check_command check_local_mrtgtraf!/var/lib/mrtg/172.16.96.1_2.log!AVG!
1000000,2000000!5000000,5000000!10
}
###NATA
define service{
use generic-service ; Inherit values from a template
host_name router-at-nata-eth1
service_description Port 1 Bandwidth Usage
check_command check_local_mrtgtraf!/var/lib/mrtg/172.16.96.7_3.log!AVG!
1000000,2000000!5000000,5000000!10
}
STEP2: Save the file.
STEP3: Restart Nagios.
Page 4 of 5
Buruca Team – Building Rural Africa
ICT 4 Rural Development
5. 2. Solution for errors
After the configuration of the MRTG plugin in Nagios and once we restarted
Nagios, we were repeatedly getting the error "check_mrtgtraf: Unable to open
MRTG log file". [1]
In the Commands.cfg file we had the configuration as
# 'check_local_mrtgtraf' command definition
define command{
command_name check_local_mrtgtraf
command_line $USER1$/check_mrtgtraf -F $ARG1$ -a $ARG2 -w
$ARG3$,$ARG4$ -c $ARG5$,$ARG6$
}
So there was no “LOGFILE” option defined in this file. This was the main cause for
the error. So to fix this we changed the commands.cfg file as below
# 'check_local_mrtgtraf' command definition
define command{
command_name check_local_mrtgtraf
command_line $USER1$/check_mrtgtraf -F $LOGFILE$ -a $ARG1$ -w
$ARG3$,$ARG4$ -c $ARG5$,$ARG6$
}
References
[1] http://nagios.sourceforge.net/docs/nagios-3.pdf
Page 5 of 5
Buruca Team – Building Rural Africa
ICT 4 Rural Development