search
数据采集 采集源配置 Collectd 数据采集

Collectd 数据采集

简介

采集 Collectd 数据指标上报到 DataFlux 中。

前置条件

配置

Collectd 配置

  1. 打开/etc/collectd/collectd.conf文件。(以 Linux Ubuntu 默认安装路径为参考)

  2. 找到#LoadPlugin network项,将行首的#删除,取消注释。

  3. 找到<Plugin network>项,<Server>Forward项取消注释,UsernamePassword项可以选择修改,如下:

<Plugin network>
#       # client setup:
#       Server "ff18::efc0:4a42" "25826"
        <Server "127.0.0.1" "25826">
                SecurityLevel Encrypt
                Username "user"
                Password "passwd"
#               Interface "eth0"
#               ResolveInterval 14400
        </Server>
#       TimeToLive 128
#
#       # server setup:
#       Listen "ff18::efc0:4a42" "25826"
#       <Listen "239.192.74.66" "25826">
#               SecurityLevel Sign
#               AuthFile "/etc/collectd/passwd"
#               Interface "eth0"
#       </Listen>
#       MaxPacketSize 1452
#
#       # proxy setup (client and server as above):
        Forward true
#
#       # statistics about the network plugin itself
#       ReportStats false
#
#       # "garbage collection"
#       CacheFlush 1800
</Plugin>
  1. /etc/collectd/路径下创建文件auth_file,内容为collectd.confnetwork项配置的UsernamePassword,格式为Username:Password

根据第二步参数设置,auth_file内容为:

user:passwd
  1. 使用systemctl restart collectd命令重启 collectd。

DataKit 配置

进入 DataKit 安装目录下的 conf.d/collectd 目录,复制 collectd.conf.sample 并命名为 collectd.conf。示例如下:

注意:collectd 是采用 socket_listener 这个采集器来实现数据采集的。

[[inputs.socket_listener]]
  service_address = "udp://:25826"
  data_format = "collectd"
  
  ## Authentication file for cryptographic security levels
  collectd_auth_file = "/etc/collectd/auth_file"
  
  ## One of none (default), sign, or encrypt
  collectd_security_level = "encrypt"
  
  ## Path of to TypesDB specifications
  collectd_typesdb = ["/usr/share/collectd/types.db"]
  
  ## Multi-value plugins can be handled two ways.
  ## "split" will parse and store the multi-value plugin data into separate measurements
  ## "join" will parse and store the multi-value plugin as a single multi-value measurement.
  ## "split" is the default behavior for backward compatability with previous versions of influxdb.
  collectd_parse_multivalue = "split"

其中,collectd_auth_file为 collectd 第三步创建的文件auth_file,其余选项可以使用默认值。

示例输出

注:所有measurement都带有后缀_value

memory_value,type=memory,type_instance=buffered value=2520051712 1560455990829955922
memory_value,type=memory,type_instance=used value=3710791680 1560455990829955922
memory_value,type=memory,type_instance=buffered value=2520047616 1560455980830417318
memory_value,type=memory,type_instance=cached value=9472626688 1560455980830417318
memory_value,type=memory,type_instance=slab_recl value=2088894464 1560455980830417318
memory_value,type=memory,type_instance=slab_unrecl value=146984960 1560455980830417318
memory_value,type=memory,type_instance=free value=2978258944 1560455980830417318
memory_value,type=memory,type_instance=used value=3707047936 1560455980830417318