MRTG Monitor switch router traffic and Nagios alarms

Source: Internet
Author: User
Tags mrtg

1. Switch to enable SNMP protocol
2. Installing MRTG

Yum-y Install MRTG
3. Configure MRTG
(1) Create the configuration file, if there are multiple switches, you can create a corresponding configuration file for each switch
cfgmaker-output=/usr/local/mrtg/switch.cfg [email protected] Switch IP

The switchw.cfg configuration file generated at this time records information such as the model of the monitored switch, all ports being used, VLAN, current rate, and so on.
This needs to be liked, we do not have to configure each.
(2) Create a web directory of traffic graphs at access time
(3) Modify the configuration file generated by the first step to point the working directory to the web directory you set
# for UNIX
(4) Generate traffic map in working directory
After the execution, there will be alarm prompts, we need to execute several times, until no alarm information for the general execution 3 times can
[[email protected] share]# ls tml index.html OG mrtg-l.png Onth.png Mrtg-m.png LD Mrtg-r.png Eek.png Ear.png Ay.png tml OG
(5) Since we need real-time monitoring, we need to set up a scheduled task to meet our needs, which is set to update every 5 minutes
*/5 * * * */usr/bin/env lang=c/usr/bin/mrtg/usr/local/mrtg/switch.cfg >>/dev/null >2&1
(6) Generate summary home index.html
indexmaker-output=/usr/local/mrtg/share/index.html-title= "Mainswitch Traffic Monitoring"/usr/local/mrtg/ Switch.cfg

4. Configure Apache to enable Web Access
After the Yum installation is complete, the configuration file/etc/httpd/conf.d/mrtg.conf is generated on Apache and is configured as follows:
[Email protected] mrtg]# cat/etc/httpd/conf.d/mrtg.conf
# This configuration file maps the MRTG output (generated daily)
# into the URL space. By default These results is only accessible
# from the local host.

Order Deny,allow
# Deny from all
Allow from all
Allow from
Allow from:: 1
# Allow from.
We can access it through HTTP://IP/MRTG, the effect is as follows:

Through the above we can view the traffic information of the switch in real-time, but we want to realize the traffic monitoring alarm, we need nagios to read the MRTG monitor traffic information to achieve
In the new version of Nagios, there are two plugins, CHECK_MRTG and Check_mrtgtraf, and the relevant parameters have been configured so that we can call them directly.
1. First we need to define the switch and monitoring services
We can modify the/usr/local/nagios/etc/switch.cfg file directly.
Define Host{
Use Generic-switch; Inherit default values from a template
HOST_NAME huawei-er-3100; The name we ' re giving to this switch
Alias Huawei-er-3100; A longer name associated with the switch
Address; IP Address of the switch
Hostgroups switches; Host groups This switch are associated with
Define Service{
Use Generic-service; Inherit values from a template
HOST_NAME huawei-er-3100
Service_description Interface 1794 Bandwidth Usage
Check_command check_local_mrtgtraf!/usr/local/mrtg/share/! Avg!1000000,1000000!5000000,5000000!10
Where 1794 represents the 1794 port of the switch, we can configure it according to the effective information of MRTG monitoring.
The "AVG" parameter means to take the statistical average of the bandwidth, "1000000,1000000" parameter refers to the incoming alarm threshold (in bytes), "5000000,5000000" is the output traffic emergency threshold (in bytes), "10" Refers to a state of emergency (which should be updated every 5 minutes) if the MRTG log does not return data for more than 10 minutes.

2. Check the Nagios configuration file and restart
Service Nagios Restart

MRTG Monitor switch router traffic and Nagios alarms

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.