hi, i have solved this problem, this is the things that i did:
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 using yum install mrtg
2. Now you need not to create mrtg configuration file. Use cfgmaker.
cfgmaker --global 'WorkDir: /var/www/html/mymrtg' --global 'Options[_]: bits,growright' --output /etc/httpd/conf/mrtg.cfg public@<ip address of the switch>
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/bin/mrtg /etc/mrtg/mrtg.cfg
10. Set cron to run above command every 5 minute.
crontab -e
11. insert the code below and save,
*/5 * * * * /usr/bin/env LANG=C /usr/bin/mrtg /etc/mrtg/mymrtg.cfg –logging /var/log/mrtg.log
*/5 * * * * /usr/bin/env LANG=C /usr/bin/mrtg /etc/httpd/conf/mrtg.cfg --logging /var/log/mrtg.log
12. Restart cron service.
/etc/init.d/crond restart
13. Confirm that it is been configured.
http://localhost/mymrtg/{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/mymrtg/<ip address of the switch>_2.html
Procedure to monitor Bandwidth Usages in Nagios:
1. Default installation directory of nagios is /usr/local/nagios/.
2. Open switch.cfg file
nano /etc/nagios/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/mymrtg/172.17.42.22_2.log!AVG!1000000,1000000!5000000,500 0000!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
|
Recent comments
1 day 11 hours ago
1 day 14 hours ago
2 days 2 hours ago
2 days 4 hours ago
2 days 9 hours ago
2 days 15 hours ago
3 days 52 min ago
3 days 2 hours ago
3 days 10 hours ago
3 days 12 hours ago