Add polling.yaml to managed configs

This change adds polling.yaml to the list of managed config files, for
Queens and above.  Two new config items are added alongside the
template, to take into account a choice between the two polling.yaml
files supplied with the Ceilometer source, one which has a small list of
pollsters and the other which has all pollsters.  Additionally the
change adds the option to set the polling interval.

Change-Id: Ifff72870cf79bea23dbd21586857dd832c9e1405
Closes-Bug: 1785933
Closes-Bug: 1652848
This commit is contained in:
Xav Paice 2018-08-08 15:25:27 +12:00
parent 8cde93e515
commit 2baf36f4ee
6 changed files with 87 additions and 0 deletions

View File

@ -255,3 +255,16 @@ options:
description: |
When set the content is written to /etc/ceilometer/pipeline.yaml, by
default the package's file is used.
polling-interval:
type: int
default: 300
description: |
Number of seconds between Ceilometer central agent pollster collections.
This setting only takes effect from Queens onwards.
enable-all-pollsters:
type: boolean
default: False
description: |
From Pike onwards, the default ceilometer pollster collection runs a
limited set of pollsters. Enable this to run all the available pollsters.
This setting only takes effect from Queens onwards.

View File

@ -106,6 +106,8 @@ class CeilometerContext(OSContextGenerator):
'metering_secret': get_shared_secret(),
'metering_time_to_live': int(config('metering-time-to-live')),
'event_time_to_live': int(config('event-time-to-live')),
'polling_interval': int(config('polling-interval')),
'enable_all_pollsters': config('enable-all-pollsters'),
}
return ctxt

View File

@ -71,6 +71,7 @@ HAPROXY_CONF = '/etc/haproxy/haproxy.cfg'
CEILOMETER_CONF_DIR = "/etc/ceilometer"
CEILOMETER_CONF = "%s/ceilometer.conf" % CEILOMETER_CONF_DIR
CEILOMETER_PIPELINE_YAML = "%s/pipeline.yaml" % CEILOMETER_CONF_DIR
POLLING_CONF = "%s/polling.yaml" % CEILOMETER_CONF_DIR
CEILOMETER_API_SYSTEMD_CONF = (
'/etc/systemd/system/ceilometer-api.service.d/override.conf'
)
@ -160,6 +161,11 @@ QUEENS_CONFIG_FILES = OrderedDict([
AMQPListenersContext(ssl_dir=CEILOMETER_CONF_DIR)],
'services': QUEENS_SERVICES
}),
(POLLING_CONF, {
'hook_contexts': [
CeilometerContext()],
'services': QUEENS_SERVICES
}),
])
CONFIG_FILES = OrderedDict([

31
templates/polling.yaml Normal file
View File

@ -0,0 +1,31 @@
---
sources:
- name: juju_pollsters
interval: {{ polling_interval }}
meters:
{%- if enable_all_pollsters %}
- "*"
{%- else %}
- cpu
- cpu_l3_cache
- memory.usage
- network.incoming.bytes
- network.incoming.packets
- network.outgoing.bytes
- network.outgoing.packets
- disk.device.read.bytes
- disk.device.read.requests
- disk.device.write.bytes
- disk.device.write.requests
- hardware.cpu.util
- hardware.memory.used
- hardware.memory.total
- hardware.memory.buffer
- hardware.memory.cached
- hardware.memory.swap.avail
- hardware.memory.swap.total
- hardware.system_stats.io.outgoing.blocks
- hardware.system_stats.io.incoming.blocks
- hardware.network.ip.incoming.datagrams
- hardware.network.ip.outgoing.datagrams
{%- endif %}

View File

@ -131,6 +131,8 @@ class CeilometerContextsTest(CharmTestCase):
'metering_secret': 'mysecret',
'metering_time_to_live': -1,
'event_time_to_live': -1,
'polling_interval': 300,
'enable_all_pollsters': False,
})
@patch.object(utils, 'get_shared_secret')
@ -144,10 +146,40 @@ class CeilometerContextsTest(CharmTestCase):
'metering_secret': 'mysecret',
'metering_time_to_live': 7776000,
'event_time_to_live': 7776000,
'polling_interval': 300,
'enable_all_pollsters': False,
})
self.assertTrue(type(context['metering_time_to_live']) is int)
self.assertTrue(type(context['event_time_to_live']) is int)
@patch.object(utils, 'get_shared_secret')
def test_ceilometer_context_enable_all_pollsters(self, secret):
secret.return_value = 'mysecret'
self.test_config.set('enable-all-pollsters', True)
context = contexts.CeilometerContext()()
self.assertEqual(context, {
'port': 8777,
'metering_secret': 'mysecret',
'metering_time_to_live': -1,
'event_time_to_live': -1,
'polling_interval': 300,
'enable_all_pollsters': True,
})
@patch.object(utils, 'get_shared_secret')
def test_ceilometer_context_polling_interval(self, secret):
secret.return_value = 'mysecret'
self.test_config.set('polling-interval', 900)
context = contexts.CeilometerContext()()
self.assertEqual(context, {
'port': 8777,
'metering_secret': 'mysecret',
'metering_time_to_live': -1,
'event_time_to_live': -1,
'polling_interval': 900,
'enable_all_pollsters': False,
})
def test_ceilometer_service_context(self):
self.relation_ids.return_value = ['ceilometer-service:0']
self.related_units.return_value = ['ceilometer/0']

View File

@ -176,6 +176,9 @@ class CeilometerUtilsTest(CharmTestCase):
{'/etc/ceilometer/ceilometer.conf': [
'ceilometer-agent-central',
'ceilometer-agent-notification'],
'/etc/ceilometer/polling.yaml': [
'ceilometer-agent-central',
'ceilometer-agent-notification'],
}
)