打印

[分享] Win2K 安装MRTG

Win2K 安装MRTG

Win2K 安装MRTG

mrtg(MultiRouter Traffic Grapher, mrtg)是基于SNMP的典型网络流量统计分析工具,它耗用的系统资源很小。

测试环境:Win2K-sp4,hostname为Honey,IP地址:192.168.0.10
监控目标:3COM 17206 交换机 IP地址:192.168.0.11


Win2K下安装网络流量统计分析工具mrtg所需软件:

mrtg-2.10.14.zip
下载:http://people.ee.ethz.ch/~oetike ... ub/mrtg-2.10.14.zip

ActivePerl-5.8.4.810-MSWin32-x86.msi
下载:http://downloads.activestate.com ... 810-MSWin32-x86.msi

新建一个f:\mrtg目录,并把相关文件放在此目录下。

1、安装Perl
运行ActivePerl-5.8.4.810-MSWin32-x86.msi,按默认安装即可

2、安装mrtg
解压mrtg-2.10.14.zip

3、设定mrtg

3.1先建立mrtg发布目录
C:\Inetpub\wwwroot\mrtg

3.2建立mrtg配置文件
f:\mrtg\mrtg-2.10.14\bin> perl cfgmaker public@192.168.0.11 --global "WorkDir: c:\InetPub\wwwroot\mrtg" --global "Options[_]: growright,bits" --ifref=ip --output mrtg.cfg

--global参数表示后面的选项是对后面指定的设备都是有效的(如果希望对多个设备进行监控时,该参数就会发生作用)。
WorkDir用来指示mrtg的工作目录;
Options用来指定一些特定的选项,这里的growright,bits是用来指定默认options配置的,对于常见的应用来说默认options配置就可以满足需求了。
ifref用来指示用什么选项来标识设备接口,ifref可以指定为nr、ip、eth、descr、name。
nr表示用接口在MIBII库中Interface接口的ifIndex来识别接口;
IP表示使用ip地址识别接口;
eth表示使用接口的物理地址标识接口;
descr表示使用接口的描述信息来标识接口;
name表示使用接口名来标识接口。
一般来说ip地址是唯一的,但是有些情况下接口是没有IP地址的,例如交换机就会出现这种情况。对于接口来说nr(接口号)是唯一的,因此对于一般情况使用IP地址就可以了,而对于其他一些情况则需要采用nr了。
--output mrtg.cfg 标识将生成的配置文件名。
public@192.168.0.11 表示监控IP地址为192.168.0.11的设备,采用public作为共同体名通过snmp协议来监控设备192.168.0.11。

3.3 产生主index.html文件
f:\mrtg\mrtg-2.10.14\bin> perl indexmaker --output=C:\Inetpub\wwwroot\mrtg\index.html --title="Honey's 3com mrtg sheet" f:\mrtg\mrtg-2.10.14\bin\mrtg.cfg
--output:想要存放网页的地方
--title:inex.html的title
f:\mrtg\mrtg-2.10.14\bin\mrtg.cfg :mrtg配置文件的地址

3.4 将f:\mrtg\mrtg-2.10.14\images目录中的所有文件放入C:\Inetpub\wwwroot\mrtg\


3.5 让mrtg连续、定期执行 (每5分钟执行一次)
在配置文件mrtg.cfg中,加入这一行:RunAsDaemon: yes

3.6 mrtg中文化
在mrtg的配置文件mrtg.cfg加入这一行Language: gb

3.7 第一次执行mrtg
f:\mrtg\mrtg-2.10.14\bin> perl mrtg mrtg.cfg
本帖最近评分记录
  • mwpq 菊花元 +4 我很赞同 2006-5-30 07:04

TOP

以前想试 不过没时间去找资料。哈哈 现在可以试了。谢谢楼主
—————————————————

Romanhuang's MSN space
学习是一辈子的事情

—————————————————

TOP

更正地址连接

mrtg-2.10.14.zip已经被删除。最新版本下载:

