LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 2025|回复: 8

终于安装完 mrtg+rrdtool+routers.cgi实现 CPU,内存,交换机等流量监控

[复制链接]
发表于 2005-10-20 15:23:57 | 显示全部楼层 |阅读模式
自己做了一周,感觉久了一点啊。带着胜利的喜悦,来这里与大家分享。有不足的地方请大家多多原谅。

以下是我的安装手稿:
                    
Mrtg+rrdtool+routers2.cgi

1.技术说明:
        mrtg 是一个监控网络链路流量负载的工具软件,它通过snmp协议从设备得到设备的流量信息。然后将采样数据保存到rrd数据库中。Rrd 这个工具专门用于收集数据, 并且按照一定的周期生成曲线图 ,不过它不包含数据采集功能, 而且灵活性高适应面更广.

2.所需软件:
          Perl   Zlib  Gd  libpng  Apache  snmp  mrtg(我的系统是linux AS4 ,一般的都是默认安装的).可以用 Rpm –qa|grep ***   这个命令来查看是否安装。
         Rrdtool          下载地址: http://people.ee.ethz.ch/~oetiker/w...l-          1.0.48.tar.gz
         Routers2.cgi      下载地址: http://www.steveshipway.org/softwar...s2-v2.14.tar.gz
3. 安装步骤:
         1). Mrtg 的安装
            Mrtg 系统没有默认安装,找到linux as4 第二张光盘,找到一个mrtg-2.10.15-1.i386.rpm包,然后rpm –ivh mrtg-2.10.15-1.i386.rpm就可以安装使用了.
         2). Rrdtool的安装
            Cd /home
                   Mkdir mrtg
                  Cd mrtg
                  Tar  zvf  rrdtool-1.2.11.tar.tar
                 Cd  rrdtool-1.2.11
                  ./configure –disable-tcl 注意: rrdtool不需要tcl的支持,如果不关闭加载tcl可能会出现问题
            Make
                 Make install
4. 配置snmp :
            1) 以cisco 2950T为例,作为mrtg 的客户端。
               C:\telnet 您的交换机的IP  
                       User Access Verification  
                       Password:  
                      TNKSW>en  Password:  
                      TNKSW# conf t  TNKSW(config)# nmp-server community abc RO  设置密码:abc      
                      TNKSW(config)# snmp-server trap-source FastEthernet0/1监控对象端口: FastEthernet0/1
                     TNKSW(config)# snmp-server contact abc@163.com 管理标识abc@163.com
                    TNKSW(config)# snmp-server host 192.168.0.6 abc 来源mrtg地址:192.168.0.6
                    TNKSW(config)# snmp-server enable traps 要监控的内容 traps TNKSW# sh run  
                   TNKSW# wr
              2) 配置mrtg服务端
                 首先编写一个自动生成监控对象参数的脚本automr.sh:
                 #!/bin/sh
                          cfgmaker --global "WorkDir: /opt/sino/web/mrtg" \ //存放库文件的地方
                           --global "Options[_]: growright,bits" \
                                        --ifref=ip \
                                        --output mrtg.test \  //输出mrtg.test文件                  
                                         abc@ip  # a bc 是你snmp认证的口令,ip交换机的IP
                          保存automr.sh 文件。
                 
                   Chmod 775 automr.sh
                         Sh automr.sh
                          这样,mrgt就采集到了被监控设备的信息了。下一步需要初始化rrdtool
                          Vi mrtg.test
                         在 Options[_]: growright,bits  下面添加如下语句:
                 LogFormat: rrdtool //用rrdtool初始化
                 PathAdd:/usr/bin
                         LibAdd:/usr/lib/perl5/site_perl/5.8.0/i386-linux-thread-multi/ //perl安装的路径。
                 Mkdir /home/mrtg/etc
                        Cp mrtg.test /home/mrtg/etc/switch.cfg
                       到这里,snmp 和mrtg都配置完毕,下一步生成 rrd 数据库了。
                 /usr/bin/mrtg  /home/etc/switch.cfg
                 执行完毕以后,就会在 /home/mrtg/etc目录下生成一个swtich.ok 文件。
                 5.安装routers.cgi:
                 Cd /home/mrtg
                         Tar  zvf  routers2-v2.14.tar.tar
                          Cd  routers-2.2.14
                          ./configure --prefix=/usr/local
                           Make; make install
                         Perl install.pl
                 
