一、mrtg和cacti的对比: MRTG的优点:简单、易上手,基本安装完了之后只要更改一下配置文件即可。 缺点: 1、使用文本式的数据库,数据不能重复使用; 2、只能按日、周、月、年来查看数据; 3、只能画两个DS(一条线、一个块); 4、每取一次数据即需要绘图一次,浪费系统资源; 5、无管理功能; rrdtool的优点: 1、使用rrd存储格式,数据能重复使用,比如我可以将一个rrd文件中的数据与另一个rrd文件中的数据相加。 2、可以定义任意时间段画图,即你可以画出一张半年以来的数据的图,也可以画出一张半小时以来的图。 3、能画任意个DS。 4、CDEF让你能任意摆弄数据。 缺点: 1、rrdtool的作用只是存储数据和画图,它没有mrtg中集成的数据采集功能; 2、在命令行的使用非常复杂,参数极多。 3、无管理功能。 简单的说,rrdtool就是一个强大的绘图的引擎。 由于其非常复杂的命令,对用户非常不友好,我一度想自己用php写一套系统。幸运的是,半年前我找到了cacti()。对该工具我只有一个字形容:“great!”。 cacti其实是一套php程序,它运用snmpget采集数据,使用rrdtool绘图。它的界面非常漂亮,能让你根本无需明白rrdtool的参数能轻易的绘出漂亮的图形。更难能可贵的是,它提供了强大的数据管理和用户管理功能,一张图是属于一个host的,每一个host又可以挂载到一个树状的结构上。用户的管理上,作为一个开源软件,它居然做到为指定一个用户能查看的“树”、host、甚至每一张图,还可以与LDAP结合进行用户的验证!我不由得佩服作者考虑的周到!Cacti还提供自己增加模板的功能,让你添加自己的snmp_query和script!可以说,cacti将rrdtool的所有“缺点”都补足了! 这里有2副图帮助理解: 二、cacti的安装步骤: 之前要保证有GCC、Perl、gd、libpng和zlib这些软件包,所以最好在debian下面装。 apt-cache show mrtg Package: mrtg Priority: extra Section: net Installed-Size: 1308 Maintainer: Adam Majer Architecture: i386 Version: 2.14.7-2 Depends: debconf (>= 1.2.0) | debconf-2.0, libsnmp-session-perl (>= 0.97), perl-modules (>= 5.6.0), perl (>= 5.6.0-16), libc6 (>= 2.3.6-6), libgd2-noxpm (>= 2.0.33) | libgd2-xpm (>= 2.0.33), libpng12-0 (>= 1.2.8rel), zlib1g (>= 1:1.2.1)可以看到mrtg的依赖关系有哪些。 1、安装mysql 在网上找源码包 2、安装apache 下载: 安装: ./configure --prefix=/www --enable-so checking for chosen layout... apr checking for gcc... no checking for cc... no checking for cl.exe... no configure: error: no acceptable C compiler found in $PATH See `config.log' for more details.说明在安装前要保证有gcc make && make install make;make install bash: make: command not found bash: make: command not found说明没有装make这个软件包aptitude search makep make - The GNU version of the "make" utility. 建立启动脚本 cp /www/bin/apachectl /etc/init.d/httpd 启动 /www/bin/apachectl start cat /etc/inittab看系统启动项是那个runlevel之后加启动项。 cd /etc/rc3.d ln -s ../init.d/httpd S85httpd ln -s ../init.d/httpd K85httpd 2、安装php 下载:
安装:参考:less INSTALL ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql e LIBXML support... yes checking libxml2 install dir... no checking for xml2-config path... configure: error: xml2-config not found. Please check your libxml2 installation.发现没有装libxml2,所以: [email=liangyin@debian:~/php-5.2.5$]liangyin@debian:~/php-5.2.5$[/email] sudo aptitutde search libxml2 make && make install checking for MSSQL support via FreeTDS... no checking for MySQL support... yes checking for specified location of the MySQL UNIX socket... no checking for MySQL UNIX socket location... /var/run/mysqld/mysqld.sock configure: error: Cannot find MySQL header files under yes. Note that the MySQL client library is not bundled anymore! 发现没有装apt-cache show php5-mysql Package: php5-mysql Priority: optional Section: web Installed-Size: 236 Maintainer: Debian PHP Maintainers Architecture: i386 Source: php5 Version: 5.2.0-8+etch10 Replaces: php5-mysqli Depends: libc6 (>= 2.3.6-6), libmysqlclient15off (>= 5.0.27-1), phpapi-20060613+lfs, php5-common (= 5.2.0-8+etch10) debian:/home/liangyin/php-5.2.5# aptitude search myslq
cp php.ini-dist /www/php/php.ini vi /www/conf/httpd.conf 加入: ###############for php and cacti################### AddType application/x-tar .tgz AddType application/x-httpd-php .php AddType image/x-icon .ico DirectoryIndex index.php index.html index.html.var #######################over######################## 3、 4、设置mysql # mysql -u root -prootroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 10 to server version: 4.0.23-standard Type 'help;' or '\h' for help. Type '\c' to clear the buffer. mysql>; create database cactidb; Query OK, 1 row affected (0.00 sec) mysql>; grant all on cactidb.* to root; Query OK, 0 rows affected (0.01 sec) mysql>; grant all on cactidb.* to root@localhost; Query OK, 0 rows affected (0.01 sec) mysql>; grant all on cactidb.* to cactiuser; Query OK, 0 rows affected (0.00 sec) mysql>; grant all on cactidb.* to cactiuser@localhost; Query OK, 0 rows affected (0.01 sec) mysql>; set password for cactiuser@localhost=password('cactipw'); Query OK, 0 rows affected (0.00 sec) mysql>; exit 5、安装rrdtool 下载: 然后 ./configure make && make install 即可 与mrtg相比,rrdtool自带了gd库,所以不用先安装gd库.(不过由于rrdtool自带的gd库不支持中文,所以rrdtool画出来的图也不能有中文,否则会出现乱码). 注意:rrdtool1.2的版本由于已经不再自带外部的lib库(如cgilib,zlib等),所以需要从下载这些库来安装。建议还是使用1.0的版本,比较方便。 6、安装net-snmp 几乎所有的网络设备和操作系统默认都安装了snmp服务。 unix系统安装的都是net-snmp或ucd-snmp(其实两个都是同一组人写的)。 如果没有安装snmp,可以到net-snmp.sourceforge.org上下载源码编译安装。 我这里说的安装SNMP服务并不是要求安装SNMPD,其实是Cacti需要用到net-snmp中的两个命令――snmpwalk和snmpget进行数据的采集。 我们可以直接在系统中运行snmpwalk和snmpget看是否有该命令,如果有则不用安装了。 7、安装cacti 注意:写该文档时cacti的最高版本时0.8.6c,现在的最高版本是0.8.6f。由于0.8.6f以下的版本有SQL注入漏洞,请大家下载0.8.6f或以上的版本进行安装。 下载: 安装: cp cacti-0.8.6c.tar.gz /www/htdocs tar xzvf cacti-0.8.6c.tar.gz mv cacti-0.8.6c cacti cd cacti 导入表: /usr/local/mysql/bin/mysql –u root –prootroot cactidb 设置配置文件: vi /www/htdocs/cacti/include/config.php $database_type = “mysql”; $database_default = “cactidb”; $database_hostname = “localhost”; $database_username = “cactiuser”; $database_password = “cactipw”; 核对以上几项是否正确 Crontab –u cactiuser –e 为cactiuser用户加入 */5 * * * * /www/php/bin/php /www/htdocs/cacti/poller.php >; /dev/null 2>;&1 (不要使用root用户运行上面的命令,否则要再运行一次chown –R cactiuser rra/ log/) 8、页面设置: 在浏览器上输入: 进入cacti的初始设置页面: 在这里我们要输入一些原始的信息: NEXT -》 输入一些信息,如rrdtool、php、snmpwalk、snmpget的位置,使用ucd-snmp还是net-snmp等 -》 输入原始的用户和密码:admin/admin -》 更改admin用户的密码 -》 点击 Save 安装完成! 现在可以在浏览器中进入Cacti的世界了! | |