http://people.ee.ethz.ch/~oetiker/webtools/mrtg/pub/mrtg-2.14.3.zip


ActivePerl-5.8.4.810-MSWin32-x86.msi下载:
http://downloads.activestate.com/ActivePerl/Windows/5.8/ActivePerl-5.8.4.810-MSWin32-x86.msi


[ 本帖最后由 Romanhuang 于 2006-5-30 07:19 编辑 ]
本帖最近评分记录
  • mwpq 菊花元 +2 辛苦 2006-5-30 09:52
—————————————————

Romanhuang's MSN space
学习是一辈子的事情

—————————————————

TOP

是不错的东东,第一次看到在linux下
http://oss.oetiker.ch/mrtg/

TOP

这个软件放置的pc有要求吗?必需是交换机的数据出口吗?
我是一只菜 菜 菜 菜鸟,想要飞,却怎么样也飞不高

TOP

引用:
原帖由 shopperman 于 2006-5-30 08:34 发表
这个软件放置的pc有要求吗?必需是交换机的数据出口吗?
不用 可参考这里学习:

http://oss.oetiker.ch/mrtg/doc/mrtg-nt-guide.en.html
—————————————————

Romanhuang's MSN space
学习是一辈子的事情

—————————————————

TOP

引用:
原帖由 Romanhuang 于 2006-5-30 09:42 发表


不用 可参考这里学习:

http://oss.oetiker.ch/mrtg/doc/mrtg-nt-guide.en.html
mrtg在NT环境使用手册

如有错误,恳请通知我。谢谢!idcpanda@126.com
帮助原文是用WEB界面,大家可以看doc目录下的nt-guide文件.
NAME
名称:
nt-guide - The Windows NT Guide to MRTG 2.9.28
NT向导 - MRTG2.9.28的NT指导手册大纲
--------------------------------------------------------------------------------
SYNOPSIS
Installing MRTG on an Windows NT or Windows 2000 box is not quite as ``click and point'' as some might want it to be. But then again, it is not all that difficult if you follow the instructions below.
大纲:
在Windows NT或者Windows 2000环境下安装MRTG并不像有些人希望的那样,完全是“点击”。然而从另外一方面来看,如果你按照下面指示的方法来做,它也并不总是那末困难。

--------------------------------------------------------------------------------

PREREQUISITS
先决条件:
To get MRTG to work on Windows NT you need the following:
为了将MRTG安装到你的NT系统并且工作,你需要如下条件:
A copy of Perl for NT from http://www.ActiveState.com (it must be version 5.005, or better yet, 5.6).

The latest version of MRTG from http://people.ee.ethz.ch/~oetiker/webtools/mrtg/pub Look for mrtg-2.9.28.zip or better. The archive also contains a precompiled copy of rateup.exe for Win32.

从http://www.Activestate.com(注:大家可以从网上很多地方获得)获取一个Perl的拷贝(必须是5.005或者以上的版本)。

最新的MRTG版本mrtg-2.9.28.zip 或者更高可以从http://people.ee.ethz.ch/~oetiker/webtools/mrtg/pub获得,这个软件包还包括一个win32的预编译器 rateup.exe。

注:
我现在使用的这两个软件分别从http://www.activestate.com/http://people.ee.ethz.ch/~oetiker/webtools/mrtg/pub/获得,大家还可以去http://people.ee.ethz.ch/~oetiker/webtools/mrtg/看一些资料.
--------------------------------------------------------------------------------

INSTALLATION
I suggest you do the following from the machine that will be running MRTG, which, in this case, is also a web server.

安装:建议安装在服务器上。

First
首先
Unzip MRTG to C:\mrtg-2.9.28 on the WindowsNT machine of your choice.
将MRTG解压到你选择的Windows NT机器的C:\mrtg-2.9.28目录下。

Next
下一步

Install Perl on the same Windows NT machine. You might want to make sure that the Perl binary directory is listed in your system path.
C:\Perl\bin;%SystemRoot%\system32;%SystemRoot%;...You can manually check this by going to [Control Panel]->[System]->[Environment]

