From d787b2bb213be8ddf6448ecc97f68b2da06bdbce Mon Sep 17 00:00:00 2001 From: guochao Date: Fri, 21 Jul 2017 11:09:16 +0800 Subject: [PATCH] Add collectd support to telegraf container Telegraf can collect sample from collectd via UDP. Configure collectd to exposed samples and telegraf to collect them. Change-Id: Ie868a4c23cb793e6054e14ee1209a56256c130ac Depends-On: I33b1a3fe606bf5bd4a08901c7bf274aed5303055 --- ansible/group_vars/all.yml | 2 ++ ansible/roles/collectd/templates/collectd.conf.j2 | 5 +++++ ansible/roles/telegraf/templates/telegraf.conf.j2 | 7 +++++++ 3 files changed, 14 insertions(+) diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index 16443a2872..188ad32b82 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -137,6 +137,8 @@ congress_api_port: "1789" cloudkitty_api_port: "8889" +collectd_udp_port: "25826" + designate_api_port: "9001" designate_bind_port: "53" designate_mdns_port: "5354" diff --git a/ansible/roles/collectd/templates/collectd.conf.j2 b/ansible/roles/collectd/templates/collectd.conf.j2 index 6fdc5a333b..fad5e438fb 100644 --- a/ansible/roles/collectd/templates/collectd.conf.j2 +++ b/ansible/roles/collectd/templates/collectd.conf.j2 @@ -4,3 +4,8 @@ LoadPlugin cpu LoadPlugin interface LoadPlugin load LoadPlugin memory +LoadPlugin network + + + Server "{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}" "{{ collectd_udp_port }}" + diff --git a/ansible/roles/telegraf/templates/telegraf.conf.j2 b/ansible/roles/telegraf/templates/telegraf.conf.j2 index 687cdcc078..667c79271b 100644 --- a/ansible/roles/telegraf/templates/telegraf.conf.j2 +++ b/ansible/roles/telegraf/templates/telegraf.conf.j2 @@ -21,6 +21,13 @@ percpu = true totalcpu = true fielddrop = ["time_*"] +{% if enable_collectd | bool and inventory_hostname in groups['collectd'] %} +[[inputs.socket_listener]] + service_address = "udp://{{ hostvars[inventory_hostname]['ansible_' + api_interface]['ipv4']['address'] }}:{{ collectd_udp_port }}" + name_prefix = "collectd_" + data_format = "collectd" + collectd_typesdb = ["/usr/share/collectd/types.db"] +{% endif %} [[inputs.disk]] ignore_fs = ["tmpfs", "devtmpfs"] [[inputs.diskio]]