由于效率的原因,在需要大量采集数据时,如果使用自带的cmd.php轮询器会比较慢,1分钟1次的采集频率可能无法完成轮询所有的被监控的机器,从而可能导致部分监控项目不出图或图形断断续续。为了解决效率问题,Cacti官方也推出spine,采用多线程的方式高效的轮询。
1、解决依赖关系
## 依赖于mysql mysql-devel net-snmp-devel openssl-devel
## 我们在安装cacti的时候已经安装 mysql mysql-devel 所以,这里只需安装另外2个
# yum -y install net-snmp-devel openssl-devel
2、安装spine,下载的版本最好与cacti一致,spine-0.8.8b
# tar xf cacti-spine-0.8.8b.tar.gz
# cd cacti-spine-0.8.8b
# ./configure
# make && make install
3、提供配置文件
# cp /usr/local/spine/etc/spine.conf.dist /etc/spine.conf
## 编辑配置文件,请根据实际情况修改
# vi /etc/spine.conf
DB_Host localhost
DB_Database cactidb
DB_User cactiuser
DB_Pass cactiuser
DB_Port 3306
DB_PreG 0
# 这里的配置是怎么来的呢? 还记得吧, 就是 cacti/include/config.php
/* make sure these values refect your actual database/host/user/password */
$database_type = "mysql";
$database_default = "cactidb";
$database_hostname = "localhost";
$database_username = "cactiuser";
$database_password = "cactiuser";
$database_port = "3306";
$database_ssl = false;
4、测试
# /usr/local/spine/bin/spine
SPINE: Using spine config file [/etc/spine.conf]
SPINE: Version 0.8.8b starting
SPINE: Time: 0.1707 s, Threads: 5, Hosts: 2
5、设置spine的路径
Console -> Configureation -> Settings -> Alternate Poller Path -> Spine Poller File Path
输入spine的路径:默认安装在/usr/local/spine/bin/spine
6、修改cacti默认的Poller Types
Console -> Cacti Settings -> Poller -> Poller Type
在下拉框中,选择spine, 然后记得“Save”
注意:Spine不必为其添加计划任务,Cacti well spawn Spine every 5 minutes instead of cmd.php
而poller.php需要定义计划任务去执行,然后poller.php再去调度数据收集方法。