将Perl安装到同一台Windows NT机器上,你可能想要确认Perl二进制目录已经存在于你的系统路径中,
C:\Perl\bin;%SystemRoot%\system32;%SystemRoot%;
你可以通过控制面板-》系统-》环境来手动检查这一项

To see if everything is installed properly you can open a Command Shell and go into c:\mrtg-2.9.28\bin. Type:

perl mrtg
为了查看是否以上安装都是正确地,你可以打开一个DOS界面,并且进入c:\mrtg-2.9.28\bin目录
,输入:
perl mrtg

This should give you a friendly error message complaining about the missing mrtg configuration file. Now, you have successfully installed mrtg and perl.
这将给你一个友好的错误信息指出错误的mrtg配置文件。现在,你已经成功的安装了mrtg和perl。


--------------------------------------------------------------------------------

CONFIGURING MRTG
配置MRTG

Now it is time to create a configuration for mrtg.燘ut before we begin you need to know a few things. Take an opportunity to gather the following information:

现在我们来为mrtg生成一个配置文件。在开始之前,你必须清楚几件事情.

The IP address or hostname and the snmp port number, (if non standard), of the device you want to monitor.

你想要监测的IP地址或者主机名以及设备的端口号(如果是非标准设备).

If you want to monitor something other than bytes in and out, you must also know the SNMPOID of what you want to monitor.

如果你想要监测除了数据进出之外的其他信息,你必须知道你想要监测的信息的SNMPOID编号.

Finally you need to know the read-only SNMP community string for your device.?If you don't know it, try public, that is the default.

最后你需要知道你的设备的只读SNMP团体字.如果你不知道,可以用public来尝试,这个值一般作为默认值.

For the rest of this document we will be using device 10.10.10.1 ( a CISCO Catalyst 5000) with Community string public.?We are interested in monitoring traffic, and the CPU load. Let's begin.

在下面的文档中,我们将使用设备10.10.10.1(一台CISCO Catalyst 5000设备),它的团体字是public,我们关注它的通信量,以及它的CPU负载.下面我们开始操作:

The first thing we do in setting up mrtg is making a default config file. Get to a cmd prompt and change to the c:\mrtg-2.9.28\bin directory. Type the following command:

装配mrtg的第一件事情是我们创建一个默认的配置文件.请转入DOS命令行模式并且进入 c:\mrtg-2.9.28\bin目录,并且输入如下命令:

perl cfgmaker public@10.10.10.1 --global "WorkDir: c:\www\mrtg" --output mrtg.cfg


This creates an initial MRTG config file for you. Note that in this file all interfaces of your router will be stored by number. Unfortunately, these numbers are likely to change whenever you reconfigure your router. In order to work around this you can get cfgmaker to produce a configuration which is based on Ip numbers, or even Interface Descriptions.

这个命令将创建一个初始的MRTG配置文件.请注意在这个文件中,所有的路由器的端口将被存储为编号.不幸的是,这些变好可能会在你重新配置的时候改变.为此你可以获取cfgmaker以生成基于IP地址或者一致的接口描述的配置文.现在检查

If you get an error message complaining about no such name or no response, your community name is probably wrong.

如果你获取了一个错误的信息说没有这样的名字或者没有响应,那末应该是你所使用的团体名存在错误.
Now, let's take a look at the mrtg.cfg file that was created.

In Perl, a # is a comment, synonymous with REM in DOS.
现在,让我们看一下生成的mrtg.cfg文件.
在perl中,一个"#"号代表注释,等同与DOS中的REM

Add the following to the top of the mrtg.cfg file:
将下面一行加入mrtg.cfg的头部:

WorkDir: D:\InetPub\wwwroot\MRTG

This is where the web pages are created, usually a web root.
这个路径就是我们最后看到的生成的web页面的地方,通常是一个web跟

以下是文件的内容,我们生成的文件就是这样的格式.

