$ wget https://github.com/collectd/collectd/archive/collectd-5.4.1.tar.gz
$ tar zxf collectd-5.4.1.tar.gz
下載 Collectd AREAWELL AW-2111A plugin
$ git clone https://github.com/a0726h77/cloudPower-collectd-plugin.git
將 AW-2111A plugin 複製到 Collectd 原始碼資料夾
$ cp -r cloudPower-collectd-plugin/* collectd-collectd-5.4.1/src/
修改編譯設定,加入 plugin
$ cd collectd-collectd-5.4.1/
$ vi configure.ac
....$ vi src/Makefile.am
AC_PLUGIN([cloudpower], [yes], [cloudpower statistics])
....
....$ vi src/types.db
if BUILD_PLUGIN_CLOUDPOWER
pkglib_LTLIBRARIES += cloudpower.la
cloudpower_la_SOURCES = cloudpower.c
cloudpower_la_LDFLAGS = -module -avoid-version
cloudpower_la_LIBADD = -L. -lcloudPowerManagerTool
collectd_LDADD += "-dlopen" cloudpower.la
collectd_DEPENDENCIES += cloudpower.la
endif
....
....
electric value:GAUGE:U:U
....
* Makefile.am 裏需指定模組對 libcloudPowerManagerTool.a 使用靜態連結
安裝相依套件
# apt-get install build-essential automake bison flex autoconf pkg-config libtool libgcrypt20-dev libltdl-dev libglib2.0-dev lib32z1-dev gcc-4.9-multilib
編譯 & 安裝
$ ./build.sh
$ ./configure CFLAGS="-m32" --prefix=/opt/collectd
CFLAGS="-m32" 編譯 collectd 成 32 位元執行檔,因爲官方給的$ make
--prefix 指定安裝路徑
libcloudPowerManagerTool.a 只有 32 位元版本
# make all install
載入模組
# vi /opt/etc/collectd.conf
....
LoadPlugin cloudpower
....
<
Plugin cloudpower>
<
Node "1F">
Host "192.168.x.x"
<
/Node>
<
/Plugin>
....
執行
# /opt/collectd-5.4.1/sbin/collectd -C /opt/collectd-5.4.1/etc/collectd.conf -f
References :
First steps - collectd Wiki
Plugin architecture - collectd Wiki
AREAWELL NETWORKS
沒有留言:
張貼留言