Chinaunix首页 | 论坛 | 博客
  • 博客访问: 381948
  • 博文数量: 136
  • 博客积分: 4010
  • 博客等级: 上校
  • 技术积分: 1410
  • 用 户 组: 普通用户
  • 注册时间: 2006-03-14 14:11
文章分类

全部博文(136)

文章存档

2008年(16)

2007年(27)

2006年(93)

我的朋友

分类: 系统运维

2006-11-02 19:36:04

1 install apache to c:\apache2  
 
2 install active perl for windows to c:\perl.   
 
3 download mrtg ,extract to c:\mrtg.         
 
4 configure cisco switch or router
cisco2950的ip为192.168.0.254
cisco2950(config)# nmp-server community china RO
cisco2950(config)# snmp-server host 192.168.0.3 china
cisco2950(config)# snmp-server enable traps
china 为community的名字,默认为public, RO为只读
host 192.168.0.3  为安装mrtg的主机
 
5 configure mrtg
 
1)生成mrtg配置文件
c:\mrtg\bin\perl cfgmaker --global "WorkDir: c:\mrtgdata" --output mrtg2950.cfg
,前者为community的名字,192.168.0.254为交换机的IP,也就是SNMP源的IP;
WorkDir: c:\mrtgdata  为将来mrtg产生的流量图片和数据存放的目录;
output2950.cfg  为mrtg产生的针对2950的配置文件,位于当前目录下,即c:\mrtg\bin\,如果需要监控多个设备,该配置文件名需要写成不同的名字;
 
修改output2950.cfg文件:

###Global Config Options的下一行加入一条命令:
RunAsDaemon: yes
这条命令的作用是使MRTG每5分钟自动去获取一次SNMP的数据及更新网络流量图形。
 
2)开始生成流量图
  c:\mrtg\bin\perl  mrtg mrtg2950.cfg
 
3)生成Index.htm文件,output后面输入全路径,我从google和MRTG官方网站上看到的都没有全路径,结果导致总是失败,
c:\mrtg\bin\perl indexmaker --output=c:\mrtgdata\index.htm mrtg2950.cfg
如果你有多个设备或多个接口需要监控,需要执行如下命令,将所有的接口集成到一个index.htm页面中去,在命令的最后输入全部的配置文件即可:
c:\mrtg\bin\perl indexmaker --output=c:\mrtgdata\index.htm mrtg2950B.cfg mrtg2950B.cfg
这样,交换机2950A和2950B的监控数据将会同时出现在index.htm同一个页面中;
6 修改apache配置文件 httpd.conf
 
1)将DocumentRoot "c:/apache2/htdocs"  修改为 DocumentRoot "c:/mrtgdata"
 
2)找到如下格式数据,修改如下:其中增加DirectoryIndex index.htm index.html    

    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    #
    # for more information.
    #
    Options Indexes FollowSymLinks
    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None
    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all
    DirectoryIndex index.htm index.html     

3)在apache的全局设置中增加DirectoryIndex index.htm index.html    
 
7 设置mrtg为windows系统服务,使其能够开机后自动运行,需要用到两个软件,可以再这里下载
文件: service_tool.rar
大小: 42KB
下载: 下载
或者到 下载,文件名为
 SRVANY.exe (Applications as Services Utility) 
 INSTSRV.exe (Service Installer)
 
  • 复制 srvany.exe and instsrv.exe 到 c:\mrtg\bin\ (your MRTG bin directory).
  • 创建注册表文件 mrtg.reg ,存放到任何地方都可以,形式如下:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\MRTG\Parameters]
"Application"="c:\\perl\\bin\\wperl.exe"
"AppParameters"="c:\\mrtg\\bin\\mrtg --logging=eventlog c:\\mrtg\\bin\\mrtg.cfg"
"AppDirectory"="c:\\mrtg\\bin\\"

红色的MRTG可以自己命名,尤其是需要监控多个设备时需要注意,名字不能相同,蓝色的MRTG不能改变,是系统的参数。例如我要监控2950A和2950B两个交换机,可以这样:
2950A.reg
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\2950A\Parameters]
"Application"="c:\\perl\\bin\\wperl.exe"
"AppParameters"="c:\\mrtg\\bin\\mrtg --logging=eventlog c:\\mrtg\\bin\\2950A.cfg"
"AppDirectory"="c:\\mrtg\\bin\\"
 
 
2950B.reg
Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\29550B\Parameters]
"Application"="c:\\perl\\bin\\wperl.exe"
"AppParameters"="c:\\mrtg\\bin\\mrtg --logging=eventlog c:\\mrtg\\bin\\2950B.cfg"
"AppDirectory"="c:\\mrtg\\bin\\"

Once again, assuming that MRTG is already fully installed and configured on the target system under c:\mrtg\ the following steps are necessary to setup MRTG as a service.

Using the command prompt go into the temporary directory where you unzipped the package. When there type the following command to create a service named ``MRTG'' in the Windows Services management console:

 instsrv MRTG c:\mrtg\bin\srvany.exe
红色的MRTG服务名字与上面建立的注册表中的相对应,同理如果需要安装多个服务,此服务名不可相同,比如需要安装监控两个交换机的服务,2950A和2950B,可以这样:
instsrv 2950A c:\mrtg\bin\srvany.exe
instsrv 2950B c:\mrtg\bin\srvany.exe
此时,在windows的系统服务中会出现2个服务,名字分别为2950A和2950B;
 然后,双击上一步建立的注册表文件,即可将相关信息导入到注册表中去;
 
8 重新启动计算机之后,在IE中输入安装MRTG的IP地址,即可看到流量图,每5分钟采集一次;
 
 
over
阅读(1263) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~