diff --git a/monasca_setup/detection/plugins/ceph.py b/monasca_setup/detection/plugins/ceph.py index f3f0c6bf..ede43027 100644 --- a/monasca_setup/detection/plugins/ceph.py +++ b/monasca_setup/detection/plugins/ceph.py @@ -165,6 +165,9 @@ class Ceph(Plugin): cluster_dict['cluster_name'] = config_file[:-5] cluster_dict['config_file'] = \ os.path.join(self.ceph_config_dir, config_file) + cluster_dict['admin_key'] = \ + cluster_dict['cluster_name'] + '.client.admin.keyring' in \ + os.listdir(self.ceph_config_dir) clusters.append(cluster_dict) expected_processes = list() @@ -187,8 +190,20 @@ class Ceph(Plugin): # Configure ceph plugin instances = [] for cluster in clusters: - cluster_name = cluster['cluster_name'] - log.info("\tMonitoring ceph cluster: '{0}'.".format(cluster_name)) - instances.append({'cluster_name': cluster_name}) + cluster_config = {} + cluster_config['cluster_name'] = cluster['cluster_name'] + + # If there is no client admin key installed for this cluster + # then we cannot invoke Ceph commands for cluster monitoring. + # In that case we only monitor the locally active processes. + if not cluster['admin_key']: + cluster_config['collect_usage_metrics'] = False + cluster_config['collect_stats_metrics'] = False + cluster_config['collect_mon_metrics'] = False + cluster_config['collect_osd_metrics'] = False + cluster_config['collect_pool_metrics'] = False + + log.info("\tMonitoring ceph cluster: '{0}'.".format(cluster['cluster_name'])) + instances.append(cluster_config) config['ceph'] = {'init_config': None, 'instances': instances} return config diff --git a/tests/detection/test_ceph.py b/tests/detection/test_ceph.py index 5386640e..b369b727 100644 --- a/tests/detection/test_ceph.py +++ b/tests/detection/test_ceph.py @@ -164,6 +164,49 @@ class TestCephDetection(base.BaseTestCase): @mock.patch('os.path.exists', return_value=True) @mock.patch('os.listdir', return_value=['ceph.conf', 'ceph1.conf']) + def test_build_config_with_no_admin_key(self, list_dir, path_exists): + self._ceph._service_config = mock.Mock( + side_effect=mocked_service_config) + + processes = MON_PROCESSES + RGW_PROCESSES + process_instances = list() + + for p in processes: + instance = { + 'exact_match': False, + 'search_string': p['search_string'], + 'detailed': True, + 'name': p['name'], + 'dimensions': {'component': p['type'], 'service': 'ceph'} + } + process_instances.append(instance) + + expected_config = { + 'process': { + 'init_config': None, + 'instances': process_instances, + }, + 'ceph': { + 'init_config': None, + 'instances': [{'cluster_name': 'ceph', + 'collect_mon_metrics': False, + 'collect_osd_metrics': False, + 'collect_pool_metrics': False, + 'collect_stats_metrics': False, + 'collect_usage_metrics': False}, + {'cluster_name': 'ceph1', + 'collect_mon_metrics': False, + 'collect_osd_metrics': False, + 'collect_pool_metrics': False, + 'collect_stats_metrics': False, + 'collect_usage_metrics': False}] + } + } + config = self._ceph.build_config() + self.assertEqual(expected_config, dict(config)) + + @mock.patch('os.path.exists', return_value=True) + @mock.patch('os.listdir', return_value=['ceph.conf', 'ceph1.conf', 'ceph1.client.admin.keyring']) def test_build_config(self, list_dir, path_exists): self._ceph._service_config = mock.Mock( side_effect=mocked_service_config) @@ -188,7 +231,12 @@ class TestCephDetection(base.BaseTestCase): }, 'ceph': { 'init_config': None, - 'instances': [{'cluster_name': 'ceph'}, + 'instances': [{'cluster_name': 'ceph', + 'collect_mon_metrics': False, + 'collect_osd_metrics': False, + 'collect_pool_metrics': False, + 'collect_stats_metrics': False, + 'collect_usage_metrics': False}, {'cluster_name': 'ceph1'}] } }