Step 3:安装rrdtool、cacti
1、 rrdtool安装前请安装以下包
A.安装libart
wget http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/pub/libs/libart_lgpl-<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>2.3.17.tar.gz
tar zxvf libart_lgpl-<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>2.3.17.tar.gz
cd libart_lgp-<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>2.3.17
./configure
make
make install
B.安装 libcgi
wget http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/pub/libs/cgilib-0.5.tar.gz
tar zxvf cgilib-0.5.tar.gz
cd cgilib-0.5
make
cp libcgi.a /usr/local/lib
cp cgi.h /usr/include
C.安装 libpng
wget http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/pub/libs/libpng-<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>1.2.8-config.tar.gz
tar zxvf libpng-<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>1.2.8-config.tar.gz
cd libpng-<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>1.2.8-config/
./configure
make
make install
D.安装freetype
wget http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/pub/libs/freetype-<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>2.1.9.tar.gz
tar zxvf freetype-<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>2.1.9.tar.gz
cd freetype-<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>2.1.9
./configure
make
make install
cd /usr/include
ln -sf /usr/local/include
2、安装 rrdtool
wget http://people.ee.ethz.ch/~oetiker/webtools/rrdtool/pub/rrdtool-<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>1.2.11.tar.gz
tar zxvf rrdtool-<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>1.2.11.tar.gz
cd rrdtool-<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>1.2.11
./configure --prefix=/usr/local/rrdtool-1.2.11 \
--disable-tcl \
--disable-python
make
make install
3、 安装net-snmp、snmpwalk和snmpget
SNMP安装和配置
(1).windows server <rtx w:st="on"></rtx>2003
打开控制面板——添加或删除程序——添加或删除windows组件,选择“管理和监视工具”中的“简单网络管理协议(SNMP)”,点确定,点下一步进行安装,安装完之后要打开控制面板——管理工具——服务,打开SNMP Service的属性,在安全选项卡里的“接受团体名称”中添加一个权限为只读的irunnet团体,然后选择“接受来自任何主机的SNMP数据包”点确定,重新启动SNMP Service服务
(2).windows 2000
打开控制面板——添加或删除程序——添加或删除windows组件,选择“管理和监视工具”中的“简单网络管理协议”,点确定,点下一步进行安装,安装完之后要打开控制面板——管理工具——服务,打开SNMP Service的属性,在安全选项卡里的“接受团体名称”中把public改成irunnet,重新启动SNMP Service服务
(3).redhat
如果系统安装的时候没有安装可以先装一个apt,然后用apt-get install net-snmp来安装
修改配置文件
vi /etc/snmp/snmpd.conf
修改如下两行
com2sec notConfigUser default irunnet
access notConfigGroup "" any noauth exact mib2 none none
去掉下面几行前面的“#”
com2sec local localhost COMMUNITY
com2sec mynetwork NETWORK/24 COMMUNITY
group MyRWGroup any local
group MyROGroup any mynetwork
view all included .1 80
view mib2 included .iso.org.dod.internet.mgmt.mib-2 fc
access MyROGroup "" any noauth 0 all none none
access MyRWGroup "" any noauth 0 all all all
开启:
setup
在system service选中snmp
(4).freebsd
Vi /usr/local/share/snmp/snmpd.conf添加如下一行
rocommunity irunnet
4、 安装、配置cacti
(1). 解压
cd /usr/local/apps/www/
wget http://www.cacti.net/downloads/cacti-<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>0.8.6g.tar.gz
tar zxvf cacti-<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>0.8.6g.tar.gz
mv cacti-<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>0.8.6g cacti
cd cacti
(2).打补丁
wget http://www.cacti.net/downloads/patches/<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>0.8.6g/short_open_tag_parse_error.patch
wget http://www.cacti.net/downloads/patches/<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>0.8.6g/graph_properties_zoom.patch
wget http://www.cacti.net/downloads/patches/<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>0.8.6g/script_server_snmp_auth.patch
wget http://www.cacti.net/downloads/patches/<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>0.8.6g/mib_file_loading.patch
patch -p1 -N < short_open_tag_parse_error.patch
patch -p1 -N < graph_properties_zoom.patch
patch -p1 -N < script_server_snmp_auth.patch
patch -p1 -N < mib_file_loading.patch
(3)建cacti库
[root@irunnet cacti]#mysqladmin --user=root create cacti
(4)导入cacti.sql
[root@irunnet cacti]#mysql cacti < cacti.sql
(5)对cacti库授权
[root@irunnet cacti]# mysql --user=root mysql
mysql> GRANT ALL ON cacti.* TO cacti@localhost IDENTIFIED BY 'cacti';
mysql> flush privileges;
(6)修改cacti配置文件、连接MYSQL
编辑cacti/include/config.php
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "cacti";
(7)对cacti中rra,log文件夹权限稍加修改
[root@irunnet cacti]# chown -R cacti rra/ log/[请事先在OS中添加cacti用户]
(8) 定时运行cacti采集数据
/etc/crontab -e
添加一行:
*/5 * * * * /usr/local/php/bin/php /usr/local/apps/www/cacti/poller.php >/dev/null 2>&1
(9) 测试
[root@irunnet cacti]cd include
[root@localhost include]# /usr/local/php/bin/php /usr/local/data/www/cacti/poller.php
OK u:0.00 s:0.01 r:2.03
OK u:0.00 s:0.01 r:2.04
OK u:0.00 s:0.01 r:2.04
OK u:0.00 s:0.01 r:2.04
OK u:0.00 s:0.01 r:2.04
OK u:0.00 s:0.01 r:3.06
OK u:0.00 s:0.01 r:3.06
OK u:0.00 s:0.01 r:3.06
OK u:0.01 s:0.01 r:4.08
OK u:0.01 s:0.01 r:4.08
OK u:0.01 s:0.01 r:4.08
OK u:0.01 s:0.01 r:4.09
OK u:0.01 s:0.01 r:5.10
OK u:0.01 s:0.01 r:5.10
OK u:0.01 s:0.01 r:5.11
OK u:0.01 s:0.01 r:5.11
OK u:0.01 s:0.01 r:5.11
OK u:0.01 s:0.01 r:6.15
OK u:0.01 s:0.01 r:6.15
OK u:0.01 s:0.01 r:6.15
OK u:0.01 s:0.01 r:7.16
12/08/<rtx w:st="on"></rtx>2005 12:24:02 AM - SYSTEM STATS: Time:7.2343 Method:cmd.php Processes:1 Threads:N/A Hosts:3 HostsPerProcess:3 DataSources:27 RRDsProcessed:21
说明正常,已经开始采集数据
当测试时候出现如下错误时候
PHP Warning: mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /usr/local/apps/www/cacti/lib/adodb/drivers/adodb-mysql.inc.php on line 340
…………………………………………………………………………..
等主要是和mysql连接出现故障,将mysql.sock连接到/var/lib/mysql/mysql.sock即可 [注意写全路径,mysql默认安装sock在/tmp下]
ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
(10)监控页面初始配置
http://www.irunnet.com/******/cacti
初始安装next----new install—配置路径[请修改:RRDTool Binary Path:/usr/local/rrdtool-<chsdate year="1899" month="12" day="30" islunardate="False" isrocdate="False" w:st="on"></chsdate>1.2.11/bin/rrdtool,其他的默认路径都应该OK]—登陆[默认用户名密码都是admin]
进去之后请更改settings选项中的几个参数
RRDTool Utility Version默认是RRDTool 1.0.x请改为RRDTool 1.2.x
SNMP Version默认是Version 1请改为Version 2
SNMP Community 请设置为你自己想要的如irunnet
(11)如何进行监控,参考http://www.cacti.net/downloads/docs/html/basics.html
Step 4:添加启动脚本
echo "cd /usr/local/apache2/bin;./apachectl start">>/etc/rc.local
echo "cd /usr/local/mysql/bin;./mysqld_safe & ">>/etc/rc.local