With the development of Internet applications, enterprise Internet applications are not just as simple as building a website. Enterprises are constantly increasing their Internet applications, providing richer and more powerful functions. In the face of more large-scale Internet applications, many enterprises have to own several or even dozens of servers in telecom IDCs.
In the process of managing these servers, the traffic of each server becomes a key point of management. The administrator can promptly detect potential security or performance problems from abnormal network traffic through monitoring various network traffic; upper-level leaders can also obtain useful business analysis information from the statistical network traffic report, so as to make relevant adjustments or upgrade decisions for the business.
Among the many network traffic monitoring software, MRTG is undoubtedly well-known and representative. MRTG is a typical SNMP-based network traffic monitoring, statistics, and analysis tool. SNMP Simple Network Management Protocol) is a protocol specially designed to monitor and control various network devices in the network, such as switches, routers, and servers.
Most network products on the market support the SNMP protocol, so MRTG is widely used. This article will focus on how to use the MRTG software to monitor server traffic.
Why MRTG Monitoring Center
Server operating systems are diverse. Most Commonly Used Unix or Windows operating systems, all of which support the SNMP protocol. For example, for a Windows system, you only need to add the Windows component in "management and monitoring tools" to support the SNMP protocol.
After the server starts SNMP, port 161/162 is opened. If the administrator wants to monitor this machine, he must install MRTG on his own machine and send a query request to port 161/162 of the server through MRTG, after data is obtained, a traffic report for graphics and HTML documents is generated. This is a simple MRTG monitoring process.
In practical applications, an enterprise may have multiple servers. Generally, the administrator needs to continuously monitor the server traffic 24 hours a day. If MRTG is simply used on the Administrator's machine, it is not suitable. The best way is to establish a MRTG monitoring center.
The MRTG monitoring center can be a dedicated server or another server as the MRTG monitoring center. The machines and other servers used in the monitoring center are located behind the firewall. Because SNMP is easy to be the target of attacks, access to port 161/162 of the server should be prohibited in firewall rules. This ensures that the MRTG monitoring center is responsible for monitoring all other servers.
The MRTG monitoring center continuously generates traffic reports and sends them to administrators in the form of web pages. Of course, this Web page has the identity authentication function to ensure that only administrators with accounts can view the corresponding traffic reports.
Using such a MRTG monitoring center can bring the following benefits:
◆ 24 hours of uninterrupted work to ensure the generation of detailed and comprehensive traffic reports;
◆ Provides a Web browser interface with identity authentication. The administrator can view the traffic report on the internet anytime and anywhere by account;
◆ The Administrator is free from the trouble of installing MRTG. You only need to view the traffic report through the browser;
◆ Only MRTG monitoring center machines are allowed to access port 161/162 of the server, which is more secure.
Build MRTG Monitoring Center
The following describes how to build a MRTG monitoring center on Linux.
MRTG needs to install Apache first
1. MRTG must be based on the SNMP service, so make sure that your system has enabled this service.
1. Make sure that the following software packages are installed on your system
Net-snmp-libs
Net-snmp
Net-snmp-utils
2. Modify/etc/snmp/snmpd. conf
Remove the comment of the following line.
View mib2 shortded .iso.org. dod. internet. mgmt. mib-2 fc
Add the following line at about 55 rows
View systemview embedded ded. 1.3.6.1.2.1.2
Set the following lines
Access notConfigGroup "" any noauth exact systemview none
Modified:
Access notConfigGroup "" any noauth exact mib2 none
3. Enable the snmpd service
# Service snmpd start
# Chkconfig -- levle2345 snmpd on
4. view the port enabling status
# Netstat-tunlp | grep snmp
Tcp 0 0 0.0.0.0: 199 0.0.0.0: * LISTEN 4973/snmpd
Udp 0 0 0.0.0.0: 161 0.0.0.0: * 4973/snmpd
Ii. MRTG generation: httpd service is required for Image Browsing, AND gd, libpng, and zlib software packages are also required.
Several of its software.
Iii. Install MRTG
: Http://oss.oetiker.ch/mrtg/pub/
# Tar zxvf mrtg-2.16.2.tar.tar
# Cd mrtg-2.16.2
#./Configure -- prefix =/usr/local/mrtg
# Make
# Make install
4. Configure MRTG
Generate the configuration file:
# Mkdir/etc/mrtg
#/Usr/local/mrtg/bin/mongomaker public @ localhost>/etc/mrtg. cfg
Edit/etc/mrtg. cfg
Set
# WorkDir:/home/http/mrtg
Remove the comment and change it
WorkDir:/usr/local/www/htdocs/mrtg
(Here is the default home directory of your httpd) Note that there is no space before
Remove the comment of the following line
# Options [_]: growright, bits
Add the following lines to display Chinese characters on the webpage.
Language: gb2312
Generate the MRTG webpage homepage File
#/Usr/local/mrtg/bin/indexmaker/etc/mrtg. cfg -- output =/usr/local/www/htdocs/mrtg/index.html --
Title = "My MRTG"
4. Start MRTG
# Env LANG = C/usr/local/mrtg/bin/mrtg/etc/mrtg. cfg
This command outputs some error information, which can be safely ignored. You can execute this command three times in a row.
5. The web pages generated by MRTG are static. to refresh the pages continuously, add the preceding commands to crontab.
# Crontab-e
Add the following line
*/3 ***** env LANG = C/usr/local/mrtg/bin/mrtg/etc/mrtg. cfg
Note: This row indicates that the refresh interval is refreshed every three minutes. You can modify the refresh interval as needed.
6. After the installation is complete, check the result. Enter the following address in the browser:
Http: // 192.168.1.1/mrtg (IP address is your machine IP address)
Http://www.syitren.com/bbs/thread-2178-1-1.html