diff --git a/ceph/agents/plugins/ceph.py b/ceph/agents/plugins/ceph.py index a14dd092..c89d3961 100755 --- a/ceph/agents/plugins/ceph.py +++ b/ceph/agents/plugins/ceph.py @@ -34,7 +34,21 @@ def command_osd(self, osdid, cmd): def command_pg(self, pgid, cmd): return self.pg_command(pgid, json.dumps({'prefix': cmd, 'format': 'json'}), b'', timeout=5) -cluster = RadosCMD(conffile='/etc/ceph/ceph.conf') +ceph_config='/etc/ceph/ceph.conf' +ceph_client='client.admin' +try: + with open(os.path.join(os.environ['MK_CONFDIR'], 'ceph.cfg'), 'r') as config: + for line in config.readlines(): + if '=' in line: + key, value = line.strip().split('=') + if key == 'CONFIG': + ceph_config = value + if key == 'CLIENT': + ceph_client = value +except FileNotFoundError: + pass + +cluster = RadosCMD(conffile=ceph_config, name=ceph_client) cluster.connect() hostname = socket.gethostname().split('.', 1)[0] diff --git a/ceph/agents/plugins/ceph_2.py b/ceph/agents/plugins/ceph_2.py index 91e3d59b..e355a061 100755 --- a/ceph/agents/plugins/ceph_2.py +++ b/ceph/agents/plugins/ceph_2.py @@ -34,7 +34,21 @@ def command_osd(self, osdid, cmd): def command_pg(self, pgid, cmd): return self.pg_command(pgid, json.dumps({'prefix': cmd, 'format': 'json'}), b'', timeout=5) -cluster = RadosCMD(conffile='/etc/ceph/ceph.conf') +ceph_config='/etc/ceph/ceph.conf' +ceph_client='client.admin' +try: + with open(os.path.join(os.environ['MK_CONFDIR'], 'ceph.cfg'), 'r') as config: + for line in config.readlines(): + if '=' in line: + key, value = line.strip().split('=') + if key == 'CONFIG': + ceph_config = value + if key == 'CLIENT': + ceph_client = value +except FileNotFoundError: + pass + +cluster = RadosCMD(conffile=ceph_config, name=ceph_client) cluster.connect() hostname = socket.gethostname().split('.', 1)[0] diff --git a/ceph/ceph-11.19.0.mkp b/ceph/ceph-11.19.0.mkp deleted file mode 100644 index 85727baa..00000000 Binary files a/ceph/ceph-11.19.0.mkp and /dev/null differ diff --git a/ceph/ceph-11.19.1.mkp b/ceph/ceph-11.19.1.mkp new file mode 100644 index 00000000..76667778 Binary files /dev/null and b/ceph/ceph-11.19.1.mkp differ diff --git a/ceph/lib/python3/cmk/base/cee/plugins/bakery/ceph.py b/ceph/lib/python3/cmk/base/cee/plugins/bakery/ceph.py index c4fff360..eb526f7f 100644 --- a/ceph/lib/python3/cmk/base/cee/plugins/bakery/ceph.py +++ b/ceph/lib/python3/cmk/base/cee/plugins/bakery/ceph.py @@ -18,12 +18,22 @@ from pathlib import Path from typing import Any, Dict -from .bakery_api.v1 import FileGenerator, OS, Plugin, register +from .bakery_api.v1 import FileGenerator, OS, Plugin, PluginConfig, register def get_ceph_files(conf: Dict[str, Any]) -> FileGenerator: yield Plugin(base_os=OS.LINUX, source=Path("ceph.py"), - interval=58) + interval=conf['interval']) + config_lines = [] + if 'config' in conf: + config_lines.append('CONFIG=%s' % conf['config']) + if 'client' in conf: + config_lines.append('CLIENT=%s' % conf['client']) + if config_lines: + yield PluginConfig(base_os=OS.LINUX, + lines=config_lines, + target=Path("ceph.cfg"), + include_header=True) register.bakery_plugin( name="ceph", diff --git a/ceph/web/plugins/wato/ceph_cee.py b/ceph/web/plugins/wato/ceph_cee.py index c5322940..1a89c2dc 100644 --- a/ceph/web/plugins/wato/ceph_cee.py +++ b/ceph/web/plugins/wato/ceph_cee.py @@ -23,17 +23,53 @@ ) from cmk.gui.cee.plugins.wato.agent_bakery.rulespecs.utils import RulespecGroupMonitoringAgentsAgentPlugins from cmk.gui.valuespec import ( - DropdownChoice, + Alternative, + Dictionary, + Filename, + TextInput, + Transform, ) + def _transform_agent_config_ceph(p): + if isinstance(p, bool): + if p: + return {'interval': 58} + return None + return p + def _valuespec_agent_config_ceph(): - return DropdownChoice( - title = _("Ceph Status (Linux)"), - help = _("This will deploy the agent plugin ceph for monitoring the status of Ceph. This plugin will be run asynchronously in the background."), - choices = [ - ( True, _("Deploy plugin for Ceph") ), - ( None, _("Do not deploy plugin for Ceph") ), - ] + return Transform( + Alternative( + title = _("Ceph Status (Linux)"), + help = _("This will deploy the agent plugin ceph for monitoring the status of Ceph. This plugin will be run asynchronously in the background."), + style = "dropdown", + elements = [ + Dictionary( + title = _("Deploy plugin for Ceph"), + elements = [ + ( "interval", + Age( + title = _("Run asynchronously"), + label = _("Interval for collecting data from Ceph"), + default_value = 58, + )), + ( "config", + Filename( + title = _("Path to ceph.conf"), + default_value = "/etc/ceph/ceph.conf", + )), + ( "client", + TextInput( + title = _("Client name"), + default_value = "client.admin", + )), + ], + optional_keys = ['config', 'client'], + ), + FixedValue( None, title = _("Do not deploy plugin for Ceph"), totext = _('(disabled)') ), + ], + ), + forth=_transform_agent_config_ceph, ) rulespec_registry.register(