MRTG的安装配置
大纲:
1.安装perl(最好是5.6版本).
2.安装MRTG,可以使用用mrtg-2.9.17.zip或者mrtg-2.9.29.zip 。在win32中的文件应该包含一个rateup.exe 。
安装:
1.解压MRTG到c:\mrtg-2.9.17目录下
2.安装perl,你要确信perl的系统目录路径跟下面列出的一致:
复制
C:\Perl\bin;%SystemRoot%\system32;%SystemRoot%;...
1.
2.
你可以到控制面板--系统--环境变量中看到这些信息。
如果你安装好了,可以在命令提示符下,到C:\mrtg-2.10.15\bin目录下,输入:
复制
perl mrtg
1.
2.
系统会给你一个正常的错误信息,需要一个MRTG的配置文件:
复制
Usage: mrtg mrtg-2.9.17 is the Multi Router Traffic Grapher. If you want to know more about this tool, you might want to read the docs. They came together with mrtg! Home: http://people.ee.ethz.ch/~oetiker/webtools/mrtg/
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
配置MRTG:
首先应该建立一个MRTG的配置文件,你需要知道下面的一些信息:
1.了解你要监控的设备ip地址或者主机名,snmp的端口号码(如果不是标准的端口号码);
2.如果你想监控其它的输入输出字节,还需要知道设备得的SNMPOID
3.最好你还必须了解SNMP的只读团体字符串
现在用一个例子说明一下:设备ip为10.56.57.38,我们将监控流量和CPU负载
1.首先我们设置MRTG的默认配置文件,在命令提示符下,进入到C:\mrtg-2.10.15\bin 目录下,输入下面命令:
perl cfgmaker public@10.56.57.38 --global "WorkDir: c:\InetPub\wwwroot\MRTG" --output mrtg.cfg 这样就建立了一个初始的配置文件,注意这个文件中设备所有接口的存储号码。当你重配置你的设备时这些号码可能会被改变,因此你可以使用cfgmaker描述一些接口。
复制
C:\mrtg-2.9.17\mrtg-2.9.17\bin>perl cfgmaker public@10.56.57.73 --global "WorkDir: C:\flow\mrtg\test" --output mrtg.cfg --base: Get Device Info on public@10.56.57.38: --base: Vendor Id: --base: Populating confcache --snpo: confcache public@10.56.57.38: Descr MS TCP Loopback interface --snpo: confcache public@10.56.57.38: Descr VMware Virtual Ethernet Adapter -->
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
2
复制
--snpo: confcache public@10.56.57.38: Descr VMware Virtual Ethernet Adapter -->
1.
2.
3 (duplicate)
复制
--snpo: confcache public@10.56.57.38: Descr Intel 8255x-based Integrated Fast Et hernet --snpo: confcache public@10.56.57.38: Ip 10.56.57.38 --> 16777221 --snpo: confcache public@10.56.57.38: Ip 127.0.0.1 --> 1 --snpo: confcache public@10.56.57.38: Ip 192.168.198.1 --> 3 --snpo: confcache public@10.56.57.38: Ip 192.168.240.1 --> 2 --snpo: confcache public@10.56.57.38: Type 24 --> 1 --snpo: confcache public@10.56.57.38: Type 6 --> 2 --snpo: confcache public@10.56.57.38: Type 6 --> 3 (duplicate) --snpo: confcache public@10.56.57.38: Type 6 --> 16777221 (duplicate) --snpo: confcache public@10.56.57.38: Eth --> 1 --snpo: confcache public@10.56.57.38: Eth 00-50-56-c0-00-08 --> 2 --snpo: confcache public@10.56.57.38: Eth 00-50-56-c0-00-01 --> 3 --snpo: confcache public@10.56.57.38: Eth 00-a0-c9-25-ba-9d --> 16777221 --base: Get Interface Info --base: Walking ifIndex --base: Walking ifType --base: Walking ifSpeed --base: Walking ifAdminStatus --base: Walking ifOperStatus --base: Writing mrtg.cfg
1.
2.
3.
4.
5.
6.
7.
8.
9.
10.
11.
12.
13.
14.
15.
16.
17.
18.
19.
20.
21.
22.
23.
24.
25.
26.
27.
28.
29.
30.
31.
32.
33.
34.
35.
36.
37.
38.
39.
40.
41.
42.
现在基本MRTG配置文件建立,你进入C:\mrtg-2.10.15\bin 目录下输入下面的命令看一下结果:
复制
perl mrtg mrtg.cfg
1.
2.
现在你就可以通过web查看到一些流量信息。
使MRTG实时运行:
现在我们希望让他实时运行,我们需要对他的配置文件进行设置。我们在mrtg.cfg中添加以下参数,使其每隔五分钟就的采集一次信息。
增加选项
复制
RunAsDaemon: yes Interval:5
1.
2.
3.
4.
生成主页面:
复制
perl indexmaker --output=C:\flow\mrtg\test\index.html mrtg.cfg
1.
2.
(运行MRTG:
复制
perl mrtg --logging=mrtg.log mrtg.cfg
1.
使用web访问http://127.0.0.1/MRTG/index.htm看MRTG是否正常生成统计页面。)
到你的mrtg.cfg文件中并且开始运行:
复制
start /DC:\mrtg-2.10.15\bin wperl mrtg --logging=eventlog mrtg.cfg
1.
2.
如果你想停止的话,可以在任务管理器中终止wperl进程。
假如你想在win启动时就启动MRTG,可以使用下面的信息:
复制
Target: wperl mrtg --logging=eventlog mrtg.cfg Start in: C:\mrtg-2.10.15\bin
1.
2.
3.
4.
其使用firedaemon软件
配置系统服务:
1.添加srvany.exe服务
复制
instsrv MRTG "C:\mrtg-2.10.15\bin\srvany.exe"
1.
2.
2.配置srvany:
在注册标HEKY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MRTG中添加parameters子键。在子键中添加以下项目:
Application的字符串,内容为C:\Perl\bin\perl.exe
AppDirectory的字符串,内容为C:\mrtg-2.10.15\bin\
AppParameters的字符串,内容为mrtg --logging=mrtg.log mrtg.cfg
3.在服务中启用MRTG服务即可实时监控指定主机信息
MRTG的安装配置就介绍到这里了。
【编辑推荐】