# NOTICE: This module requires libgd 2.0.5 or higher.
it will NOT work with earlier versions.
For earlier versions of libgd, use GD version 1.41.

Where is libgd installed? [/usr/lib] /usr/local/gd/lib

Please choose the features that match how libgd was built:
Build JPEG support? [y] y //需要输入的地方
Build FreeType support? [y] n //需要输入的地方
Build XPM support? [y] n //需要输入的地方

If you experience compile problems, please check the @INC, @LIBPATH and @LIBS
arrays defined in Makefile.PL and manually adjust, if necessary.

Writing Makefile for GD

# make;make install
# tar zxvf routers2-v2.11.tar.Z
# cd routers2-v2.11
# perl install.pl //执行该命令后会要你回答一系列的问题,请根据你的系统情况如实填写

This program attempts to install the routers2.cgi package, located in
the current directory. It will attempt to identify system settings,
but you must confirm the locations guessed, or give the correct
information.
At any point, you can answer 'quit' to abort the installation.
Depending on your Perl implementation, you may also have line editing
and history capability.
Default answers are in square brackets before the prompt.
Continue [yes]?
Checking Perl libraries...
RRDs library found correctly.
WARNING: You do not have the GD Perl libraries installed correctly.
routers2.cgi will still run, but the Compact Summary display will not work.
Download the GD libraries from CPAN.org if required.
NT Users should use PPM to collect GD from ActiveState.
UNIX users should note that they need the GD.pm Perl library IN ADDITION to
the libgd.a C library.
Continue [y]?
WARNING: You do not have the Time::Zone library installed.
This is not a big problem, so don't worry.
This will only be a potential problem if you are using multiple time zones and
your operating system does not support the TZ environment variable.
If you wish to obtain this package, visit CPAN.org
WARNING: You do not have the Net::SNMP library installed.
This library is required if you wish to use the routingtable extension.
routers2.cgi will run correctly without this package, however.
If you wish to obtain this package, visit CPAN.org

FINDING OUT ABOUT YOUR SYSTEM

0. Attempting to identify your OS and web server...
- I think you are running under UNIX.
- I think you have Apache installed in
/etc/httpd/conf //apache安装的地方

1. Web server document root directory.
This is the base document directory of your web server.
Document root [/var/www/html]? //网站主目录

2. Web server CGI directory.
This is the directory where your web server keeps the CGI scripts.
CGI directory [/var/www/cgi-bin/]? //网站cgi目录

3. MRTG install directory.
This is the directory where your MRTG configuration files are kept
MRTG config directory? /etc/mrtg //你的mrtg的配置文件存放地

4. MRTG config files.
This is the wildcarded filename format for your MRTG configuration files.
Use a '*' to mean 'any characters' - for example, '*.cfg' or '*/*.conf'.
MRTG files [*.cfg]? //mrtg配置文件的格式(后缀)

5. RRD Database directory.
This is the directory where your .rrd files are kept
RRD directory [/var/www/html/mrtg/]? //存放rrd库的地方,在你的mrtg配置文件里设的

6. Perl executable.
This is the full pathname of where the Perl executable file is kept.
Perl executable [/usr/bin/perl]? //默认

7. routers2.cgi configuration file
This is the file that will hold the routers2.cgi configuration. Unless you
have a reason to move it, stick with the default.
If this file already exists, I will ask before overwriting it!
Configuration file [/var/www/html/mrtg/routers2.conf]? /var/www/html/mrtg/routers2.conf
//你的外挂脚本配置文件存放位置
ASKING OPTIONS
1. Net::SNMP does not appear to be installed. Extensions disabled.
If you subsequently install Net::SNMP, then you can enable the extensions
in the routers2.conf file.

2. GD does not appear to be installed. This is required for the compact
summary screen to work. If you intend to install it later, answer YES.
Otherwise, answer NO.
Activeate Compact Summary screen [no]? yes //需要GD

