How to install the configuration MRTG-2.15.1 server

Source: Internet
Author: User
Tags memory usage mkdir snmp mrtg
The system used in this article is RH9.0 and the native IP address is 192.168.1.6

First, MRTG need to be based on SNMP services, so make sure your system has this service enabled

1. Please ensure that the following 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 from the following line
View MIB2 included. Iso.org.dod.internet.mgmt.mib-2 FC

Add the following line at approximately 55 lines
View SystemView included. 1.3.6.1.2.1.2

Put down like a downward
Access Notconfiggroup "" Any noauth exact systemview none None
Changed to:
Access Notconfiggroup "" Any noauth exact mib2 none None

3. Enable SNMPD Service
#service snmpd Start
#chkconfig--levle 2345 snmpd on

4. View the port's opening condition
# 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

Second, MRTG generated for browsing image needs httpd service support, but also need GD, libpng and zlib three software package support, and GD's normal operation also requires several other software, the following installation of them

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 the hint can not find the Zlib library file or header file, most of the makefile file zlib default path is incorrect. You can edit the makefile file, locate the zlib item, and reassign 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 jpegsrc.v6b
JPEG does not build its own directory by default, so you need to manually build the directory:
# Mkdir-pv/usr/local/jpeg6/{,bin,lib,include,man/{,man1},man1}
Installation
#tar ZXVF jpegsrc.v6b.tar.gz
#./configure--prefix=/usr/local/jpeg6/--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 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/jpeg6/--with-png=/usr/local/lib/--with-zlib=/usr/ local/zlib/--with-freetype=/usr/local/freetype/
# make
# make Install

Third, install the configuration 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--SYSCONFDIR=/ETC/MRTG--with-gd=/usr/local/gd2/include--with-gd-lib=/usr/ Local/gd2/lib--with-gd-inc=/usr/local/gd2/include--with-png=/usr/local/include--with-png-lib=/usr/local/lib-- With-png-inc=/usr/local/include--with-zlib=/usr/local/zlib/include--with-zlib-lib=/usr/local/zlib/include-- With-zlib-inc=/usr/local/zlib/include
# make
# make Install

3. Basic Configuration

To generate a master configuration file
#/usr/local/mrtg/cfgmaker public@localhost >/etc/mrtg/mrtg.cfg

Edit/etc/mrtg/mrtg.cfg
Will
#WorkDir:/HOME/HTTP/MRTG
Remove the comment and change it to
Workdir:/USR/LOCAL/APACHE/HTDOCS/MRTG (here is your httpd default home directory)

Remove the comment for the following line
# Options[_]: Growright, Bits

Add the following line to implement the display of Chinese characters in the Web page
language:gb2312

Generate MRTG Web page home page file
#/usr/local/mrtg/bin/indexmaker/etc/mrtg/mrtg.cfg--output=/usr/local/apache/htdocs/mrtg/index.html--title= "my MRTG "

4. Start MRTG
#env lang=c/usr/local/mrtg/bin/mrtg/etc/mrtg/mrtg.cfg
This command outputs some error messages, which are generally safely ignored and executed three consecutive times.

5.MRTG generated Web pages are static, in order to allow them to constantly refresh, you need to add the above command into the crontab
#crontab-E
Add the following line
*/3 * * * env LANG=C/USR/LOCAL/MRTG/BIN/MRTG/ETC/MRTG/MRTG.CFG
Note: This row means that every three minutes is refreshed, and you can modify the refresh interval to suit your needs.

6. Installation finished, you can go to see the results, in the browser input form such as the following address
HTTP://192.168.1.6/MRTG (IP address for your machine IP)

四、一个 Example: Memory usage monitoring

1. Create a new folder that holds the script
#mkdir-pv/usr/local/apache/htdocs/mrtgsh

2. Create a script file
#vi/usr/local/apache/htdocs/mrtgsh/mrtg.memory
Add the following script:
#!/bin/bash
# Run this script to check the MEM usage.
Totalmem= '/usr/bin/free |grep Mem |awk ' {print $} '
Usedmem= '/usr/bin/free |grep Mem |awk ' {print $} '
Uptime= '/usr/bin/uptime | awk ' {print $ ' $ ' $} '
Echo $totalmem
Echo $usedmem
Echo $UPtime
Let it have run permissions
#chmod 755/usr/local/apache/htdocs/mrtgsh/mrtg.memory

3. Editor/etc/mrtg/mrtg.cfg
Add the following content
Target[memory]: '/usr/local/apache/htdocs/mrtgsh/mrtg.memory '
Maxbytes[memory]: 4096000
Title[memory]:memory Usages
Shortlegend[memory]: &
Kmg[memory]:kb,mb
kilo[memory]:1024
Ylegend[memory]: Memory Usage:
Legend1[memory]: Total Memory:
Legend2[memory]: Used Memory:
Legendi[memory]: Total Memory:
Legendo[memory]: Used Memory:
Options[memory]: growright,gauge,nopercent
Pagetop[memory]:
4. Rebuild the home page file
#/usr/local/mrtg/bin/indexmaker/etc/mrtg/mrtg.cfg--output=/usr/local/apache/htdocs/mrtg/index.html--title= "my MRTG "

5. You can restart the MRTG as appropriate, and then you can view the effect.


This paper turns from bbs.chinaunix.net

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.