Merge "Adds Ceph RADOS Gateway monitoring to ceph plugin"

This commit is contained in:
Jenkins 2016-02-26 17:24:29 +00:00 committed by Gerrit Code Review
commit d16173a757

View File

@ -27,6 +27,11 @@ class Ceph(Plugin):
cluster and has a corresponding daemon identifier at
/var/lib/ceph/mds/
The ceph object store is exposed via RADOS Gateway
- RADOS Gateway (radosgw)
'radosgw' is an HTTP REST gateway for the RADOS object store,
a part of the Ceph distributed storage system.
Unlike OpenStack services monitoring a single instance of a service will
be of no use for Ceph. Every daemon needs to be monitored. This can be
achieved by scanning through the daemon identifiers.
@ -35,14 +40,18 @@ class Ceph(Plugin):
def __init__(self, template_dir, overwrite=True, args=None):
self.service_name = 'ceph-storage'
self.process_names = ['ceph-osd', 'ceph-mon', 'ceph-mds']
self.process_names = ['ceph-osd', 'ceph-mon', 'ceph-mds', 'radosgw']
self.ceph_config_dir = '/etc/ceph/'
self.ceph_osd_path = '/var/lib/ceph/osd/'
self.ceph_mon_path = '/var/lib/ceph/mon/'
self.ceph_mds_path = '/var/lib/ceph/mds/'
self.ceph_osd_executable = '/usr/bin/ceph-osd'
self.ceph_mon_executable = '/usr/bin/ceph-mon'
self.ceph_mds_executable = '/usr/bin/ceph-mds'
self.service_constants = dict()
for process in self.process_names:
process_type = process.replace('ceph-', '')
display_name = 'ceph-%s' % process \
if not process.startswith('ceph-') else process
self.service_constants[process_type] = {
'service_dir': '/var/lib/ceph/%s/' % process_type,
'executable': '/usr/bin/%s' % process,
'display_name': display_name
}
super(Ceph, self).__init__(template_dir, overwrite, args)
@ -50,7 +59,7 @@ class Ceph(Plugin):
"""Run detection.
"""
self.found_processes = []
self.found_processes = list()
for process in self.process_names:
if find_process_cmdline(process) is not None:
@ -60,7 +69,7 @@ class Ceph(Plugin):
@staticmethod
def _build_search_string(executable, options=None):
search_strings = []
search_strings = list()
command = [executable]
if options:
command.extend(options)
@ -70,6 +79,73 @@ class Ceph(Plugin):
search_strings.append(" ".join(permutation))
return search_strings
def _service_config(self, cluster_name, service_type):
display_name = self.service_constants[service_type]['display_name']
service_dir = self.service_constants[service_type]['service_dir']
executable = self.service_constants[service_type]['executable']
expected_processes = list()
# Get the list of daemon identifiers
instance_list = os.listdir(service_dir) \
if os.path.exists(service_dir) else list()
for instance in instance_list:
# Daemon identifier is of format <cluster_name>-<id>
# 'id' for ceph-mon is alphanumeric and is usually the hostname
# where the service is running for ceph-mon
# E.g., ceph-monitor1.dom, ceph-monitor2.dom etc.
#
# 'id' for ceph-osd is a unique numeric index for
# that OSD in the cluster
# E.g., ceph-1, ceph-2 etc.
#
# 'id' for ceph-mds is alphanumeric and is usually the hostname
# where the service is running.
# E.g., ceph-mds1.dom, ceph-mds2.dom etc.
daemon_id = instance.split(cluster_name + '-', 1)[1]
process = dict()
process_args = ['--cluster %s' % cluster_name,
'--id %s' % daemon_id, '-f']
process['search_string'] = self._build_search_string(
executable, process_args)
process['name'] = '%s-%s.%s' \
% (cluster_name, service_type, daemon_id)
process['type'] = display_name
expected_processes.append(process)
return expected_processes
def _radosgw_config(self, cluster_name, config_file):
expected_processes = list()
# RADOS Gateway processes is of the format:
# /usr/bin/radosgw -c <config_file> -n <rados_username>
# E.g.,
# /usr/bin/radosgw -c /etc/ceph/ceph.conf -n client.radosgw.gateway
process = dict()
process['search_string'] = list()
process['name'] = '%s-radosgw' % cluster_name
process['type'] = self.service_constants['radosgw']['display_name']
executable = self.service_constants['radosgw']['executable']
process_options = ['-n client.radosgw.',
'--name=client.radosgw.']
for opt in process_options:
# Adding multiple combinations for all possible use cases, since
# any of the following combination can be used to start the process
# Trivial case (This will be the most used scenario)
# E.g., /usr/bin/radosgw -n client.radosgw.gateway
process['search_string'].append('%s %s' % (executable, opt))
# Service started with specific conf file (For rare cases)
# E.g., /usr/bin/radosgw -c custom.conf -n client.radosgw.gateway
process['search_string'].append('%s -c %s %s'
% (executable, config_file, opt))
process['search_string'].append('%s --conf=%s %s'
% (executable, config_file, opt))
expected_processes.append(process)
return expected_processes
def build_config(self):
"""Build the config as a Plugins object and return.
@ -78,66 +154,26 @@ class Ceph(Plugin):
# Default cluster name
cluster_name = 'ceph'
config_file = '/etc/ceph/ceph.conf'
# Get the cluster_name from <cluster_name>.conf in /etc/ceph/ directory
if os.path.exists(self.ceph_config_dir):
config_files = [f for f in os.listdir(self.ceph_config_dir)
if f.endswith('.conf')]
if not config_files:
return config
config_file = os.path.join(self.ceph_config_dir, config_files[0])
cluster_name = config_files[0][:-5]
# Get the list of daemon identifiers
osd_list = os.listdir(self.ceph_osd_path) \
if os.path.exists(self.ceph_osd_path) else []
mon_list = os.listdir(self.ceph_mon_path) \
if os.path.exists(self.ceph_mon_path) else []
mds_list = os.listdir(self.ceph_mds_path) \
if os.path.exists(self.ceph_mds_path) else []
expected_processes = list()
expected_processes = []
for osd in osd_list:
# OSD daemon identifier is of format <cluster_name>-<id>
# Where 'id' is a unique numeric index for that OSD in the cluster
# E.g., ceph-1, ceph-2 etc.
daemon_id = osd.split(cluster_name + '-', 1)[1]
process = dict()
process_args = ['--cluster %s' % cluster_name,
'--id %s' % daemon_id, '-f']
process['search_string'] = self._build_search_string(
self.ceph_osd_executable, process_args)
process['name'] = '%s-osd.%s' % (cluster_name, daemon_id)
process['type'] = 'ceph-osd'
expected_processes.append(process)
for mon in mon_list:
# MON daemon identifier is of format <cluster_name>-<id>
# Where 'id' is alphanumeric and is usually the hostname
# where the service is running.
# E.g., ceph-monitor1.dom, ceph-monitor2.dom etc.
daemon_id = mon.split(cluster_name + '-', 1)[1]
process = dict()
process_args = ['--cluster %s' % cluster_name,
'--id %s' % daemon_id, '-f']
process['search_string'] = self._build_search_string(
self.ceph_mon_executable, process_args)
process['name'] = '%s-mon.%s' % (cluster_name, daemon_id)
process['type'] = 'ceph-mon'
expected_processes.append(process)
for mds in mds_list:
# MON daemon identifier is of format <cluster_name>-<id>
# Where 'id' is alphanumeric and is usually the hostname
# where the service is running.
# E.g., ceph-mds1.dom, ceph-mds2.dom etc.
daemon_id = mds.split(cluster_name + '-', 1)[1]
process = dict()
process_args = ['--cluster %s' % cluster_name,
'--id %s' % daemon_id, '-f']
process['search_string'] = self._build_search_string(
self.ceph_mds_executable, process_args)
process['name'] = '%s-mds.%s' % (cluster_name, daemon_id)
process['type'] = 'ceph-mds'
expected_processes.append(process)
expected_processes.extend(self._service_config(cluster_name, 'mon'))
expected_processes.extend(self._service_config(cluster_name, 'osd'))
expected_processes.extend(self._service_config(cluster_name, 'mds'))
# RADOS Gateway is little different from other ceph-daemons hence
# the process definition is handled differently
expected_processes.extend(self._radosgw_config(
cluster_name, config_file))
for process in expected_processes:
# Watch the service processes