以版本三为例,因为版本四有太多的改动
wget http://collectd.org/files/collectd-3.11.7.tar.gz
cd /root/collectd-3.11.7
./configure --prefix=/opt/collectd --with-rrdtool=/usr/local/rrdtool/ && make && make install
此段非转载--------------------------------------------------------
我自己机器上
sudo apt install librrd-dev
./configure --enable-rrdtool --with-librrd=/usr/include
-----------------------------------------------------------------------------------
上面是安装server端,因为server端要用到rrdtool来写数据
./configure --prefix=/usr/local/collectd --without-rrdtool && make && make install
这句是安装client端,因为没必要用到rrdtool,所以加了一句--without-rrdtool
然后就是修改配置文件
client
vi /usr/local/collectd/etc/collectd.conf
Mode Client
Server 192.168.1.107 1800
LoadPlugin load
LoadPlugin memory
LoadPlugin processes
LoadPlugin swap
LoadPlugin traffic
server
vi /opt/collectd/etc/collectd.conf
Mode Server
Listen 192.168.1.107 1800
LoadPlugin load
LoadPlugin memory
LoadPlugin processes
LoadPlugin swap
LoadPlugin traffic
Process java
Process httpd
两端配置完成后,就可以起服务了
server
/opt/collectd/sbin/collectd
client
/usr/local/collectd/sbin/collectd
当然你也可以用-C 来指定配置文件,比如这样/usr/local/collectd/sbin/collectd -C /root/collectd_server.conf
可以看一下help就知
[root@work_monitor 192.168.1.107]# /usr/local/collectd/sbin/collectd --help
/usr/local/collectd/sbin/collectd: invalid option -- -
Usage: collectd [OPTIONS]
Available options:
General:
-C Configuration file.
Default: /usr/local/collectd/etc/collectd.conf
-P PID-file.
Default: /usr/local/collectd/var/run/collectd.pid
-f Don't fork to the background.
Builtin defaults:
Config-File /usr/local/collectd/etc/collectd.conf
PID-File /usr/local/collectd/var/run/collectd.pid
Data-Directory /usr/local/collectd/var/lib/collectd
Step 10 seconds
Heartbeat 25 seconds
collectd 3.11.7, http://collectd.org/
by Florian octo Forster <octo@verplant.org>
for contributions see `AUTHORS'
两边服务起了之后,就可以在server端生成你所需要的rrd文件了,路径在
/opt/collectd/var/lib/collectd下面
一个机器一个文件夹
所生成的rrd文件就可以导入cacti中,cacti就可以出图了
查看rrd数据有无数据
/usr/local/rrdtool/bin/rrdtool fetch /opt/collectd/var/lib/collectd/192.168.1.107/load.rrd AVERAGE -r 900 -s e-30min