MRTG monitors switch traffic

  

First, switch snmp configuration, the following is the configuration command of H3C 5500 series:

snmp-agent enablesnmp-agent community read publicsnmp-agent sys-info version allsnmp-agent group v1 publicsnmp -agent group v2c publicsnmp-agent group v3 publicsnmp-agent target-host trap address udp-domain <nagios server IP> params securityname public
Second, install and configure mrtg1, install MRTG, use yum default installation: Br>

[root@nagios ~]#yum -y install mrtg
2, create a configuration file, because I only need to monitor one core switch, so only create one, if there are multiple switches to monitor, then Create multiples in the same way as below:

[root@nagios ~]#mkdir /usr/local/nagios/mrtg ##Create a configuration file folder [root@nagios ~]#cfgmaker - Output=/usr/local/nagios/mrtg/mainswitch.cfg public@switch IP
3. Create and configure the folder for storing the traffic graph and html page. I put it under the nagios web file, such as:

[root@nagios ~]# mkdir /usr/local/nagios/share/mrtg[root@nagios ~]# vi /usr/local/nagios/mrtg/mainswitch.cfg find“WorkDir:
” Replace the trailing path with the previous step Create the path, note that if you are commented out by #, you need to cancel #, and after completion: WorkDir: /usr/local/nagios/share/mrtg
4, generate traffic graph:

[root@nagios ~]# env LANG=C /usr/bin/mrtg /usr/local/nagios/mrtg/mainswitch.cfg

This step may have a warning, no matter how many times he performs it Until there is no warning.
Use the task plan configuration to generate every 5 minutes:

[root@nagios ~]#vi /etc/crontab

Add the following line:

*/5 * * * * root /usr/bin/env LANG=C /usr/bin/mrtg /usr/local/nagios/mrtg/mainswitch.cfg
Restart the scheduled task using service crond restart.
Generating summary home page:

[root@nagios ~]# indexmaker -output=/usr/local/nagios/share/mrtg/index.html -title="MainSwitch Traffic Monitoring" /usr/Local/nagios/mrtg/mainswitch.cfg
At this point, you can use the browser to access the traffic map of MRTG production. The path is: http://server IP/nagios/mrtg/
IV. Configure Nagios Read the traffic information monitored by mrtg: In the latest version of nagios, there are check_mrtg and check_mrtgtraf plugins, and related commands have been configured and can be used directly. The specific methods are as follows:
1. Define switches and monitoring services: Br>

Edit vi /usr/local/nagios/etc/objects/switch.cfg, you can talk about the definition of the original switch, or modify it in the original configuration, the main content is as follows: define host:

define host{use generic-switchhost_name MainSwitchalias MainSwitchaddress Replace with switch IP address hostgroups switches}
Define server:

define service{use generic-servicehost_name MainSwitchservice_description Port 1 traffic check_command check_local_mrtgtraf!/usr/local/nagios/share/mrtg/replaced with switch IP_1.log!AVG!1000000,1000000!5000000,5000000!10}

Note: Behind the switch IP above The number 1 indicates switch port 1. To monitor more ports, define more services in the same way.
Restart the nagios service, refresh the nagios monitoring page, and wait for two minutes to see the traffic information.

If you want to view more information on port traffic map, you can access the MRTG page view, the path is: http: //nagiso server IP /nagios /mrtg /

Copyright © Windows knowledge All Rights Reserved