Detailed steps for installing Mrtg configuration in Centos

Source: Internet
Author: User
Tags memory usage snmp centos cpu usage mrtg


The following are notes:

1. Check whether mrtg software is installed in the system.
# Rpm-qa | grep mrtg *

Install mrtg software
# Yum-y install mrtg *

2. mrtg configuration file (The following is a detailed description of the mrtg configuration file)
Provide us Pengfei micro service configuration file for everyone download Reference: http://url.cn/PT118T [file name Settings]

# Vi/etc/mrtg. cfg
The following is an explanation of the configuration:
HtmlDir:/var/www/mrtg // html storage directory
ImageDir:/var/www/mrtg // Directory for generating images
LogDir:/var/www/mrtg // log storage directory
ThreshDir:/var/lib/mrtg

# Monitor the eth1 Nic (connected to the public network). Other monitors are similar to this one
Target [eth1_lan]:/192.168.1.68: public @ localhost: // mrtg uses the snmp protocol and uses the public key to monitor traffic on the localhost server's point/interface (192.168.1.68)
Options [eth1_lan]: growright // right-aligned image
Directory [eth1_lan]: eth1 // Directory for storing the statistics image of this Nic; for storing the generated traffic statistics Image
Maxbytes [eth1_lan]: 100000000 // maximum number of bytes of the NIC
Kmg [eth1_lan]: K, M, G // unit on the y axis, k, m, g
YLegend [eth1_lan]: Bytes per Second // Y axis title
ShortLegend [eth1_lan]: B/s // Y axis unit size

# The following is the title of the webpage; at the bottom of the webpage
Legend1 [eth1_lan]: Inbound traffic per second (unit: Bytes)
Legend2 [eth1_lan]: outbound traffic per second (unit: Bytes)
LegendI [eth1_lan]: inbound // input marking color
LegendO [eth1_lan]: outbound // outbound marking color
Title [eth1_lan]: eth1 network traffic [inbound + outbound] // webpage Title
PageTop [eth1_lan]:

# Monitor CPU load [user + idle], similar to the above
Target [cpuload]:. 1.3.6.1.4.1.2021.11.50.0 &. 1.3.6.1.4.1.2021.11.53.0: public @ localhost: // mrtg uses the snmp protocol and uses the public key to monitor the localhost server node/interface (cpu load rate and idle rate)
Options [cpuload]: nopercent, growright // right-aligned image
Directory [cpuload]: Directory for storing cpu // statistical images
Maxbytes [cpuload]: 100 // maximum CPU usage
YLegend [cpuload]: CPU Utilization // Y axis title
ShortLegend [cpuload]: % // Y axis unit size

# The following is the title of the webpage; at the bottom of the webpage
Legend1 [cpuload]: CPU user load (%)
Legend2 [cpuload]: idle CPU (%)
LegendI [cpuload]: User // tag color
LegendO [cpuload]: Idle // marked color
Title [cpuload]: CPU load [user + idle] // webpage Title
PageTop [cpuload]:

# Monitor memory usage [Mem + Swap]
Target [memory]:. 1.3.6.1.2.1.25.2.3.1.6.2 &. 1.3.6.1.2.1.25.23.1.6.3: public @ localhost:
Options [memory]: gauge, growright
Directory [memory]: mem
MaxBytes1 [memory]: 255412 // maximum memory size. The value here must be the maximum value obtained in free-k, as shown in the following figure.
MaxBytes2 [memory]: 524280 // swap maximum value. The value here must be the maximum value obtained in free-k, as shown in the following figure.
Kmg [memory]: K, M, G
Kilo <memory]: 1024
Unscaled [memory]: dwym
YLegend [memory]: Men Bytes
ShortLegend [memory]: B
Legend1 [memory]: used Men (Bytes)
Legend2 [memory]: Swap used (Bytes)
LegendI [memory]: Mem used:
LegendO [memory]: Swap used:
Title [memory]: memory usage [Mem + Swap]
PageTop [memory]: memory usage [Mem + Swap]


# Monitoring hard disk space [system disk + data disk]
Target [disk]:. 1.3.6.1.4.1.2021.9.1.8.1 &. 1.3.6.1.4.1.2021.9.1.8.2: public @ localhost:
Options [disk]: gauge, growright
Directory [disk]: disk
MaxBytes1 [disk]: 19679908
MaxBytes2 [disk]: 101086
Kmg [disk]: K, M, G
Kilo [disk): 1024
Unscaled [disk]: dwym
YLegend [disk]: Disk Bytes
ShortLegend [disk]: B
Legend1 [disk]: space used by the system disk
Legend2 [disk]: used space of the data disk
LegendI [disk]: used by the system:
LegendO [disk]: used data:
Title [disk]: hard disk space [system disk + data disk]
PageTop [disk]:

Use mrtg to generate monitoring images
#/Usr/bin/mrtg/etc/mrtg. cfg // load this configuration file;
An error occurs.
Three times in execution
# LANG = C LC_ALL = C/usr/bin/mrtg/etc/mrtg. cfg -- lock-file/var/lock/mrtg/mrtg_l -- confcache-file/var/lib/mrtg. OK
Unless your mrtg. cfg has a syntax error, an image is generated once it is executed.

Set crontab to automatically execute the script:
/Etc/cron/The following script will be automatically executed by cron and the task plan will be executed.
Here, mrtg automatically generates an mrtg file to schedule the task file, in which you can write and set the task plan.
Vi/etc/cron. d/mrtg
The task plan has been set up in it. Change it to 5 minutes and once every 2 minutes.
*/2 ****
This command is also obtained in this file during three consecutive executions, followed by the root command.
The generated webpage contains garbled characters because the encoding does not support Chinese characters. You need to modify the generated source code to set the generated web code, or each time you watch your own set browser encoding as UTF-8;
How to modify source code
# Vi/usr/bin/mrtg
Find
<Meta http-equiv = "content-type" content = "text/html; charset = '. & $ LOC ('ISO-8859-1 '). "\"/> \ n ";
Replace
<Meta http-equiv = "content-type" content = "text/html; charset = '. & $ LOC ('utf-8 '). "\"/> \ n ";
The generated subpage will not be garbled.

Generate a monitoring homepage file
Use indexmaker to generate the mrtg monitoring homepage file, which is generated immediately after execution
# Indexmaker -- output/var/www/mrtg/index.html -- title = "Pengfei microservice server monitoring"/etc/mrtg. cfg
By default, the home page does not support Chinese characters. You need to modify the source code.
# Vi/usr/bin/indexmaker
Find
<Meta http-equiv = "content-type" content = "text/html; charset = ISO-8859-15">
Replace
<Meta http-equiv = "content-type" content = "text/html; charset = utf-8">
Then, no garbled characters are generated.


You can configure apach or nginx to access your website in different ways.

Related Article

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: info-contact@alibabacloud.com 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.