@@ -8,32 +8,58 @@ collectd 是一个守护(daemon)进程,用来收集系统性能和提供各种
88
99## collectd的安装
1010
11- ### 解决依赖
11+ ### 软件仓库安装(推荐)
12+ collectd官方有一个* 隐藏* 的软件仓库: https://pkg.ci.collectd.org,构建有`RHEL/CentOS` (rpm),` Debian/Ubuntu ` (deb)的软件包,如果你使用的操作系统属于上述,那么推荐使用软件仓库安装。
1213
14+ 目前collectd官方维护3个版本: ` 5.4 ` , ` 5.5 ` , ` 5.6 ` 。根据需要选择合适的版本。
15+
16+ Debian/Ubuntu仓库安装(示例中使用` 5.5 ` 版本):
17+ ``` bash
18+ echo " deb http://pkg.ci.collectd.org/deb $( lsb_release -sc) collectd-5.5" | sudo tee /etc/apt/sources.list.d/collectd.list
19+ curl -s https://pkg.ci.collectd.org/pubkey.asc | sudo apt-key add -
20+ sudo apt-get update && sudo apt-get install -y collectd
1321```
14- rpm -ivh "http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm"
15- yum -y install libcurl libcurl-devel rrdtool rrdtool-devel perl-rrdtool rrdtool-prel libgcrypt-devel gcc make gcc-c++ liboping liboping-devel perl-CPAN net-snmp net-snmp-devel
22+
23+ > ** NOTE** : Debian/Ubuntu软件仓库自带有` collectd ` 软件包,如果软件仓库自带的版本足够你使用,那么可以不用添加仓库,直接通过` apt-get install collectd ` 即可。
24+
25+ RHEL/CentOS仓库安装(示例中使用` 5.5 ` 版本):
26+ ``` bash
27+ cat > /etc/yum.repos.d/collectd.repo << EOF
28+ [collectd-5.5]
29+ name=collectd-5.5
30+ baseurl=http://pkg.ci.collectd.org/rpm/collectd-5.5/epel-\$ releasever-\$ basearch/
31+ gpgcheck=1
32+ gpgkey=http://pkg.ci.collectd.org/pubkey.asc
33+ EOF
34+
35+ yum install -y collectd
36+ # 其他collectd插件需要安装对应的collectd-xxxx软件包
1637```
1738
1839### 源码安装collectd
1940
20- ```
41+ ``` bash
42+ # collectd目前维护3个版本, 5.4, 5.5, 5.6。根据自己需要选择版本
2143wget http://collectd.org/files/collectd-5.4.1.tar.gz
2244tar zxvf collectd-5.4.1.tar.gz
2345cd collectd-5.4.1
2446./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib --mandir=/usr/share/man --enable-all-plugins
2547make && make install
2648```
2749
28- ### 安装启动脚本
29-
50+ 解决依赖(RH系列):
51+ ``` bash
52+ rpm -ivh " http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm"
53+ yum -y install libcurl libcurl-devel rrdtool rrdtool-devel perl-rrdtool rrdtool-prel libgcrypt-devel gcc make gcc-c++ liboping liboping-devel perl-CPAN net-snmp net-snmp-devel
3054```
55+
56+ 安装启动脚本
57+ ``` bash
3158cp contrib/redhat/init.d-collectd /etc/init.d/collectd
3259chmod +x /etc/init.d/collectd
3360```
3461
3562### 启动collectd
36-
3763```
3864service collectd start
3965```
@@ -61,7 +87,6 @@ LoadPlugin disk
6187```
6288
6389##logstash的配置
64-
6590以下配置实现通过 logstash 监听 ` 25826 ` 端口,接收从 collectd 发送过来的各项检测数据。注意 ` logstash-filter-collectd ` 插件本身需要单独安装,logstash 插件安装说明之前已经讲过:
6691
6792```
@@ -70,7 +95,7 @@ bin/plugin install logstash-filter-collectd
7095
7196### 示例一:
7297
73- ```
98+ ``` ruby
7499input {
75100 collectd {
76101 port => 25826 # # 端口号与发送端对应
@@ -81,7 +106,7 @@ input {
81106
82107### 示例二:(推荐)
83108
84- ```
109+ ``` ruby
85110udp {
86111 port => 25826
87112 buffer_size => 1452
96121
97122下面是简单的一个输出结果:
98123
99- ```
124+ ``` json
100125{
101126 "_index" : " logstash-2014.12.11" ,
102127 "_type" : " collectd" ,
0 commit comments