技术员联盟提供win764位系统下载,win10,win7,xp,装机纯净版,64位旗舰版,绿色软件,免费软件下载基地!

当前位置:主页 > 教程 > 服务器类 >

Linux系统mrtg安装设置教程

来源:技术员联盟┆发布时间:2019-05-12 06:05┆点击:

MRTG(Multi Router Traffic Grapher)是一套可用来绘出网络流量图的软件,由瑞士奥尔滕的Tobias Oetiker与Dave Rand所开发,此软件以GPL授权。

下面是网卡流量监控图

Linux系统mrtg安装设置教程 三联

MRTG最早的版本是在1995年春天所推出,以Perl所写成,因此可以跨平台使用,它利用了SNMP送出带有物件识别码(OIDs)的请求给要查询的网络设备,因此设备本身需支援SNMP。MRTG再以所收集到的资料产生HTML档案并以GIF或PNG格式绘制出图形,并可以日、周、月等单位分别绘出。它也可产生出最大值最小值的资料供统计用。

原本MRTG只能绘出网络设备的流量图,后来发展出了各种plug-in,因此网络以外的设备也可由MRTG监控,例如服务器的硬盘使用量、CPU的负载等。

Mrtg可用来监视linux的各种详细参数,如果不明白可以去搜索一下就知道了.今天我主要讲解的是他的设置方法.

一、前期准备

(1)MRTG需要以SNMP服务为基础,所以请确保你的系统已经启用了此服务,修改SNMP的配置:
#vi /etc/snmp/snmpd.conf
将62行:
access notConfigGroup "" any noauth exact systemview none none
改为
access notConfigGroup "" any noauth exact mib2 none none
把第89行前面的注释符号#去掉,变成
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc

(2)linux Mrtg监控主机流量启动http服务和snmp服务:
首先查看两个服务在系统启动时是否已经开启
#chkconfig --list | grep nginx
没有启动的话需要修改下在什么启动模式下要自己启动:
# chkconfig --level 35 nginx on
对 snmpd 服务采用同样的设置,现在手动启动下
#service nginx start
#service snmpd start
啟動之後最好是用setup配置服務,讓其隨機自動啟動

查看端口的开启状况也可確認其是否已經被啟動
# 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

(3)MRTG生成供浏览图像需要http服务的支持,同时也需要gd、libpng和zlib三个软件包的支持,而gd的正常运行也需要其它的几个软件,(系統默認自帶,如果沒有自帶則需要我們手工安裝)
1.安装zlib-1.2.3
#tar zxvf zlib-1.2.3.tar.gz
#cd zlib-1.2.3
#./configure --prefix=http://www.3lian.com/usr/local/zlib
#make
#make install

2.安装httpd-2.2.4
#tar zxvf httpd-2.2.4.tar.gz
#cd httpd-2.2.4
#./configure --prefix=http://www.3lian.com/usr/local/apache --sysconfdir=http://www.3lian.com/etc/httpd --enable-so --enable-track-vars --enable-rewrite --with-z-dir=http://www.3lian.com/usr/local/zlib
#make
#make install
启动httpd
/usr/local/apache/bin/apachectl -k start

3.安装libpng-1.2.14
#tar zxvf libpng-1.2.14.tar.gz
# cd libpng-1.2.14
# cp scripts/makefile.linux makefile
# make (若是提示找不到zlib库文件或者头文件,多半是makefile文件里zlib的默认路径有误。可编辑makefile文件,找到zlib项并重新指定路径到/usr/local/zlib/lib和/usr/local/zlib/include)。
# make install

4.安装freetype-2.1.10
# tar -zvxf freetype-2.1.10.tar.gz
# cd freetype-2.1.10
# mkdir -p /usr/local/freetype
# ./configure --prefix=http://www.3lian.com/usr/local/freetype
# make;make install

5.安装jpegsrc.v6b
jpeg默认不会自建目录,因此需手动建立目录:
# mkdir -pv /usr/local/jpeg6/{,bin,lib,include,man/{,man1},man1}
安装
#tar zxvf jpegsrc.v6b.tar.gz
# ./configure --prefix=http://www.3lian.com/usr/local/jpeg6/ --enable-shared --enable-static
# make
# make install
# make install-lib

6.安装libxml2-2.6.19
# tar -zxf libxml2-2.6.19.tar.gz
# cd libxml2-2.6.19
# mkdir -p /usr/local/libxml2
# ./configure --prefix=http://www.3lian.com/usr/local/libxml2
# make; make install
#cp xml2-config /usr/bin

7.安装GD-2.0.33库
# tar -zvxf gd-2.0.33.tar.gz
# mkdir -p /usr/local/gd2
# cd gd-2.0.33
# ./configure --prefix=http://www.3lian.com/usr/local/gd2 --with-jpeg=http://www.3lian.com/usr/local/jpeg6/ --with-png=http://www.3lian.com/usr/local/lib/ --with-zlib=http://www.3lian.com/usr/local/zlib/ --with-freetype=http://www.3lian.com/usr/local/freetype/
# make
# make install

(4)修改系統語言配置
#vi /etc/profile
增加如下兩行
LC_ALL=C
LANGUAGE=on

二、开始安装

(1)开始安装mrtg
#cd /usr/local/src
#wget
#tar zvxf mrtg-2.14.5.tar.gz
#cd mrtg-2.14.5
#./configure --prefix=http://www.3lian.com/usr/local/mrtg 注意:“--prefix=http://www.3lian.com/usr/local/mrtg”是指定的安装路径
#make
#make install