3. How big should 1K and 1M be? This is the 'usebigk' parameter from the
routers2.conf file. You have three options - 'yes', 'no' and 'mixed'.
yes -> 1K=1024, 1M=1024x1024
no -> 1K=1000, 1M=1000x1000
mixed -> 1K=1024, 1M=1024x1000 (dont ask)
'usebigk' option [mixed]? yes //选择流量计算方法

4. Can I attempt to send an email to the author to let him know that the
software has been installed? This will only give your routers.cgi version,
Perl version, and Operating System version.
Can I mail [yes]?

INSTALLING SOFTWARE

Perl is : /usr/bin/perl
MRTG files : /etc/mrtg/*.cfg
RRD files : /var/www/html/mrtg/
Doc root : /var/www/html
CGI bin : /var/www/cgi-bin/
Config file : /var/www/html/mrtg/routers2.conf
Extensions : INACTIVE
Compact page: ENABLED
'usebigk' : yes
Mail Steve : yes
Other options can be set later by modifying the Config file
Continue [yes]?
WARNING: /var/www/html/mrtg/routers2.conf already exists!
Overwrite existing file [no]? yes
Creating /var/www/html/mrtg/routers2.conf...
No Mail::Send available, trying sendmail instead.
/usr/sbin/sendmail: invalid option -- U
/usr/sbin/sendmail returned code 0. Looks like I cant send an email after all.


** ALL COMPLETE **

You should now be able to run the software, although you may need to
make sure you have your web server running.
To access the frontend, point your favourite web browser at the URL:
http://netcool2/cgi-bin/routers2.cgi

See http://www.cheshire.demon.co.uk/pub/wishlist for information on
how to say 'thanks' for this free software.

* Apache users should make sure that mod_expires is loaded and enabled
* Apache should also be configured with 'AllowOverride: All' for the directory
/var/www/html/graphs
* Apache users should NOT use mod_perl or speedycgi for this script.
* You may wish to tighten the rights granted on the graphs directory
/var/www/html/graphs //图片输出位置   

这样你就可以通过  http://ip/cgi-bin/routers2.cgi来查看你的流量图了。
 楼主| 发表于 2005-10-20 17:41:21 | 显示全部楼层
??没有人顶
回复 支持 反对

使用道具 举报

发表于 2005-10-20 21:30:45 | 显示全部楼层
MRTG做出来还用顶啊?。。。。。。。。

这两天弄了一个cacti 那个也不错,你也装装看吧。

比MRTG好的地方是它是往mysql数据库里保存信息的,所以可以支持任何时间的查询等等。

感觉不错。控制起来也很方便,还在试验中。
回复 支持 反对

使用道具 举报

发表于 2005-10-20 21:32:18 | 显示全部楼层
cacti 需要编译安装 apache php zend(可选,如果你想php执行快点的话) mysql net-snmp cacti rrdtool 基本上你需要用到的东西就练了一个遍了
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-10-21 09:01:50 | 显示全部楼层
谢谢楼上的兄弟,cacti我也装过,我不喜欢这种傻瓜试的东西,我比较亲睐 mrtg。呵呵
回复 支持 反对

使用道具 举报

发表于 2005-10-21 20:19:27 | 显示全部楼层
我现在所有的路由器等网络设备全都在用mrtg监控,虽然功能上没什么问题,不过感觉mrtg也有不好的地方。就如同我说的如果你想查某一天某一点的状况就不方便。
cacti这点做得不错,至于其它的我想就是配置起来简单吧。
而且我觉得最方便的就是数据的备份了,全都在数据库里头,一考就走了。
mrtg现在我都是每天晚上12点取一下系统时间然后cp到一个目录做成tar,不如这个好感觉。

不过我想网络运营上mrtg足够了,就是看流量罢了
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-10-24 08:57:13 | 显示全部楼层
恩,同意楼上的观点。其实mrtg也就是告诉我们流量怎么样?负载没有啊。
回复 支持 反对

使用道具 举报

为什么不能注册 该用户已被删除
发表于 2005-10-26 14:46:05 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复 支持 反对

使用道具 举报

 楼主| 发表于 2005-11-4 16:40:26 | 显示全部楼层
那也可以啊,直接cfgmaker public@IP  生成交换机所有端口的数据,然后拷贝到响应的CFG文件中
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表