######################################################################
# Description: LCP SUWGB
# Contact: Administrator
# System Name: LC-Bridge
# Location: Here
#.....................................................................
TargetDevice's IP Address:Interface Number:Community:IP Address

Target[10.10.10.1.1]: 1:public@10.10.10.1This is the interface speed (Default is 10 megabits; for 100Mbit devices use 12500000 and so on...)

MaxBytes[10.10.10.1.1]: 1250000 Title[10.10.10.1.1]: LC-Bridge (sample.device): ether0This section determines how the web page headers will look

PageTop[10.10.10.1.1]: <H1>Traffic Analysis for ether0</H1>
<TABLE>
<TR><TD>System:</TD><TD>LC-Bridge inAndover</TD></TR>
<TR><TD>Maintainer:</TD><TD>Administrator</TD></TR>
<TR><TD>Interface:</TD><TD>ether0(1)</TD></TR>
<TR><TD>IP:</TD><TD>sample.device(10.10.10.1)</TD></TR>
<TR><TD>Max Speed:</TD>
<TD>1250.0 kBytes/s (ethernetCsmacd)</TD></TR>
</TABLE> Target[10.10.10.1.2]: 2:public@10.10.10.1
MaxBytes[10.10.10.1.2]: 1250000
Title[10.10.10.1.2]: LC-Bridge (): ulink0
PageTop[10.10.10.1.2]: <H1>Traffic Analysis for ulink0</H1>
<TABLE>
<TR><TD>System:</TD><TD>LC-Bridge inAndover</TD></TR>
<TR><TD>Maintainer:</TD><TD>Administrator</TD></TR>
<TR><TD>Interface:</TD><TD>ulink0(2)</TD></TR>
<TR><TD>IP:</TD><TD>()</TD></TR>
<TR><TD>Max Speed:</TD>
<TD>1250.0 kBytes/s (ethernetCsmacd)</TD></TR>
</TABLE> #---------------------------------------------------------------


And that's a very basic mrtg config file. You can run this and see your results by going into the c:\mrtg-2.9.28\bin directory and typing:
这是一个非常基本的mrtg配置文件,你可以运行这个文件,并且可以在指定的路径下目录下看到运行的结果.运行的命令是在c:\mrtg-2.9.28\bin目录下输入:
perl mrtg mrtg.cfg

It is normal to get errors for the first two times you run this command. The errors will alert you about the fact that there have not been any log files in existence before.
通常在你开始运行这个命令的一两次里,可能会有出错信息.这个信息警告你以前还没有日志文件存在.
If you take a look at those web pages they are not very exciting (yet). You need to have the mrtg files run every five minutes to produce the desired results. Just run it again after a few minutes. You should now be able to see the first lines in your graphs.
如果你现在去查看web页面,可能它们并不让你激动.你需要让mrtg文件每五分钟运行一次以产生期望的结果.过一会再去运行它,你将会看到在你的图表上有了第一条线.


--------------------------------------------------------------------------------

MAKE MRTG RUN ALL THE TIME
让MRTG始终运行:

Starting mrtg by hand every time you want to run it is not going to make you happy I guess.
我猜想,在你需要运行这个程序的时候,每次都手动去启动不会让你高兴.
There is a special option you can set in the mrtg configuration file so so that mrtg will not terminate after it was started. Instead it will wait for 5 minutes and then run again.
这里有一个特殊的选项,你可以把它设置到mrtg配置文件中,这样,mrtg将在启动以后不在终止,而是自动每隔5分钟去运行一次

Add the option to your mrtg.cfg file
加入如下的语句到你的mrtg.cfg文件中:

RunAsDaemon: yes

and start it with:
并在启动中加入这个程序:

start /Dc:\mrtg-2.9.28\bin wperl mrtg --logging=eventlog mrtg.cfg


