URN Logo
UNIX Resources » Linux » China Linux Forum » 网络管理技术 » 7 » [原创] 手把手:RPM/编译/自动安装MRTG
announcement 声明: 本页内容为中国Linux论坛的内容镜像,文章的版权以及其他所有的相关权利属于中国Linux论坛和相应文章的作者,如果转载,请注明文章来源及相关版权信息。
Resources
China Linux Forum(finished)
Linux Forum(finished)
FreeBSD China(finished)
linuxforum.net
  业界新闻与评论
  自由软件杂谈
  IT 人生
  Linux软件快递
  翻译作坊
  Linux图书与评论
  GNU Emacs/XEmacs
  Linux 中文环境和中文化
  Linux桌面与办公软件
  Linux 多媒体与娱乐版
  自由之窗Mozilla
  笔记本电脑上的Linux
  Gentoo
  Debian 一族
  网络管理技术
  Linux 安装与入门
  WEB服务器和FTP服务器
  域名服务器和邮件服务器
  Linux防火墙和代理服务器应用
  文件及打印服务器
  技术培训与认证
  Linux内核技术
  Linux 嵌入技术
  Linux设备驱动程序
  Linux 集群技术
  LINUX平台数据库
  系统和网络安全
  CPU 与 编译器
  系统计算研究所专栏
  Linux下的GUI软件开发
  C/C++编程版
  PHP 技 术
  Java&jsp技术
  Shell编程技术
  Perl 编 程
  Python 编 程
  XML/Web Service 技术
  永远的Unix
  FreeBSD世界
   
[原创] 手把手:RPM/编译/自动安装MRTG
Author: canglan    Posted: 2005-05-04 18:23    Length: 6,580 byte(s)
[Original] [Print] [Top]
出处 菜鸟油 ( http://www.noobu.com ) 作者:沧蓝 欢迎转载,转载请注明出处与作者,谢谢
<推荐> 本文的完美排版/最后更新修正版本:http://www.noobu.com/0504_mrtg_install.html <推荐>


MRTG (Multi Router Traffic Grapher) 是一款系统带宽监测软件。也是最著名、使用最广泛的同类软件之一。下面将介绍三种不同的安装方法。

首先,是通过 yum 安装的RPM安装方式。菜鸟油的服务器为CentOS,控制面板采用的是DSM,由于其特殊性,导致部分MRTG与部分软件不兼容。编译时会显示如下错误:

** Ooops, one of many bad things happened:

a) You don’t have the GD library installed.
Get it from http://www.boutell.com, compile it and
use either –with-gd-lib=DIR and –with-gd-inc=DIR to specify
its location. You might also have to use –with-z-inc,
–with-z-lib and –with-png-inc, –with-png-lib for gd
versions 1.6 and higher. Check config.log for more
information on the problem.

b) You have the GD library installed, but not the gd.h
header file. Download the source (see above) and use
–with-gd-inc=DIR to specify where the file can be found.

c) You have the library and the header file installed, but
you also have a shared GD library in the same directory.
Remove the shared library files and/or links (e.g.
libgd.so.2.0.0, libgd.so and libgd.so.2). This is especially
likely if you’re using a recent (post 1.8.4) version of GD
and didn’t configure it with –disable-shared.

