安装完cacti之后一直使用默认的cmd.php来完成数据采集,可是后来发现cmd.php采集存在很大的延迟平均一次需要2秒,执行效率太低了,而spine只用了0.7秒,差距实在太大了。两厢比较了一下,从添加device好到设备up,spine只需要不到一分钟,而cmd等的时间较长,超过10分钟。 当设备down后 2分钟之内spine可以发出alert,而cmd可能需要10分钟以上。 所以还是要使用spine吧。spine安装很简单,编译三部曲,推荐编译的时候加上相关参数会更好。
- net-snmp-devel
- mysql
- mysql-devel
- openssl-devel
1.相关包先打上
1
2
| [iyunv@localhost ~]# yum -y
install net-snmp-devel openssl-devel mysql mysql-devel
|
2、安装spine,下载的版本最好与cacti一致,spine-0.8.8b
1
2
3
4
5
6
7
| [iyunv@localhost ~]# tar xf
cacti-spine-0.8.8b.tar.gz
[iyunv@localhost ~]# cd cacti-spine-0.8.8b
[iyunv@localhost
cacti-spine-0.8.8b]# ./configure
[iyunv@localhost cacti-spine-0.8.8b]# make &&
make install
|
编译时可能产生的报错如下: 1
2
| configure: error: Cannot find SNMP headers. Use --with-snmp= to
specify non-default path.
|
解决方法: 1
| yum install net-snmp-devel
|
或者启用with-snmp=/usr/local/net-snmp/ 参数,若RMP安装的net-snmp可能找不到net-snmp则可以重新编译安装net-snmp,加上参数 1
| --prefix=/usr/local/net-snmp/
|
3.设置配置文件
1
2
3
4
5
6
7
8
9
10
| [iyunv@localhost ~]# cp /usr/local/spine/etc/spine.conf.dist /etc/spine.conf
## 编辑配置文件,请根据实际情况修改
[iyunv@localhost ~]# vi /etc/spine.conf
DB_Host
localhost
DB_Database cacti
DB_User cactiuser
DB_Pass cactiuser
DB_Port 3306
DB_PreG 0
|
4启动测试spine
1
| [iyunv@localhost ~]# /usr/local/spine/bin/spine -C /usr/local/spine/etc/spine.conf
|
启动时产生的报错如下: 1
2
3
4
5
| MYSQL: Connection Failed: Can't connect to local MySQL server
through socket '/var/lib/mysql/mysql.sock' (2)
11/02/2007 04:02:51 PM - SPINE: Poller[0] FATAL: Connection Failed:
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock'
(2) (Spine init)
|
解决方法: 可以重新编译spine 加上--with-mysql=/usr/local/mysql/参数 或者查找mysql.sock 是否丢失,如否则在/var/lib/ 下建立mysql文件夹 , 1
| [iyunv@monitor mysql]# ln -s /tmp/mysql.sock /var/lib/mysql/mysql.sock
|
用ln和tmp目录下的连接起来。tmp下的mysql.sock 是安装mysql的时候产生的,而/var/lib/mysql/mysql.sock ln产生的。
5、在cacti的WEB页面进行设置spine的路径 /usr/local/spine/bin/spine,修改Cacti默认的Poller Types Console -> CactiSettings -> Poller -> Poller Type在下拉框中,选择spine, 然后记得“Save
|