Merge "Add telegraf user to ceph group"
diff --git a/telegraf/files/input/procstat.conf b/telegraf/files/input/procstat.conf
index d3d921e..11330ba 100644
--- a/telegraf/files/input/procstat.conf
+++ b/telegraf/files/input/procstat.conf
@@ -13,9 +13,7 @@
{%- if item.user is defined %}
user = "{{ item.user }}"
{%- endif %}
-{%- if item_name is defined %}
process_name = "{{ item_name }}"
-{%- endif %}
{%- if item.tags is defined %}
[inputs.{{name}}.tags]
{%- for tag_name, tag_value in item.tags.iteritems() %}
diff --git a/telegraf/map.jinja b/telegraf/map.jinja
index c49db55..3ca3e3e 100644
--- a/telegraf/map.jinja
+++ b/telegraf/map.jinja
@@ -17,16 +17,18 @@
},
}, merge=salt['pillar.get']('telegraf:remote_agent')) %}
-{%- set service_grains = {'telegraf': {'agent': {'input': {}}, 'remote_agent': {'input':{}}}} %}
+{# Collect configuration from */meta/telegraf.yml #}
+{%- set telegraf_grains = {'telegraf': {'agent': {'input': {}}, 'remote_agent': {'input':{}}}} %}
{%- for service_name, service in pillar.items() %}
{%- if service.get('_support', {}).get('telegraf', {}).get('enabled', False) %}
{%- set grains_fragment_file = service_name+'/meta/telegraf.yml' %}
{%- macro load_grains_file() %}{% include grains_fragment_file ignore missing %}{% endmacro %}
{%- set grains_yaml = load_grains_file()|load_yaml %}
{%- if grains_yaml is mapping %}
- {%- set service_grains = salt['grains.filter_by']({'default': service_grains}, merge={'telegraf': grains_yaml}) %}
+ {%- set telegraf_grains = salt['grains.filter_by']({'default': telegraf_grains}, merge={'telegraf': grains_yaml}) %}
{%- endif %}
{%- endif %}
{%- endfor %}
-{%- set telegraf_grains = salt['grains.filter_by']({'default': service_grains}, merge={'telegraf': {'agent': agent}}) %}
-{%- set telegraf_grains = salt['grains.filter_by']({'default': service_grains}, merge={'telegraf': {'remote_agent': remote_agent}}) %}
+
+{# Deep-merge the service configuration with the pillar data #}
+{%- do salt['defaults.merge'](telegraf_grains, {'telegraf': {'agent': agent, 'remote_agent': remote_agent}}) %}
diff --git a/telegraf/remote_agent.sls b/telegraf/remote_agent.sls
index f7123f1..6a508cf 100644
--- a/telegraf/remote_agent.sls
+++ b/telegraf/remote_agent.sls
@@ -3,6 +3,9 @@
{%- if remote_agent.get('enabled', False) %}
+{%- set remote_agent_label = pillar.get('docker', {}).get('client', {}).get('stack', {}).get('monitoring', {}).get('service', {}).get('remote_agent', {}).get('deploy', {}).get('labels', {}).get('com.mirantis.monitoring', 'remote_agent') %}
+{%- set docker_ids = salt['cmd.run']("docker ps -q -f 'label=com.mirantis.monitoring=" + remote_agent_label + "' 2> /dev/null") %}
+
config_dir_remote_agent:
file.directory:
- name: {{remote_agent.dir.config}}
@@ -26,6 +29,10 @@
- group: root
- mode: 644
- template: jinja
+ - onchanges_in:
+{%- for docker_id in docker_ids.split() %}
+ - cmd: {{docker_id}}_remote_agent_reload
+{%- endfor %}
- require:
- file: config_dir_remote_agent
- context:
@@ -55,6 +62,10 @@
- group: root
- mode: 644
- template: jinja
+ - onchanges_in:
+{%- for docker_id in docker_ids.split() %}
+ - cmd: {{docker_id}}_remote_agent_reload
+{%- endfor %}
- require:
- file: config_d_dir_remote_agent
- defaults:
@@ -75,6 +86,10 @@
- group: root
- mode: 644
- template: jinja
+ - onchanges_in:
+{%- for docker_id in docker_ids.split() %}
+ - cmd: {{docker_id}}_remote_agent_reload
+{%- endfor %}
- require:
- file: config_d_dir_remote_agent
- defaults:
@@ -82,4 +97,10 @@
values: {{ values }}
{%- endfor %}
+
+{%- for docker_id in docker_ids.split() %}
+{{docker_id }}_remote_agent_reload:
+ cmd.run:
+ - name: docker kill -s SIGHUP {{ docker_id }}
+{%- endfor %}
{%- endif %}