Merge "Collect Elasticsearch performance metrics"
diff --git a/.kitchen.yml b/.kitchen.yml
new file mode 100644
index 0000000..e96d842
--- /dev/null
+++ b/.kitchen.yml
@@ -0,0 +1,47 @@
+---
+driver:
+ name: docker
+ hostname: collectd.ci.local
+ use_sudo: false
+
+provisioner:
+ name: salt_solo
+ salt_install: bootstrap
+ salt_bootstrap_url: https://bootstrap.saltstack.com
+ salt_version: latest
+ require_chef: false
+ log_level: error
+ formula: collectd
+ grains:
+ noservices: True
+ state_top:
+ base:
+ "*":
+ - collectd
+ pillars:
+ top.sls:
+ base:
+ "*":
+ - collectd
+ dependencies:
+ - name: linux
+ repo: git
+ source: https://github.com/salt-formulas/salt-formula-linux
+
+verifier:
+ name: inspec
+ sudo: true
+
+platforms:
+ - name: <%=ENV['PLATFORM'] || 'ubuntu-xenial'%>
+ driver_config:
+ image: <%=ENV['PLATFORM'] || 'trevorj/salty-whales:xenial'%>
+ platform: ubuntu
+
+suites:
+
+ - name: client
+ provisioner:
+ pillars-from-files:
+ collectd.sls: tests/pillar/client.sls
+# vim: ft=yaml sw=2 ts=2 sts=2 tw=125
diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..4f34af2
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,40 @@
+sudo: required
+services:
+ - docker
+
+install:
+ - pip install PyYAML
+ - pip install virtualenv
+ - |
+ test -e Gemfile || cat <<EOF > Gemfile
+ source 'https://rubygems.org'
+ gem 'rake'
+ gem 'test-kitchen'
+ gem 'kitchen-docker'
+ gem 'kitchen-inspec'
+ gem 'inspec'
+ gem 'kitchen-salt', :git => 'https://github.com/salt-formulas/kitchen-salt.git'
+ - bundle install
+
+env:
+ - PLATFORM=trevorj/salty-whales:trusty
+ - PLATFORM=trevorj/salty-whales:xenial
+
+
+before_script:
+ - set -o pipefail
+ - make test | tail
+
+script:
+ - test ! -e .kitchen.yml || bundle exec kitchen test -t tests/integration
+
+notifications:
+ webhooks:
+ urls:
+ - https://webhooks.gitter.im/e/6123573504759330786b
+ on_success: change # options: [always|never|change] default: always
+ on_failure: never # options: [always|never|change] default: always
+ on_start: never # options: [always|never|change] default: always
+ on_cancel: never # options: [always|never|change] default: always
+ on_error: never # options: [always|never|change] default: always
+ email: false
diff --git a/collectd/files/plugin/collectd_openstack.py b/collectd/files/plugin/collectd_openstack.py
index ade9b60..e118332 100644
--- a/collectd/files/plugin/collectd_openstack.py
+++ b/collectd/files/plugin/collectd_openstack.py
@@ -111,13 +111,18 @@
endpoint = item['endpoints'][0]
if self.region and self.region != endpoint['region']:
continue
+ if 'internalURL' not in endpoint and 'publicURL' not in endpoint:
+ self.logger.warning(
+ "Skipping service '{}' with no valid URL".format(
+ endpoint["name"]
+ )
+ )
+ continue
self.service_catalog.append({
'name': item['name'],
'region': endpoint['region'],
- 'service_type': item['type'],
- 'url': endpoint['internalURL'],
- 'admin_url': endpoint['adminURL'],
+ 'url': endpoint.get('internalURL', endpoint.get('publicURL')),
})
self.logger.debug("Got token '%s'" % self.token)
diff --git a/collectd/files/plugin/openstack_glance.py b/collectd/files/plugin/openstack_glance.py
index 90bc9f8..efb94be 100644
--- a/collectd/files/plugin/openstack_glance.py
+++ b/collectd/files/plugin/openstack_glance.py
@@ -40,6 +40,19 @@
def itermetrics(self):
+ def default_metrics(suffix=''):
+ ret = {}
+ for name in ('snapshots', 'images'):
+ for visibility in ('public', 'private',
+ 'community', 'shared'):
+ for status in ('active', 'queued', 'saving',
+ 'killed', 'deleted', 'deactivated',
+ 'pending_delete'):
+ key = '%s%s.%s.%s' % (name, suffix,
+ visibility, status)
+ ret[key] = 0
+ return ret
+
def is_snap(d):
return d.get('image_type') == 'snapshot'
@@ -56,6 +69,8 @@
detail=False)
status = self.count_objects_group_by(images_details,
group_by_func=groupby)
+ if len(status) == 0:
+ status = default_metrics()
for s, nb in status.iteritems():
(name, visibility, state) = s.split('.')
yield {
@@ -79,6 +94,8 @@
sizes = self.count_objects_group_by(images_details,
group_by_func=groupby_size,
count_func=count_size_bytes)
+ if len(sizes) == 0:
+ sizes = default_metrics('_size')
for s, nb in sizes.iteritems():
(name, visibility, state) = s.split('.')
yield {
diff --git a/tests/pillar/client.sls b/tests/pillar/client.sls
index b970e72..93bd7ad 100644
--- a/tests/pillar/client.sls
+++ b/tests/pillar/client.sls
@@ -1,4 +1,3 @@
-
collectd:
client:
enabled: true
@@ -8,4 +7,7 @@
engine: carbon
host: 127.0.0.1
port: 2023
-
+linux:
+ system:
+ name: hostname
+ domain: domain