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