2015/09/28

使用 Spine 加速 Cacti 的輪循裝置速度

----
使用 Spine 加速 Cacti 的輪循裝置速度
----
http://www.cacti.net/spine_info.php
Spine, formerly Cactid, is a poller for Cacti that primarily strives to be as fast as possible. For this reason it is written in native C, makes use of POSIX threads, and is linked directly against the net-snmp library for minmumal SNMP polling overhead. Spine is a replacement for the default cmd.php poller so you must decide if using Spine makes sense for your installation.

Spine 是 Cacti 用來加入輪循的程式,使用原生的 C 及支援 POSIX 的 threads 來加入輪循主機的效率。在 Cacti 預設是使用 cmd.php 來當成 poller ,如果你有 poller 時間過長的問題可以考慮使用 spine 來處理。

你可以透過, log 檔來判斷你是否需要 spine
Console -> Utilities -> View Cacti Log File

底下例子是 cmd.php 使用了 190 秒的時間,離上限 300 秒很接近了。
09/28/2015 08:25:12 PM - SYSTEM STATS: Time:190.7159 Method:cmd.php Processes:100 Threads:N/A Hosts:68 HostsPerProcess:1 DataSources:3003 RRDsProcessed:1433
這個案例就有改善的必要。

----
spine 的安裝
----
http://www.cacti.net/spine_install_unix.php
Spine 需要底下這些 lib 如果沒裝的話,可以再補上去。

net-snmp utilities and development libraries
mysql utilities, server and development libraries
openssl development libraries

例如:mysql 的 lib
yum install mysql++-devel -y

spine 沒有現成的 binary 檔案,請自行編譯
----
wget http://www.cacti.net/downloads/spine/cacti-spine-0.8.8f.tar.gz
tar zxvf cacti-spine-0.8.8f.tar.gz 
cd cacti-spine-0.8.8f
./configure 
make
sudo make install

# 找一下 spine 安裝去那了
[root@mail ~]# whereis spine
spine: /usr/local/spine

# 建立 spine 的設定檔,用來直接存取 mysql DB , 請設定和你的 cacti 一樣
[root@mail spine]# cat /usr/local/spine/etc/spine.conf 
DB_Host         localhost
DB_Database     cacti
DB_User         cactiuser
DB_Pass         cactiuser
DB_Port         3306

# spine 的路徑
[root@mail spine]# /usr/local/spine/bin/spine --help
SPINE 0.8.8f  Copyright 2002-2015 by The Cacti Group
Usage: spine [options] [[firstid lastid] || [-H/--hostlist='hostid1,hostid2,...,hostidn']]
... skip ...


----
spine 設定在 cacti 內
----

填入 spine 的程式路徑,讓 cacti 找到它
填入 spine 的程式路徑,讓 cacti 找到它

修改 poller type 為 spine 並設定 porcess 及 threads 的數量
修改 poller type 為 spine 並設定 porcess 及 threads 的數量


觀察 log 看看 poller 時間的變化
觀察 log 看看 poller 時間的變化

以這個案例而言,更換以後效能突飛猛進....差了快 10 倍。
09/28/2015 09:12:16 PM - SYSTEM STATS: Time:15.2687 Method:spine Processes:100 Threads:10 Hosts:68 HostsPerProcess:1 DataSources:3003 RRDsProcessed:1433
09/28/2015 09:07:21 PM - SYSTEM STATS: Time:20.1201 Method:spine Processes:100 Threads:10 Hosts:68 HostsPerProcess:1 DataSources:3003 RRDsProcessed:1433
09/28/2015 09:02:25 PM - SYSTEM STATS: Time:23.3930 Method:spine Processes:100 Threads:10 Hosts:68 HostsPerProcess:1 DataSources:3003 RRDsProcessed:1433
09/28/2015 08:57:17 PM - SYSTEM STATS: Time:15.7469 Method:spine Processes:100 Threads:60 Hosts:68 HostsPerProcess:1 DataSources:3003 RRDsProcessed:1433
09/28/2015 08:52:20 PM - SYSTEM STATS: Time:18.7691 Method:spine Processes:100 Threads:60 Hosts:68 HostsPerProcess:1 DataSources:3003 RRDsProcessed:1433
09/28/2015 08:50:16 PM - SYSTEM STATS: Time:194.3420 Method:cmd.php Processes:100 Threads:N/A Hosts:68 HostsPerProcess:1 DataSources:3003 RRDsProcessed:1877
09/28/2015 08:43:43 PM - SYSTEM STATS: Time:100.7800 Method:cmd.php Processes:100 Threads:N/A Hosts:68 HostsPerProcess:1 DataSources:3003 RRDsProcessed:1433
09/28/2015 08:38:34 PM - SYSTEM STATS: Time:92.6313 Method:cmd.php Processes:100 Threads:N/A Hosts:68 HostsPerProcess:1 DataSources:3003 RRDsProcessed:1433
09/28/2015 08:34:33 PM - SYSTEM STATS: Time:151.5439 Method:cmd.php Processes:100 Threads:N/A Hosts:68 HostsPerProcess:1 DataSources:3003 RRDsProcessed:1433



REF:
http://blog.jangmt.com/2015/09/centos-7-cacti.html  CACTI 安裝 ni Centos 7
張貼留言