Assuming that you have enough knowledge of Unix system and Nagios monitoring. If you dont know how to configure nagios please follow this link
Prerequisite:
- Make sure Nagios is running properly. Check http://localhost/nagios
- Also make sure that you have installed nagios_plugins.
- Iptables and Selinux must be disabled.
Install check_snmp plugin:
- Make sure you have all following packages install for successful installation of snmp plugin.
net-snmp, net-snmp-devel, net-snmp-libs, net-snmp-utils, beecrypt-devel,
elfutils-devel, elfutils-devel-static, lm_sensors
- To install check_snmp I download the plugin from this location. check_snmp
1. Unzip the downloaded file
bunzip check_snmp-1.1.tar.bz2
2. Untar it.
tar xvf check_snmp-1.1.tar
3. Configure and install it.
./configure
make
make install
4. Once it is install successfully you can find check_snmp at /usr/local/bin location.
5. Create a soft link for check_snmp.
ln -s /usr/local/bin/check_snmp /usr/local/nagios/libexec/check_snmp
Install MRTG:
To monitor bandwidth usages of router/switch you must have mrtg installed on system. Before installation please make sure you have install gd, libpng, zlib packages.
1. Download MRTG.
2. Once all libraries installed required for MRTG you are all set to compile and configure MRTG.
gunzip -c mrtg-2.16.2.tar.gz | tar xvf -
cd mrtg-2.16.2
3. ./configure --prefix=/usr/local/mrtg-2
make
make install
4. Create /var/www/html/mrtg file to store mrtg html files.
mkdir /var/www/html/mrtg
5. Now you need not to create mrtg configuration file. Use cfgmaker.
cfgmaker --global 'WorkDir: /var/www/html/mrtg' --global 'Options[_]: bits,growright' --output /etc/httpd/conf/mrtg.cfg public@172.17.42.22
( I choose default apache web location for installation of mrtg html files and apache conf directory to store mrtg.cfg.)
6. Go to respective location and make sure that above command has created respective files.
cd /var/www/html/mrtg;
ls -al /etc/httpd/conf/mrtg.cfg
7. Run this command to update mrtg log file.
env LANG=C /usr/local/mrtg-2/bin/mrtg /home/mrtg/cfg/mrtg.cfg
8. create a script to update the mrtg log file which will fetch data regularly and display in graph as well as on nagios.
vi /usr/local/mrtg-2/bin/monitor_mrtg.sh
9. Put following lines in it and save.
#!/bin/sh
env LANG=C /usr/local/mrtg-2/bin/mrtg /home/mrtg/cfg/mrtg.cfg
(When you run it first time it returns you few errors/warnings. Ignore it.)
chmod 755 mrtgbw.sh ; Make script executable.
10. Set cron to run above script every 5 minute.
crontab -e
11. Modify and save,
*/5 * * * * /usr/local/mrtg-2/bin/monitor_mrtg.sh
12. Restart cron service.
/etc/init.d/crond restart
13. Confirm that it is been configured.
http://localhost/mrtg/{name of html file}
Actually when you run mrtg command it searches for respective router community collects all data from router. Accordingly it creates log file. Like in my case it has found port 2 running on router and hence created file 172.17.42.22_2.log, 172.17.42.22_2.html. So I can access my graph through this link,
http://localhost/mrtg/172.17.42.22_2.html
Procedure to monitor Bandwidth Usages in Nagios:
1. Default installation directory of nagios is /usr/local/nagios/.
2. Open switch.cfg file
vi /usr/local/nagios/etc/objects/switch.cfg
3. Make changes according to your router specifications. Like,
define host{
use generic-switch
host_name Router_1
alias Router 1
address 172.17.42.22
hostgroups switches
}
4. You can also set PING, Uptime, Ports Link Status etc.
define service{
use generic-service ; Inherit values from a template
host_name Router_1 ; The name of the host the service is associated with
service_description PING ; The service description
check_command check_ping!200.0,20%!600.0,60% ; The command used to monitor the service
normal_check_interval 5 ; Check the service every 5 minutes under normal conditions
retry_check_interval 1 ; Re-check the service every minute until its final/hard state is determined
}
define service{
use generic-service ; Inherit values from a template
host_name Router_1
service_description Uptime
check_command check_snmp!-C public -o sysUpTime.0 -H 172.17.42.22
}
define service{
use generic-service ; Inherit values from a template
host_name Router_1
service_description Port 2 Link Status
check_command check_snmp!-C public -o ifOperStatus.2 -r 1 -H 172.17.42.22
}
define service{
use generic-service ; Inherit values from a template
host_name Router_1
service_description Port 2 Bandwidth Usage
check_command check_local_mrtgtraf!/var/www/html/mrtg/172.17.42.22_2.log!AVG!1000000,1000000!5000000,5000000
!10
}
5. Verify the configuration of nagios
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
6. Restart nagios service.
/etc/init.d/nagios restart
nothing is impossible!!!!
Subscribe to:
Post Comments (Atom)
9 comments:
its working How to.. can be implementable as it mentioned.
good info and have you come across any specific field issues with these procedures?
Hello Nilesh,
I get the following error after step 7:
ERROR: Creating templock /home/mrtg/cfg/mrtg.cfg_l_60866: No such file or directory at /usr/local/mrtg-2/bin/mrtg line 1961.
Can you please help. Thank you,
Mevin
Hi Mevin,
This is a path problem. Depending on your linux version and where you installed mrtg or where you saved you config files.
regards,
Dave
And from http://shuchishukla.blogspot.com/2010/08/add-mrtg-to-nagios.html
on step 5
indexmaker --output=/var/www/html/mymrtg/index.html /etc/mrtg/mymrtg.cfg
to create an index for your html files.
Hi I am getting error on 5th step
cfgmaker --global 'WorkDir: /var/www/html/mrtg' --global 'Options[_]: bits,growright' --output /etc/httpd/conf/mrtg.cfg
usage error
Agilestorelocator.com is the professional in wordpress plugin and plugin is for WordPress. Here is also options available for the Location finder WordPress.
Hi All,
I am using MRTG and Kaseya Traverse for monitoring my routers.
But i have and issue with them, when i compare the traffic IN & OUT values of both they seems to be different.
Kaseya Traverse shows the kbps, so i have configured same in MRTG so that i can get the value in kbps, but no luck.
Can any one help on this......
Thanks in advance....
I work online and I offer professional writing services such ad Plagiarized Case study Paraphrasing to college and university students and therefore I use internet occasionally and the context of this page has help me to be cautious how I utilize my internet. Thanks for sharing it with us, I have found it to be very useful.
Post a Comment