下载catcti中文版和rrdtool软件。
rrdtool-1.4.4.tar.gz cacti-0.8.7b-cn-utf8.tar.gz
一,配置监控服务端(10.70.38.161)
配置Cacti监控服务端需要AMP(Apache,Mysql,PHP)平台的支持,另外需要安装gd、zlib等软件(RHEL5.5)
<!--[if !supportLists]-->1. <!--[endif]-->分别安装的构建APM平台的需要的RPM软件包。
httpd-2.2.3-31.el5 mysql-5.0.77-3.el5、
mysql-connector-odbc-3.51.26r1127-1.el5、
mysql-server-5.0.77-3.el5
php-common-5.1.6-23.2.el5_3、
php-pdo-5.1.6-23.2.el5_3、
php-5.1.6-23.2.el5_3
php-mysql-5.1.6-23.2.el5_3
2.安装net-snmp-utils软件包
lm_sensors、net-snmp、net-snmp-utils
3.安装rrdtool软件包
[root@hrmsustt ~]# tar -zxvf rrdtool-1.4.4.tar.gz
[root@hrmsustt ~]# cd rrdtool-1.4.4
[root@hrmsustt rrdtool-1.4.4]# ./configure --prefix=/usr/local
[root@hrmsustt rrdtool-1.4.4]# make
[root@hrmsustt rrdtool-1.4.4]# make install
4.安装配置Cacti服务器套件cacti-0.8.7b-cn-utf8.tar.gz(中文包)
1>安装Cacti软件包,解压到Web服务器网页目录,同时添加用于读写监测数据库用户cacti。
[root@hrmsustt ~]# mv cacti-0.8.7b-cn-utf8.tar.gz /var/www/html/
[root@hrmsustt ~]# cd /var/www/html/
[root@hrmsustt html]# ls
cacti-0.8.7b-cn-utf8.tar.gz
[root@hrmsustt html]# tar -xvf cacti-0.8.7b-cn-utf8.tar.gz -C /var/www/html
[root@hrmsustt html]# mv cacti-0.8.7b-cn-utf8 cacti
[root@hrmsustt html]# useradd cacti
[root@hrmsustt html]# chown -R cacti.cacti cacti/
[root@hrmsustt html]# chown -R 755 cacti/
2>设置监测数据库:建立保存监测数据的数据库,表,设置好授权访问数据库的用户和密码。
[root@hrmsustt php]# service mysqld restart;
[root@hrmsustt php]# mysql -u root
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2 to server version: 5.0.22
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> create database cactidb default character set utf8;
Query OK, 1 row affected (0.02 sec)
mysql> grant all on cactidb.* to cacti@localhost identified by 'pwd@123';
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> grant all on cactidb.* to cacti@127.0.0.1 identified by 'pwd@123';
Query OK, 0 rows affected (0.00 sec)
mysql>
mysql> grant all on cactidb.* to cacti@10.70.38.161 identified by 'pwd@123';
Query OK, 0 rows affected (0.00 sec)
mysql> quit
导入数据表
[root@hrmsustt cacti]# mysql -u cacti -p cactidb < cacti.sql
Enter password:
3>修改Cacti配置文件:
[root@hrmsustt cacti]# vi include/config.php
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "pwd@123";
$database_port = "3306";
$config['url_path'] = "/";
4.>修改http.conf配置文件,使其支持php网页,并将utf-8作为默认的中文页面字符集:
[root@hrmsustt cacti]# vi /etc/httpd/conf/httpd.conf
DocumentRoot "/var/www/html/cacti"
DocumentRoot "/var/www/html/cacti" //设置网站文件根目录
//设置目录权限
Options None
AllowOverride None
Order allow,deny
Allow from all
DirectoryIndex index.php index.html //设置默认的索引页
AddDefaultCharset UTF-8 //设置网页默认的字符集
修改apache为非80端口8080
vi /etc/httpd/conf/httpd.conf
#Listen 12.34.56.78:80
#Listen 80
Listen 8080
[root@hrmsustt webmin-1.510]# service httpd restart;
Stopping httpd: [FAILED]
Starting httpd:
二.配置被监测的Linux服务器(10.70.38.51):
1.安装net-snmp软件包:lm_sensors-2.10.0-3.1,net-snmp-5.3.1-24.el5
[root@hrmsuw01 ~]# rpm -qa|grep lm_se*
lm_sensors-2.10.0-3.1
[root@hrmsuw01 ~]# rpm -qa|grep net-snmp*
net-snmp-5.3.1-24.el5
net-snmp-libs-5.3.1-24.el5
<!--[if !supportLists]-->2. <!--[endif]-->修改snmp服务配置文件及启动服务:
[root@hrmsuw01 ~]# vi /etc/snmp/snmpd.conf
com2sec notConfigUser 10.70.38.161 public
access notConfigGroup "" any noauth exact all none none
view all included .1 80
[root@hrmsuw01 snmp]# service snmpd restart
Stopping snmpd: [FAILED]
Starting snmpd: [ OK ]
[root@hrmsuw01 snmp]# chkconfig --level 35 snmpd on
[root@hrmsuw01 snmp]# chkconfig --list snmpd
snmpd 0:off 1:off 2:off 3:on 4:off 5:on 6:off
[root@hrmsuw01 snmp]#
三.初始化Cacti系统:
在客户端Web浏览器访问Cacti服务器(10.70.38.161),第一次访问cacti界面,页面将跳转至Cacti的初始化安装向导界面:
<!--[if !vml]--><!--[endif]-->
<!--[if !vml]--><!--[endif]-->
四.使用Cacti监控系统:
1.登陆管理平台,完成Cacti初始化安装之后,直接进入web登录界面,如下图所示,输入默认的管理员用户名和密码(admin/admin):
<!--[if !vml]--><!--[endif]-->
2首次登录强制要求更改密码,更改完成之后保存就可以进入管理界面了:admin/password
<!--[if !supportLists]-->3. <!--[endif]-->设置PRDtool工具的版本和字体的路径:在Cacti的控制台界面中,点击左侧栏的“设置”,打开Cacti的系统设置界面,确认“常规”标签中的”PRDtool应用程序版本“设置为PRDtool1.2.x”。
<!--[if !vml]--><!--[endif]-->
找到“路径”选项卡中的“PRDtool默认字体路径”,将字体路径设置为
/usr/share/fonts/zh_TW/TrueType/bsmi00lp.ttf
<!--[if !vml]--><!--[endif]-->
<!--[if !supportLists]-->4. <!--[endif]-->添加被监测的设备或者主机:(本例中添加一台Linux服务器)
连接主机,在Cacti控制台中,点击左侧栏“管理”下的“设备”,然后点击上方的“添加”按钮,进入添加新设备的页面:
本实验添加的设备为“Linux”,设置IP地址为“10.70.38.161”,设备模板选择“ucd/net SNMP设备”,“SNMP版本”选择“版本1”,然后点击“创建”完成添加并进行初次连接:
<!--[if !vml]--><!--[endif]-->
指定监控项目:成功连接被监测的主机(10.70.38.51)后,可以看到“保存成功”的提示信息,可以在页面的下方看到默认监控项目,另外可以根据实际需要自行添加需要图像模板和数据查询名称:
<!--[if !vml]--><!--[endif]-->
然后保存设置。
5.
<!--[if !vml]--><!--[endif]-->
<!--[if !supportLists]-->5. <!--[endif]-->生成监控图像:
创建图像,点击Cacti控制台左侧栏的“新建图像”,进入图像创建页面,“设备”下拉菜单处指定需要绘制的图像主机,勾选需要创建图像的监控项目上,最后点击页面右下方的“创建”,在出现的页面中再次单击“创建”按钮即可完成:
<!--[if !vml]--><!--[endif]-->
<!--[if !supportLists]-->6. <!--[endif]-->添加图像至监控树:
单击Cacti控制台左侧栏“管理”下的“图像树”,在右侧点击“默认”,可以对默认的监控树进行管理,点击右侧的“添加”,可以为默认的监控树添加“树枝”节点项目,有“设备”,“图像”,“标头”三类,本实验添加“设备”节点,最后点击“创建”:
<!--[if !vml]--><!--[endif]-->
<!--[if !supportLists]-->7. <!--[endif]-->在Cacti监控服务端执行首次初始化并添加计划任务,定期采集监控数据:
执行首次初始化必须使用cacti用户,出现以下数据,表示初始化成功,可以查看到监控图像,如果没有以下数据,将不会看到正常的监控图像。
[root@hrmsustt home]# su – cacti
[root@hrmsustt home]#php /var/www/html/cacti/poller.php
08/05/2013 09:38:46 PM - SYSTEM STATS: Time:1.1748 Method:cmd.php Processes:1 Threads:N/A Hosts:3 HostsPerProcess:3 DataSources:19 RRDsProcessed:19
OK u:0.00 s:0.00 r:0.89
OK u:0.00 s:0.00 r:0.89
OK u:0.00 s:0.00 r:0.89
OK u:0.00 s:0.00 r:0.89
OK u:0.00 s:0.00 r:0.89
OK u:0.00 s:0.00 r:0.89
OK u:0.00 s:0.00 r:0.89
OK u:0.00 s:0.00 r:0.89
OK u:0.00 s:0.00 r:0.89
OK u:0.00 s:0.00 r:0.89
OK u:0.00 s:0.00 r:0.89
OK u:0.00 s:0.00 r:0.89
OK u:0.00 s:0.00 r:0.89
OK u:0.00 s:0.00 r:0.89
OK u:0.00 s:0.00 r:0.89
OK u:0.00 s:0.00 r:0.89
OK u:0.00 s:0.00 r:0.89
OK u:0.01 s:0.00 r:0.89
OK u:0.01 s:0.00 r:0.89
OK u:0.01 s:0.00 r:0.89
OK u:0.01 s:0.00 r:0.89
OK u:0.01 s:0.01 r:0.89
OK u:0.01 s:0.01 r:0.89
OK u:0.01 s:0.01 r:0.89
OK u:0.01 s:0.01 r:0.89
OK u:0.01 s:0.01 r:0.89
OK u:0.01 s:0.01 r:0.89
OK u:0.01 s:0.01 r:0.89
OK u:0.01 s:0.01 r:0.89
添加计划任务
[cacti@hrmsustt ~]$ crontab -e
0-59/5 * * * * php /var/www/html/cacti/poller.php > /dev/null 2>&1 ;
[root@hrmsustt home]# service crond restart
Stopping crond: [ OK ]
Starting crond: [ OK ]
[root@hrmsustt home]# chkconfig --level 35 crond on
[root@hrmsustt home]#
<!--[if !supportLists]-->8. <!--[endif]-->查看监控侧结果:(监控图像界面)
点击Cacti控制台上方的“查看图像”标签,然后展开左侧栏的“默认”监控树,点击需要查看的设备(“HRMS DEV服务器”),查看到监控项目的图示列表信息。
到此,Cacti配置完成。可以添加一些Cacti支持的插件。获取一些扩展的服务。
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/23757700/viewspace-767829/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/23757700/viewspace-767829/