Skip to content

Commit 1aeb124

Browse files
authored
Merge pull request #19 from abcfy2/master
Add collectd install method to use official repo.
2 parents cc35331 + d275de5 commit 1aeb124

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

logstash/plugins/input/collectd.md

Lines changed: 36 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -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。根据自己需要选择版本
2143
wget http://collectd.org/files/collectd-5.4.1.tar.gz
2244
tar zxvf collectd-5.4.1.tar.gz
2345
cd collectd-5.4.1
2446
./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --libdir=/usr/lib --mandir=/usr/share/man --enable-all-plugins
2547
make && 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
3158
cp contrib/redhat/init.d-collectd /etc/init.d/collectd
3259
chmod +x /etc/init.d/collectd
3360
```
3461

3562
### 启动collectd
36-
3763
```
3864
service 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
7499
input {
75100
collectd {
76101
port => 25826 ## 端口号与发送端对应
@@ -81,7 +106,7 @@ input {
81106

82107
### 示例二:(推荐)
83108

84-
```
109+
```ruby
85110
udp {
86111
port => 25826
87112
buffer_size => 1452
@@ -96,7 +121,7 @@ udp {
96121

97122
下面是简单的一个输出结果:
98123

99-
```
124+
```json
100125
{
101126
"_index": "logstash-2014.12.11",
102127
"_type": "collectd",

0 commit comments

Comments
 (0)