Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to install MRTG on RedHat to monitor the traffic of local network card

Shulou Source: shulou.com Published: 2022-06-01 10:40:15 09月18日 Update

This article mainly explains "how to install MRTG on RedHat to monitor local network card traffic". The explanation in this article is simple and clear and easy to learn and understand. please follow the editor's train of thought to study and learn "how to install MRTG on RedHat to monitor local network card traffic".

Install MRTG on RedHat to monitor the traffic of local network card

System environment: redhat9.0

Essential software:

The system must have the following software installed, all of which can be found on the CD:

Gd-1.8.4-11

Gd-devel-1.8.4-11

Libpng-1.2.2-16

Libpng-devel-1.2.2-16

Libpng10-1.0.13-8

Libpng10-devel-1.0.13-8

Perl-5.8.0-88

Zlib-1.1.4-8

Zlib-devel-1.1.4-8

Httpd-manual-2.0.40-21

Httpd-2.0.40-21)

Gcc-3.2.2-5

Net-snmp-5.06-17

Mrtg-2.9.29.tar.gz

MRTG works on the SNMP protocol, you must install SNMP to start MRTG to observe your network, I just did not configure NET-SNMP, so MRTG display will not have graphics, I made such a mistake. Some networks are required to install UCD-SNMP, my redhat 9.0 is installed by default is net-snmp, so I did not use ucd-snmp, have not tried, but I think it is more or less the same.

1. First, install and configure net-snmp

# rpm-ivh net-snmp-5.06-17 # usually redhat9.0 is installed by default. After # vi / etc/snmp/snmpd.conf # is installed, configure the / etc/snmp/snmpd.conf file to work with mrtg.

Go to line 90 and remove the # below

# view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc # on line 89

Put the following statement # on line 62

Access notConfigGroup "" any noauth exact systemview none none

Change to:

Access notConfigGroup "" any noauth exact mib2 none none

Go to line 397

Rocommunity mrtg

Remember, this is the community is mrtg, not the common public, this will be used in the future to remember, I just used public many times to get the graphics, now think of, stupid. Public may be the default in ucd-snmp and has not been used. What does Ro mean, read only, also heard others say (and friends asked, what to do without this line, hey, add to go! To ask such a question!).

Ok, after the modification, you can start the snmpd service, and the SNMP configuration is complete.

# / etc/rc.d/init.d/snmpd start

two。 Install mrtg

Tar zvxf mrtg-2.9.29.tar.gz cd mrtg-2.9.29. / configure-- prefix=/usr/local/mrtg\-- with-gd=/usr/include\-- with-gd-lib=/usr/lib\-- with-gd-inc=/usr/include\-- with-png=/usr/include\-with-zlib=/usr/include & & make & & make install

3. Configure mrtg

# mkdir / var/www/html/mrtg where / var/www/html is the default home address of www. You may be different from me. # cp images/* / var/www/html/mrtg images/* is in the mrtg-2.9.29 folder where mrtg-2.9.29.tar.gz is unzipped # / usr/local/mrtg/bin/cfgmaker-- output=/var/www/html/mrtg/mrtg.cfg\ > Mrtg@192.168.0.1 # here is to create a mrtg.cfg file

Please pay special attention to this: in the mrtg@192.168.0.1 line, mrtg is meaningful (in the default search code in the snmp communication service, the default may be public, which is why you just want to check / etc/snmp/snmpd.conf), so, if the dynamic DNS name of your host is your.domain.name, then you must write it as mrtg@your.domain.name! Make no mistake! Many netizens have encountered this problem!

Under the / var/www/html/mrtg directory, and monitor the address of 192.168.0.1. In this example, this address is the local Nic IP address.

# vi / var/www/html/mrtg/mrtg.cfg # modify the mrtg.cfg file, mainly by modifying the following to suit your actual situation

WorkDir: / var/www/html/mrtg Options [_]: growright, bits Language:GB2312

One thing to note about this is that there are no spaces in front of them, otherwise there will be some "ERROR: Line 8 (WorkDir: / var/www/html/mrtg) in CFG file (mrtg) does not make sense" error.

Here is the following:

# / usr/local/mrtg/bin/mrtg / var/www/html/mrtg/mrtg.cfg

This needs to be run 3 times, the first two times will report an error, ignore him, the third time there should be no error, however, if there is a problem, you need to modify the mrtg.cfg, and then execute until no error occurs.

The mistake goes something like this:

Rateup WARNING: / usr/local/mrtg2/bin/rateup could not read the primary log file for localhost Rateup WARNING: / usr/local/mrtg2/bin/rateup The backup log file for localhost was invalid as well Rateup WARNING: / usr/local/mrtg2/bin/rateup Can't remove localhost.old updating log file Rateup WARNING: / usr/local/mrtg2/bin/rateup Can't rename localhost.log to localhost.old updating log file

4. Make the home page index.html:

# / usr/local/mrtg/bin/indexmaker\ >;-- output=/var/www/html/mrtg/index.html\ >;-- title= server traffic statistics\ >; / var/www/html/mrtg/mrtg.cfg

The above program indexmaker is making the home page. Will automatically output an index.html file. If you modify this file later (for example, increase the detection of CPU, hard disk, etc., you need to generate it again, otherwise the drawing will not come out.)

5. Set to be executed every 5 minutes

Running mrtg manually does not generate appropriate statistics on a regular basis, so * * automatically run mrtg statistics on a regular basis. The default is once every five minutes.

Enter the editing state as root identity crontab-e, and add the following:

* / 5 * root / usr/local/mrtg/bin/mrtg / var/www/html/mrtg/mrtg.cfg

Ok! At this point, when the configuration is complete, be sure to restart the snmp and httpd services!

Visit: http://192.168.0.1/mrtg/

You can see the network traffic graph.

Thank you for reading, the above is the content of "how to install MRTG on RedHat to monitor local network card traffic". After the study of this article, I believe you have a deeper understanding of how to install MRTG on RedHat to monitor local network card traffic, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Traffic network card local machine monitoring file configuration that is error content address problem service operation network software learning statistics one line information graphics Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Shulou Tech Info Apple Linux Docker