凌晨思绪万千。
结合之前的那篇博文:https://blog.ich8.com/post/5550
安装Spine支持。这软件为啥要叫Spine啊?看Spine这个词我就讨厌。
需要以下软件支持:
root@Nano-Server:/tmp/cacti-spine-0.8.8f# dpkg -l | grep snmp
ii libnet-snmp-perl 6.0.1-2 all Script SNMP connections
ii libsnmp-base 5.7.2~dfsg-8.1ubuntu5 all SNMP configuration script, MIBs and documentation
ii libsnmp-dev 5.7.2~dfsg-8.1ubuntu5 armhf SNMP (Simple Network Management Protocol) development files
ii libsnmp30:armhf 5.7.2~dfsg-8.1ubuntu5 armhf SNMP (Simple Network Management Protocol) library
ii snmp 5.7.2~dfsg-8.1ubuntu5 armhf SNMP (Simple Network Management Protocol) applications
ii snmp-mibs-downloader 1.1 all Install and manage Management Information Base (MIB) files
ii snmpd 5.7.2~dfsg-8.1ubuntu5 armhf SNMP (Simple Network Management Protocol) agents
编译过程:
sudo apt-get install snmp snmpd rrdtool libsnmp-dev snmp-mibs-downloader libsnmp-base libnet-snmp-perl libsnmp30
cd /tmp
wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8f.tar.gz
tar xvzf cacti-spine-*.tar.gz
cd cacti-spine-*
./configure
make
sudo make install
完成设置:
cp /usr/local/spine/etc/spine.conf.dist /etc/spine.conf #复制spine配置文件到etc目录
ln -s /usr/local/spine/bin/spine /usr/sbin/spine #添加spine软链接到sbin目录,也可不添加,但路径需要设置正确
修改/etc/spine.conf
DB_Host localhost #数据库地址
DB_Database cacti #cacti数据库名
DB_User root #数据库用户名
DB_Pass 123456 #数据库密码
DB_Port 3306 #数据库连接端口
后台设置:
Console -> Cacti Settings 页面的 Paths 选项卡中 Alternate Poller Path 一项,填入 /usr/sbin/spine
Console -> Cacti Settings 页面的 Poller 选项卡中Poller Type 一项,下拉菜单选择 Spine
===FAQ===
测试Spine是否工作正常,正常工作如下:
运行:/usr/local/spine/bin/spine
root@Nano-Server:~# /usr/local/spine/bin/spine
SPINE: Using spine config file [/etc/spine.conf]
SPINE: Version 0.8.8f starting
SPINE: Time: 4.7763 s, Threads: 1, Hosts: 6
如果提示如下错误,提示无法连接上数据库。
root@Nano-Server:~# /usr/local/spine/bin/spine
SPINE: Using spine config file [/etc/spine.conf]
MYSQL: Connection Failed: Error:'2002', Message:'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
MYSQL: Connection Failed: Error:'2002', Message:'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
MYSQL: Connection Failed: Error:'2002', Message:'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
MYSQL: Connection Failed: Error:'2002', Message:'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
MYSQL: Connection Failed: Error:'2002', Message:'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)'
07/22/2015 03:01:51 AM - SPINE: Poller[0] FATAL: Connection Failed, Error:'2002', Message:'Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)' (Spine init)
解决:
查找mysql.sock,建立软链接,开机自动建立
root@Nano-Server:~# find / -name mysql.sock
/tmp/mysql.sock
root@Nano-Server:~# ln -s /tmp/mysql.sock /var/run/mysqld/mysqld.sock
当然,重启后会重置run目录,可以将内容添加到/etc/rc.local中。
提高Spine性能
Console -> Cacti Settings 页面的 Poller 选项卡中 Spine Specific Execution Parameters 下面的 Maximum Threads per Process ,将数值修改大,建议和CPU核心数量一致(有说CPU数量X2的,测试查询所花费的时间都差不多。)
root@Nano-Server:~# /usr/local/spine/bin/spine
SPINE: Using spine config file [/etc/spine.conf]
SPINE: Version 0.8.8f starting
SPINE: Time: 8.5827 s, Threads: 1, Hosts: 6
root@Nano-Server:~# /usr/local/spine/bin/spine
SPINE: Using spine config file [/etc/spine.conf]
SPINE: Version 0.8.8f starting
SPINE: Time: 4.8881 s, Threads: 1, Hosts: 6
root@Nano-Server:~# /usr/local/spine/bin/spine
SPINE: Using spine config file [/etc/spine.conf]
SPINE: Version 0.8.8f starting
SPINE: Time: 1.4303 s, Threads: 4, Hosts: 6
root@Nano-Server:~# /usr/local/spine/bin/spine
SPINE: Using spine config file [/etc/spine.conf]
SPINE: Version 0.8.8f starting
SPINE: Time: 1.5332 s, Threads: 4, Hosts: 6
root@Nano-Server:~# /usr/local/spine/bin/spine
SPINE: Using spine config file [/etc/spine.conf]
SPINE: Version 0.8.8f starting
SPINE: Time: 1.6066 s, Threads: 8, Hosts: 6
root@Nano-Server:~# /usr/local/spine/bin/spine
SPINE: Using spine config file [/etc/spine.conf]
SPINE: Version 0.8.8f starting
SPINE: Time: 1.5591 s, Threads: 8, Hosts: 6
root@Nano-Server:~# /usr/local/spine/bin/spine
SPINE: Using spine config file [/etc/spine.conf]
SPINE: Version 0.8.8f starting
SPINE: Time: 3.0854 s, Threads: 8, Hosts: 6
[分享]Ubuntu Server 15.04 编译Spine:等您坐沙发呢!