Add list of VIPs to ipcheck
Change-Id: I73c4988ca023de3070319662c6e3a59cfec3593d
Closes-bug: PROD-21261
diff --git a/keepalived/files/telegraf.conf b/keepalived/files/telegraf.conf
index 1ab05a2..8b522fc 100644
--- a/keepalived/files/telegraf.conf
+++ b/keepalived/files/telegraf.conf
@@ -1,6 +1,9 @@
[[inputs.ipcheck]]
{%- include 'telegraf/files/input/_common.conf' %}
{%- if values.interface_name_regexp_exclude is defined %}
- interface_name_regexp_exclude = "{{ values.interface_name_regexp_exclude }}"
+interface_name_regexp_exclude = "{{ values.interface_name_regexp_exclude }}"
+{%- endif %}
+{%- if values.ips is defined %}
+ips = [{%- for ip in values.ips %}"{{ ip }}"{%- if not loop.last %}, {%- endif %}{%- endfor %}]
{%- endif %}
{%- include 'telegraf/files/input/_tags.conf' %}
diff --git a/keepalived/meta/telegraf.yml b/keepalived/meta/telegraf.yml
index abad283..b7818f3 100644
--- a/keepalived/meta/telegraf.yml
+++ b/keepalived/meta/telegraf.yml
@@ -1,3 +1,4 @@
+{%- from "keepalived/map.jinja" import cluster with context %}
agent:
input:
procstat:
@@ -7,3 +8,16 @@
ipcheck:
template: keepalived/files/telegraf.conf
interface_name_regexp_exclude: '^docker.*'
+ ips: [
+ {%- for _, vip in cluster.instance.iteritems() %}
+ {%- if vip.get('enabled', True) %}
+ {%- if vip.get('address', False) %}
+ "{{ vip.address }}"{%- if not loop.last %}, {% endif %}
+ {%- elif vip.get('addresses', False) %}
+ {%- for ip in vip.addresses %}
+ "{{ ip }}"{%- if not loop.last %}, {% endif %}
+ {%- endfor %}
+ {%- endif %}
+ {%- endif %}
+ {%- endfor %}
+ ]