Merge remote-tracking branch 'upstream/master' into merge-master-branch
Conflicts:
collectd/client.sls
collectd/files/collectd.conf
collectd/files/collectd_python.conf
collectd/map.jinja
diff --git a/collectd/client.sls b/collectd/client.sls
index d81c660..5937f04 100644
--- a/collectd/client.sls
+++ b/collectd/client.sls
@@ -55,16 +55,38 @@
file.recurse:
- source: salt://collectd/files/plugin
-{%- set service_grains = {'collectd': {'plugin': {}}} %}
+{%- set service_grains = {'collectd': {'remote_plugin': {}, 'local_plugin': {}}} %}
+
{%- for service_name, service in pillar.items() %}
{%- if service.get('_support', {}).get('collectd', {}).get('enabled', False) %}
+
{%- set grains_fragment_file = service_name+'/meta/collectd.yml' %}
-{%- macro load_grains_file() %}{% include grains_fragment_file %}{% endmacro %}
+{%- macro load_grains_file() %}{% include grains_fragment_file ignore missing %}{% endmacro %}
{%- set grains_yaml = load_grains_file()|load_yaml %}
-{%- set _dummy = service_grains.collectd.plugin.update(grains_yaml.plugin) %}
+
+{%- if grains_yaml is mapping %}
+{%- set service_grains = salt['grains.filter_by']({'default': service_grains}, merge={'collectd': grains_yaml}) %}
+{%- endif %}
+
{%- endif %}
{%- endfor %}
+{%- set remote_plugin = {} %}
+
+{%- if client.remote_collector %}
+
+{%- for node_name, node_grains in salt['mine.get']('*', 'grains.items').iteritems() %}
+
+{%- if node_grains.collectd is defined %}
+
+{%- set remote_plugin = salt['grains.filter_by']({'default': remote_plugin}, merge=node_grains.collectd.get('remote_plugin', {})) %}
+
+{%- endif %}
+
+{%- endfor %}
+
+{%- endif %}
+
collectd_client_grain:
file.managed:
- name: /etc/salt/grains.d/collectd
@@ -86,9 +108,9 @@
- watch:
- file: collectd_client_grain
-{%- for plugin_name, plugin in service_grains.collectd.get('plugin', {}).iteritems() %}
+{%- for plugin_name, plugin in service_grains.collectd.local_plugin.iteritems() %}
-{%- if (plugin.get('execution', 'local') == 'local' or client.remote_collector) and plugin.get('plugin', 'native') not in ['python'] %}
+{%- if plugin.get('plugin', 'native') not in ['python'] %}
{{ client.config_dir }}/{{ plugin_name }}.conf:
file.managed:
@@ -113,6 +135,37 @@
{%- endfor %}
+{%- if client.remote_collector %}
+
+{%- for plugin_name, plugin in remote_plugin.iteritems() %}
+
+{%- if plugin.get('plugin', 'native') not in ['python'] %}
+
+{{ client.config_dir }}/{{ plugin_name }}.conf:
+ file.managed:
+ {%- if plugin.template is defined %}
+ - source: salt://{{ plugin.template }}
+ - template: jinja
+ - defaults:
+ plugin: {{ plugin|yaml }}
+ {%- else %}
+ - contents: "<LoadPlugin {{ plugin.plugin }}>\n Globals false\n</LoadPlugin>\n"
+ {%- endif %}
+ - user: root
+ - mode: 660
+ - require:
+ - file: collectd_client_conf_dir
+ - require_in:
+ - file: collectd_client_conf_dir_clean
+ - watch_in:
+ - service: collectd_service
+
+{%- endif %}
+
+{%- endfor %}
+
+{%- endif %}
+
{%- if client.file_logging %}
/etc/collectd/conf.d/00_collectd_logfile.conf:
@@ -138,7 +191,8 @@
- group: root
- mode: 660
- defaults:
- plugin: {{ service_grains.collectd.plugin|yaml }}
+ local_plugin: {{ service_grains.collectd.local_plugin|yaml }}
+ remote_plugin: {{ remote_plugin|yaml }}
- watch_in:
- service: collectd_service
- require:
@@ -183,6 +237,7 @@
- mode: 640
- defaults:
service_grains: {{ service_grains|yaml }}
+ remote_plugin: {{ remote_plugin|yaml }}
- require:
- file: collectd_client_conf_dir
- require_in:
diff --git a/collectd/files/collectd.conf b/collectd/files/collectd.conf
index 03175e2..c839530 100644
--- a/collectd/files/collectd.conf
+++ b/collectd/files/collectd.conf
@@ -15,7 +15,11 @@
# Global settings for the daemon. #
##############################################################################
+{%- if client.use_fqdn %}
Hostname "{{ system.name }}.{{ system.domain }}"
+{%- else %}
+Hostname "{{ system.name }}"
+{%- endif %}
FQDNLookup false
#BaseDir "/var/lib/collectd"
@@ -881,11 +885,17 @@
{%- if client.file_logging %}
Include "/etc/collectd/conf.d/00_collectd_logfile.conf"
{%- endif %}
-{%- for plugin_name, plugin in service_grains.collectd.get('plugin', {}).iteritems() %}
-{%- if (plugin.get('execution', 'local') == 'local' or client.remote_collector) and plugin.get('plugin', 'native') not in ['python'] %}
+{%- for plugin_name, plugin in service_grains.collectd.local_plugin.iteritems() %}
+{%- if plugin.get('plugin', 'native') not in ['python'] %}
Include "{{ client.config_dir }}/{{ plugin_name }}.conf"
{%- endif %}
{%- endfor %}
+{%- if client.remote_collector %}
+{%- for plugin_name, plugin in remote_plugin.iteritems() %}
+{%- if plugin.get('plugin', 'native') not in ['python'] %}
+{%- endif %}
+{%- endfor %}
+{%- endif %}
Include "{{ client.config_dir }}/collectd_python.conf"
{%- for backend_name, backend in client.backend.iteritems() %}
Include "{{ client.config_dir }}/collectd_writer_{{ backend_name }}.conf"
diff --git a/collectd/files/collectd_check_local_endpoint.conf b/collectd/files/collectd_check_local_endpoint.conf
index 4144e96..b154564 100644
--- a/collectd/files/collectd_check_local_endpoint.conf
+++ b/collectd/files/collectd_check_local_endpoint.conf
@@ -1,6 +1,4 @@
-
{%- if plugin.get('endpoint', {})|length > 0 %}
-
Import "check_local_endpoint"
<Module "check_local_endpoint">
@@ -13,5 +11,4 @@
Url "{{ endpoint_name }}" "{{ endpoint.url }}"
{%- endfor %}
</Module>
-
-{%- endif %}
\ No newline at end of file
+{%- endif %}
diff --git a/collectd/files/collectd_python.conf b/collectd/files/collectd_python.conf
index a30ee36..7a279e7 100644
--- a/collectd/files/collectd_python.conf
+++ b/collectd/files/collectd_python.conf
@@ -1,4 +1,4 @@
-{%- from "collectd/map.jinja" import client with context %}
+{%- from "collectd/map.jinja" import client with context -%}
<LoadPlugin python>
Globals false
</LoadPlugin>
@@ -7,9 +7,16 @@
ModulePath "/usr/lib/collectd-python"
LogTraces false
Interactive false
- {%- if plugin is mapping %}
- {%- for plugin_name, plugin in plugin.iteritems() %}
- {%- if (plugin.get('execution', 'local') == 'local' or client.remote_collector) and plugin.get('plugin', 'native') == 'python' %}
+
+ {%- for plugin_name, plugin in local_plugin.iteritems() %}
+ {%- if plugin.get('plugin', 'native') == 'python' %}
+ {%- include plugin.template %}
+ {%- endif %}
+ {%- endfor %}
+
+ {%- if client.remote_collector %}
+ {%- for plugin_name, plugin in remote_plugin.iteritems() %}
+ {%- if plugin.get('plugin', 'native') == 'python' %}
{%- include plugin.template %}
{%- endif %}
{%- endfor %}
diff --git a/collectd/files/plugin/rabbitmq_info.py b/collectd/files/plugin/rabbitmq_info.py
index c92ce0e..d78b6cb 100644
--- a/collectd/files/plugin/rabbitmq_info.py
+++ b/collectd/files/plugin/rabbitmq_info.py
@@ -79,14 +79,14 @@
self.api_overview_url, r.status_code)
raise base.CheckException(msg)
- objects = overview['object_totals']
- stats['queues'] = objects['queues']
- stats['consumers'] = objects['consumers']
- stats['connections'] = objects['connections']
- stats['exchanges'] = objects['exchanges']
- stats['channels'] = objects['channels']
- stats['messages'] = overview['queue_totals']['messages']
- stats['running_nodes'] = len(overview['contexts'])
+ objects = overview.get('object_totals', {})
+ stats['queues'] = objects.get('queues', 0)
+ stats['consumers'] = objects.get('consumers', 0)
+ stats['connections'] = objects.get('connections', 0)
+ stats['exchanges'] = objects.get('exchanges', 0)
+ stats['channels'] = objects.get('channels', 0)
+ stats['messages'] = overview.get('queue_totals', {}).get('messages', 0)
+ stats['running_nodes'] = len(overview.get('contexts', []))
for k, v in stats.iteritems():
yield {'type_instance': k, 'values': v}
diff --git a/collectd/map.jinja b/collectd/map.jinja
index a0156c5..0bfbe96 100644
--- a/collectd/map.jinja
+++ b/collectd/map.jinja
@@ -8,15 +8,17 @@
'read_interval': 60,
'file_logging': True,
'remote_collector': False
+ 'use_fqdn': True,
},
'Debian': {
- 'pkgs': ['collectd-core', 'snmp', 'python-yaml', 'libpython2.7'],
+ 'pkgs': ['collectd-core', 'snmp', 'python-yaml', 'libpython2.7', 'python-simplejson'],
'service': 'collectd',
'config_file': '/etc/collectd/collectd.conf',
'config_dir': '/etc/collectd/conf.d',
'read_interval': 60,
'file_logging': True,
'remote_collector': False
+ 'use_fqdn': True,
},
'RedHat': {
'pkgs': ['collectd', 'collectd-ping', 'net-snmp', 'PyYAML'],
@@ -26,5 +28,6 @@
'read_interval': 60,
'file_logging': True,
'remote_collector': False
+ 'use_fqdn': True,
},
}, merge=salt['pillar.get']('collectd:client')) %}
diff --git a/collectd/meta/collectd.yml b/collectd/meta/collectd.yml
index 98d6ee1..a529942 100644
--- a/collectd/meta/collectd.yml
+++ b/collectd/meta/collectd.yml
@@ -1,30 +1,24 @@
-plugin:
+local_plugin:
collectd_processes:
plugin: processes
- execution: local
template: collectd/files/collectd_processes.conf
process:
collectdmon: {}
- collectd_check_local_endpoint:
- plugin: python
- execution: local
- template: collectd/files/collectd_check_local_endpoint.conf
- endpoint: {}
-{%- if pillar.collectd.client.get('check', {}).curl is defined %}
+ {%- if pillar.collectd.client.get('check', {}).curl is defined %}
collectd_curl:
plugin: curl
execution: local
template: collectd/files/collectd_curl.conf
data: {{ pillar.collectd.client.check.curl|yaml }}
-{%- endif %}
-{%- if pillar.collectd.client.get('check', {}).ping is defined %}
+ {%- endif %}
+ {%- if pillar.collectd.client.get('check', {}).ping is defined %}
collectd_ping:
plugin: ping
execution: local
template: collectd/files/collectd_ping.conf
data: {{ pillar.collectd.client.check.ping|yaml }}
-{%- endif %}
-{%- if pillar.get('external', {}).network_device is defined %}
+ {%- endif %}
+ {%- if pillar.get('external', {}).network_device is defined %}
collectd_network_device:
plugin: snmp
execution: local
@@ -45,4 +39,10 @@
- 1.3.6.1.2.1.31.1.1.1.7
- 1.3.6.1.2.1.31.1.1.1.11
host: {{ pillar.external.network_device|yaml }}
-{%- endif %}
\ No newline at end of file
+ {%- endif %}
+remote_plugin:
+ collectd_check_local_endpoint:
+ plugin: python
+ execution: remote
+ template: collectd/files/collectd_check_local_endpoint.conf
+ endpoint: {}
diff --git a/metadata/service/client/init.yml b/metadata/service/client/init.yml
index cbf9f47..6ef1257 100644
--- a/metadata/service/client/init.yml
+++ b/metadata/service/client/init.yml
@@ -7,3 +7,4 @@
client:
enabled: true
read_interval: 60
+ use_fqdn: true