If you use wperl instead of perl, no console window will show. MRTG is now running in the background. If it runs into problems it will tell you so over the EventLog. To stop MRTG, open the Task Manager and terminate the wperl.exe process. If mrtg has anything to tell you these messages can be found in the event log.
如果你是用wperl代替perl,将没有控制台窗口被显示.MRTG现在运行在后台.如果他在运行过程中出现问题,它将会通过时间日志告诉你.要终止MRTG,打开任务管理器,终止wperl.exe进程就可以了. 如果mrtg有任何信息要通知你,

If you put a shortcut with
如果你采用一种简洁的方式:
Target: wperl mrtg --logging=eventlog mrtg.cfg
Start in: c:\mrtg-2.9.28\bin

into your startup folder, mrtg will now start whever you login to your NT box.
添加到你的启动文件中,mrtg将在你登录到NT系统的时候自动启动.


If you do not want to log into your NT box just to start mrtg. Have a look at http://www.firedaemon.com/mrtg-howto.html which describes a free tool to start any program as a Service. The pages gives specific instructions for mrtg users.
如果你不希望登录到NT系统后就启动mrtg,请参考http://www.firedaemon.com/mrtg-howto.html文件,这个文件描述了一个免费工具用来像启动一个设备一样启动任何程序.这个网页对于mrtg使用者给出了详细的介绍.



--------------------------------------------------------------------------------

EXAMPLE
Now lets look at a config file to monitor what we wanted to on our mythical Cisco Cat 5000 -- utilization on ports 3, 5, 10, and 24, and the CPU Load, which will show us nonstandard mrtg configurations as well as more options..
例子:
现在看看我们希望监控的路由器的端口3.5.10.24的配置文件,以及CUP负载.它将向我们展示有了更多的选项后的非标准的mrtg配置文件:

WorkDir: D:\InetPub\wwwroot\MRTG ######################################################################
# Description: LCP SUWGB
# Contact: Administrator
# System Name: LC-Bridge
# Location: Here
#..................................................................... Target[10.10.10.1.1]: 3:public@10.10.10.1
MaxBytes[10.10.10.1.1]: 1250000
Title[10.10.10.1.1]: LC-Bridge (sample-device): ether0
PageTop[10.10.10.1.1]: <H1>Traffic Analysis for ether0</H1>
<TABLE>
<TR><TD>System:</TD><TD>LC-Bridge inAndover</TD></TR>
<TR><TD>Maintainer:</TD><TD>Administrator</TD></TR>
<TR><TD>Interface:</TD><TD>ether0(3)</TD></TR>
<TR><TD>IP:</TD><TD>sample-device(10.10.10.1)</TD></TR>
<TR><TD>Max Speed:</TD>
<TD>1250.0 kBytes/s (ethernetCsmacd)</TD></TR>
</TABLE> #--------------------------------------------------------------- Target[10.10.10.1.2]: 5:public@10.10.10.1
MaxBytes[10.10.10.1.2]: 1250000
Title[10.10.10.1.2]: LC-Bridge (): ulink0
PageTop[10.10.10.1.2]: <H1>Traffic Analysis for ulink0</H1>
<TABLE>
<TR><TD>System:</TD><TD>LC-Bridge inAndover</TD></TR>
<TR><TD>Maintainer:</TD><TD>Administrator</TD></TR>
<TR><TD>Interface:</TD><TD>ulink0(5)</TD></TR>
<TR><TD>IP:</TD><TD>()</TD></TR>
<TR><TD>Max Speed:</TD>
<TD>1250.0 kBytes/s (ethernetCsmacd)</TD></TR>
</TABLE> #--------------------------------------------------------------- Target[10.10.10.1.1]: 10:public@10.10.10.1
MaxBytes[10.10.10.1.1]: 1250000
Title[10.10.10.1.1]: LC-Bridge (sample-device): ether0
PageTop[10.10.10.1.1]: <H1>Traffic Analysis for ether0</H1>
<TABLE>
<TR><TD>System:</TD><TD>LC-Bridge inAndover</TD></TR>
<TR><TD>Maintainer:</TD><TD>Administrator</TD></TR>
<TR><TD>Interface:</TD><TD>ether0(10)</TD></TR>
<TR><TD>IP:</TD><TD>sample-device(10.10.10.1)</TD></TR>
<TR><TD>Max Speed:</TD>
<TD>1250.0 kBytes/s (ethernetCsmacd)</TD></TR>
</TABLE> #--------------------------------------------------------------- Target[10.10.10.1.2]: 24:public@10.10.10.1
MaxBytes[10.10.10.1.2]: 1250000
Title[10.10.10.1.2]: LC-Bridge (): ulink0
PageTop[10.10.10.1.2]: <H1>Traffic Analysis for ulink0</H1>
<TABLE>
<TR><TD>System:</TD><TD>LC-Bridge inAndover</TD></TR>
<TR><TD>Maintainer:</TD><TD>Administrator</TD></TR>
<TR><TD>Interface:</TD><TD>ulink0(24)</TD></TR>
<TR><TD>IP:</TD><TD>()</TD></TR>
<TR><TD>Max Speed:</TD>
<TD>1250.0 kBytes/s (ethernetCsmacd)</TD></TR>
</TABLE> #--------------------------------------------------------------- # Router CPU load %
Target[cpu.1]:1.3.6.1.4.1.9.2.1.58.0&1.3.6.1.4.1.9.2.1.58.0:public@10.10.10.1
RouterUptime[cpu.1]: public@10.10.10.1
MaxBytes[cpu.1]: 100
Title[cpu.1]: CPU LOAD
PageTop[cpu.1]: <H1>CPU Load %</H1>
Unscaled[cpu.1]: ymwd
ShortLegend[cpu.1]: %
XSize[cpu.1]: 380
YSize[cpu.1]: 100
YLegend[cpu.1]: CPU Utilization
Legend1[cpu.1]: CPU Utilization in % (Load)
Legend2[cpu.1]: CPU Utilization in % (Load)
Legend3[cpu.1]:
Legend4[cpu.1]:
LegendI[cpu.1]:
LegendO[cpu.1]: Usage
Options[cpu.1]: gauge


