Article title: MRTG installation configuration document. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
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-5.0.6-17
Net-snmp-devel-5.0.6-17
Net-snmp-utils-5.0.6-17
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 are also required. Other software is required for the normal operation of gd, install them together
1. install zlib-1.2.3
# Tar zxvf zlib-1.2.3.tar.gz
# Cd zlib-1.2.3
#./Configure -- prefix =/usr/local/zlib
# Make
# Make install
2. install httpd-2.2.4
# Tar zxvf httpd-2.2.4.tar.gz
# Cd httpd-2.2.4
#. /Configure -- prefix =/usr/local/apache -- sysconfdir =/etc/httpd -- enable-so -- enable-track-vars -- enable-rewrite -- with-z-dir =/ usr/local/zlib
# Make
# Make install
Start httpd
/Usr/local/apache/bin/apachectl-k start
3. install libpng-1.2.14
# Tar zxvf libpng-1.2.14.tar.gz
# Cd libpng-1.2.14
# Cp scripts/makefile. linux makefile
# Make (if you are prompted that the zlib library file or header file cannot be found, the default path of zlib in the makefile file is incorrect. You can edit the makefile file, find the zlib item, and re-specify the path to/usr/local/zlib/lib and/usr/local/zlib/include ).
# Make install
4. install freetype-2.1.10
# Tar-zvxf freetype-2.1.10.tar.gz
# Cd freetype-2.1.10
# Mkdir-p/usr/local/freetype
#./Configure -- prefix =/usr/local/freetype
# Make; make install
5. install composer src. v6b
By default, jpeg does not create user-created directories. Therefore, you need to manually create directories:
# Mkdir-pv/usr/local/IPv6/{, bin, lib, include, man/{, man1}, man1}
Install
# Tar zxvf restart src.v6b.tar.gz
#./Configure -- prefix =/usr/local/defaults 6/-- enable-shared -- enable-static
# Make
# Make install
# Make install-lib
6. install libxml2-2.6.19
# Tar-zxf libxml2-2.6.19.tar.gz
# Cd libxml2-2.6.19
# Mkdir-p/usr/local/libxml2
#./Configure -- prefix =/usr/local/libxml2
# Make; make install
# Cp xml2-config/usr/bin
7. install the GD-2.0.33 Library
# Tar-zvxf gd-2.0.33.tar.gz
# Mkdir-p/usr/local/gd2
# Cd gd-2.0.33
#. /Configure -- prefix =/usr/local/gd2 -- with-jpeg =/usr/local/defaults 6/-- with-png =/usr/local/lib/-- with-zlib = /usr/local/zlib/-- with-freetype =/usr/local/freetype/
# Make
# Make install
III. install and configure MRTG
1. download mrtg, the latest version is mrtg-2.15.1
Http://oss.oetiker.ch/mrtg/pub/mrtg-2.15.1.tar.gz
2. install mrtg-2.15.1
# Tar zxvf mrtg-2.15.1.tar.gz
# Cd mrtg-2.15.1
#./Configure -- prefix =/usr/local/mrtg
# Make
# Make install
3. basic configuration
Generate the main configuration file
Cd/usr/local/mrtg/bin/
. /Producer maker -- snmp-options =: 2 -- global 'workdir:/var/www/html/mrtg '-- global "language: chinese "-- global 'options [_]: growright, bits '-- ifref = ip -- output/etc/mrtg. cfg public@10.0.1.1.
The configuration file mrtg. cfg is generated under/etc.
The configuration file can be modified as needed
Generate the MRTG webpage homepage file
#/Usr/local/mrtg/bin/indexmaker/etc/mrtg. cfg -- output =/var/www/html/mrtg/index.html -- title = "name yourself"
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.
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
*/2 ***** env LANG = C/usr/local/mrtg/bin/mrtg/etc/mrtg. cfg
Note: This row indicates refresh every two minutes. you can modify the refresh interval as needed.
Back up mrtg to generate images
The autoback. sh script in the/root/directory is as follows:
#! /Bin/sh
Backup_ball = "/home/backup/mrtgall _ $ (date ready before f).tar.gz"
If tar jcf $ backup_ball/var/www/html/mrtg
Then
Echo "$ backup_ball backup succeeded. :)" | mail-s "backup OK" root
Else
Echo "$ backup_ball backup failed. :(" | mail-s "backup FAILED" root
Fi
Scheduled execution in crontab
0 14 ***/bin/bash/root/autoback. sh