Cacti是一套基于PHP,MySQL,SNMP及RRDTool开发的服务器监测图形分析工具。
一,添加epel源
通过添加epel源,我们可以通过yum来安装cacti,这样我们可以省去不少编译的时间,自动解决包依赖关系。
如果添加epel源,请参考 centos 6推荐使用epel源,个人觉得这个源里面的东西很全。
二,安装cacti
- yum install cacti net-snmp*
cacti安装的时候,如果你机子,没有mysql,php,apache或者nginx的话,自动会安装上的
- Installing:
- cacti noarch 0.8.7g-1.el6 epel 2.0 M
- Installing for dependencies:
- dejavu-lgc-sans-mono-fonts noarch 2.30-2.el6 base 393 k
- dejavu-sans-mono-fonts noarch 2.30-2.el6 base 450 k
- mysql x86_64 5.1.52-1.el6_0.1 updates 889 k
- php x86_64 5.3.2-6.el6_0.1 updates 1.1 M
- php-cli x86_64 5.3.2-6.el6_0.1 updates 2.2 M
- php-common x86_64 5.3.2-6.el6_0.1 updates 516 k
- php-mysql x86_64 5.3.2-6.el6_0.1 updates 75 k
- php-pdo x86_64 5.3.2-6.el6_0.1 updates 72 k
- php-snmp x86_64 5.3.2-6.el6_0.1 updates 28 k
- rrdtool x86_64 1.3.8-6.el6 base 293 k
这台机子上面,我装了apache,所以web服务器就不同有装了。管理软件包安装省事,手动编译,因为有版本问题,依赖关系很让人头痛。
二,配置cacti
1,创建cacti数据库,用户
- //启动mysql服务器
- /etc/init.d/mysqld start
- //root账户,添加数据库
- mysql> show databases;
- mysql> create database cacti;
- mysql> grant all ON cacti.* TO 'cacti'@'127.0.0.1' identified by '111111';
- mysql> flush privileges;
2,导入cacti数据库
- //查找一下cacti.sql文件位置
- [root@localhost cacti]# locate cacti.sql
- /usr/share/doc/cacti-0.8.7g/cacti.sql
- //导入数据库
- mysql -ucacti -p -h 127.0.0.1 cacti < /usr/share/doc/cacti-0.8.7g/cacti.sql
3,修改cacti的config.php
- vim /usr/share/cacti/include/config.php
- $database_type = "mysql";
- $database_default = "cacti";
- $database_hostname = "127.0.0.1";
- $database_username = "cacti";
- $database_password = "111111";
4,修改snmp的配置文件
- vim /etc/snmp/snmp.conf
- com2secnotConfigUser default public
- 改为:
- com2secnotConfigUser 127.0.0.1 public
- access notConfigGroup "" any noauth exact systemview none none
- 改为:
- accessnotConfigGroup "" any noauth exact all none none
- #view all included .1 80
- 将前面的 # 注释去掉,改为
- view all included .1 80
5,采集数据
- crontab -e
- */5 * * * * /usr/bin/php /usr/share/cacti/poller.php > /dev/null 2>&1
6,配置web环境
apache设置一下documentroot,nginx设置一下root,指定到/usr/share/cacti下面就行了
三,启动相关程序
- [root@localhost include]# /etc/init.d/httpd start
- [root@localhost include]# /etc/init.d/snmpd start
四,进入web界面安装
进入web页面以后,一直下一步就行,管理员的原始用户名,密码是admin,admin
到这儿cacti就装好了。不过只监控了一台机子,如果想要监控其他机器呢。要怎么做呢。也就是说
cacti装在192.168.1.2,我又想监控192.168.1.3这台机器,怎么办呢,看下面
1,在192.168.1.3客户机上面安装net-snmp
yum install net-snmp*
2,配置192.168.1.3客户机的snmp
- com2sec notConfigUser 192.168.1.2 public
添加一行到com2sec相对应的部分,将ip指定到cacti所在服务器。
- [root@localhost include]# /etc/init.d/snmpd start
3,在192.168.1.2上面添加多服务器
a,添加服务器
Console -> Create New Graphs 右上方有一个 create new host
或者直接输入url,如下
http://192.168.1.2/graphs_new.php
b,为新增服务器,创建图表
Console -> Devices -> (Edit) 右上方有一个 Create Graphs for this Host
或者直接输入url,如下
http://192.168.1.132/graphs_new.php?host_id=2
c,将新增加的服务器,添加到graph tree
Console -> Graph Trees -> (Edit) -> Graph Tree Items
这样的话,我们就可以在graph中看到我添加的服务器了。看下图
cacti
来源: http://blog.51yip.com/server/1350.html