Cacti 安装
Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的网络流量监测图形分析工具,可以监控主机的状态及负载情况,Cacti是通过 snmpget来获取数据,使用 RRDtool绘画图形,而且你完全不需要了解RRDtool复杂的参数。
一、安装依赖环境包
yum install net-snmp net-snmp-utils net-snmp-devel httpd-devel mysql-devel mysql-server php php-mysql php-json php-pdo
yum install cairo-devel libxml2-devel pango pango-devel
二、配置Rrdtool、Cacti
1.安装rrdtool
[root@localhost cacti-nagios]# tar zxvf rrdtool-1.4.5.tar.gz
[root@localhost cacti-nagios]# cd rrdtool-1.4.5
[root@localhost rrdtool-1.4.5]# ./configure --prefix=/usr/local/rrdtool
[root@localhost rrdtool-1.4.5]# make && make install
[root@localhost rrdtool-1.4.5]# ln -s /usr/local/rrdtool/bin/* /usr/local/bin/
2.解压 cacti
[root@localhost cacti-nagios]# tar zxvf cacti-0.8.8a.tar.gz
[root@localhost cacti-nagios]# mv cacti-0.8.8a /var/www/html/cacti
3.创建数据库并导入sql
[root@localhost cacti-nagios]# mysql -uroot -ppassword
mysql> create database cacti;
Query OK, 1 row affected (0.00 sec)
mysql> grant all on cacti.* to cacti@'localhost' identified by 'password';
Query OK, 0 rows affected (0.00 sec)
mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)
[root@localhost cacti]# mysql -ucacti -ppassword --database cacti< /var/www/html/cacti/cacti.sql
配置完mysql后,我们需要设置cacti rra、log 目录的权限,这里设置为777 :
chmod -R 777 /var/www/html/cacti/rra/
chmod -R 777 /var/www/html/cacti/log/
4.配置cacti
[root@localhost include]# pwd
/var/www/html/cacti/include
[root@localhost include]# vi global.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "password";
$database_port = "3306";
$database_ssl = false;
[root@localhost include]# vi config.php
$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "password";
$database_port = "3306";
$database_ssl = false;
5,配置抓图任务
[root@localhost include]# crontab -e*/5 * * * * /usr/bin/php /var/www/html/cacti/poller.php
三、Error
通常做到这里,很多人还无法打开http://ip/cacti/install/index.php
为了让大家少走些弯路,我将我遇到的一些错误总结一下
1.打开/etc/php.ini,修改时区并打开错误显示
date.timezone = PRC
display_errors = On
2.如果显示 /var/lib/php/session 没有权限,要给与这个目录cacti用户权限,我后面还会写一篇与nagios集成,所以这些我都设置为nagios用户。
[root@localhost ~]# chown -R nagios:nagios /var/lib/php/session
[root@localhost ~]# chown -R nagios:nagios /var/www/html/cacti
[root@localhost ~]# vi httpd.conf
User nagios
Group nagios
DirectoryIndex index.html index.html.var index.php
AddType application/x-http-php .php
3.空白页面大部分是因为权限,还有好多朋友配置时是因为少安装了php-mysql,导致空白页面,如果找不到favicon.ico,搜索这个文件,拷贝到/var/www/html/目录下
4.关闭selinux,这个有时候会出现问题
[root@localhost ~]# vi /etc/selinux/config
SELINUX=disabled
四、安装Cacti浏览器打开 http://IP/cacti/install/index.php
默认用户名密码为admin/admin,登陆后需要重置
五、配置监控本机 1.设置本机SNMP(红色为修改部分) [root@localhost etc]# vi /etc/snmp/snmpd.conf
com2sec notConfigUser 127.0.0.1 public
access notConfigGroup "" any noauth exact all none none
view all included .1 80
[root@localhost etc]# service snmpd restart
停止 snmpd:[确定]
正在启动 snmpd:[确定]
编辑localhost 模板
console->Devices->localhost ,选择下snmp版本并配置团体名,默认是public,就可以直接监控了
大家有什么问题可以给我留言
本文名称:Cacti监控安装
网页路径:
http://bzwzjz.com/article/jcsodi.html