This is a nice example of how to monitor any SNMP device if you know what OID you want to use. Once again, For an explanation of the more advance features of mrtg, please see Tobias's documentation.
这是一个监控SNMP设备的很好的例子,只要你知道你想要监控的对象的OID.如果你想知道更多的mrtg的特色,请参阅Tobias's 文档


--------------------------------------------------------------------------------

AUTHORS
David S. Divins <ddivins@moon.jic.com>, Steve Pierce <MRTG@HDL.com>, Tobi Oeitker <oetiker@ee.ethz.ch>


最后,补充说明,这个软件还可以同时监控多个设备,需要生成cfg文件的时候输入:
perl cfgmaker --global "WorkDir: c:\inetpub\wwwroot" --global "Options[_]: growright,bits" --ifdesc=alias public@IP地址 public@IP地址 --output mrtg.cfg
这个时候,你会看到mrtg.cfg文件中包含了两个路由器的信息.
在mrtg.cfg文件中,添加生成页面路径和始终运行的信息.
有一点我不明白的地方:需要删除cfg文件中的ifdesc=alias语句,否则执行的时候会报错.

在修改了cfg文件以后,就可以在bin目录下输入perl mrtg mrtg.cfg运行程序了
你将会看到,在你指定的路径下,生成对多个设备的监控web页面.

此外,还可以将生成的页面统一到一个页面中,使之便于比较这一点.需要在bin目录下执行:
perl indexmaker --output=default.html mrtg.cfg
就可以了.最后这一个方法我没有使用,大家可以尝试,如果有问题,希望能够和我探讨.


idcpanda@126.com

TOP

看来需要学习的很多呀
鸡声茅店月,人迹板桥霜
心有鸿鹄志,天高自飞翔

TOP

回复 7楼 的帖子

很好,谢谢。
想问问在win下用,mrtg做关于单个服务器cpu,内存的 服务器负荷,监测怎么做了。和路由器的做法 一样吗

TOP

这个软件要好好研究一下.

TOP