d) You have gd library installed and also it’s headers, but you are
missing libpng (and headers) or freetype (and headers)
(mrtg does not use freetype, but if your copy of gd is precompiled
against it, you have to install it …

由于更改这些软件的配置可能会导致控制面板失效,所以,笔者采用yum来安装已编译好的RPM包:

yum install mrtg

安装完MRTG后(默认安装到 /var/www/mrtg ),根据系统的不同,还需要做一些配置工作。

先更新一下搜索库:

updatedb

然后分别搜索以下内容:

locate cfgmaker
locate indexmaker
locate mrtg.cfg


以下假定这三个文件的路径分别为:

/usr/bin/cfgmaker
/usr/bin/indexmaker
/etc/mrtg/mrtg.cfg

请根据自己的实际情况更改后面内容中的相关代码。

执行以下代码配置MRTG(请将粗体部分替换为您的实际服务器IP):

/usr/bin/cfgmaker --output=/etc/mrtg/mrtg.cfg public@111.111.111.111

如果有多个IP需要监视的,就运行该命令多次。

执行以下代码生成MRTG的页面(title部分是页面的标题):

/usr/bin/indexmaker --output=/var/www/mrtg/index.html --title="MRTG Graph" /etc/mrtg/mrtg.cfg

修改配置文件:

nano /etc/mrtg/mrtg.cfg

去除 WorkDir: 前的“#”,并设置路径为 /var/www/mrtg 。
可选:去除 Options[_]: growright, bits 前的“#”。

接着,请确认你的Apache web目录(比如/var/www/html或/home/username/pubic_html/或/usr/local/apache/htdocs等)。执行以下命令:

ln -s /var/www/mrtg path/to/apache/web/mrtg

请将粗体部分替换为您的Apache web目录。

如此,就能通过浏览器访问MRTG页面了。

最后一部是将生成MRTG图形的代码加入到Cron中,让系统定时自动更新。命令为 env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

如果需要MRTG的log文件的话:

touch /var/log/mrtg.log

并将Cron中( nano /etc/crontab )的运行命令改为 env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg –logging /var/log/mrtg.log ,例如:

*/5 * * * * env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --logging /var/log/mrtg.log

至此,采用RPM的安装方式就顺利完成了。此方法应当也适用于apt-get,不过笔者没有实验过。

方法二:编译安装

由于在方法一中已经详细的说明了如何配置MRTG,所以编译安装只要执行以下命令就行了:

wget http://people.ee.ethz.ch/~oetiker/webtools/mrtg/pub/mrtg.tar.gz
tar -xzvf mrtg.tar.gz
cd mrtg-版本

./configure –prefix=/usr/local/mrtg
–with-gd=/usr/include
–with-gd-lib=/usr/lib
–with-gd-inc=/usr/include
–with-png=/usr/include
–with-zlib=/usr/include && make && make install

安装完成后,请参照方法一来进行配置。

方法三:自动安装

方法一中的配置是最简单的,也就是,大部分都采用默认设置。所以,能够监测的数据有限。而国外有用户特别针对大部分人的情况设计了一个自动安装程序,程序安装时会自动从MRTG网站下载最新的软件包,自动编译、安装,并配置。程序默认安装在 /var/www/html/mrtg,有需要的话请参考方法一中的 ln -s 进行目录连接。

执行以下命令自动安装MRTG:

wget http://serveio.com/da/install.mrtg.sh
chmod +x install.mrtg.sh
./install.mrtg.sh

该自动安装程序在以下操作系统上测试通过(均采用Direct Admin控制面板):

RedHat 9
Fedora Core 3
Debian 3.0
CentOS 3.4
CentOS 4.0
自动安装程序的作者:Matt Savona

可选步骤:

安装 net-snmp (Simple Network Management Protocol)

yum install net-smnp

安装完以后,配置/etc/snmp/snmpd.conf文件,使其能配合mrtg工作。

去除下面的“#”号
#view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc

将 access notConfigGroup “” any noauth exact systemview none none
改为: access notConfigGroup “” any noauth exact mib2 none none

启动snmpd服务:

/etc/rc.d/init.d/snmpd start

希望这篇文章能帮助你顺利的安装MRTG。:)
----
Noobu.com - 菜鸟的技术站点
[Original] [Print] [Top]
« Previous thread
欢迎各位高手进LINUX交流群:2579018
网络管理技术
7
Next thread »
哪儿有snmp的安装包啊?
     

Copyright © 2007 UNIX Resources Network, All Rights Reserved.      About URN | Privacy & Legal | Help | Contact us
备案序号: 京ICP备05006143    webmaster: webmaster@unixresources.net
This page created on 2008-07-17 02:16:05, cost 0.04560399055481 ms.