Hello,
i would like to develop an MKP to extend the GUI.
Specifically, I would like to include a livestatus column in a view that is not yet usable. (Checkmk Managed Services Edition 2.2.0p20)
But I’m having trouble getting this to work.
From what I could find in the Github repo and looking at other MKPs, I know I need to create a painter.
This painter I can then use in a view in the “painters” section.
But I have no idea where I should put/create the painter so that the code will run.
Is there some sort of overview where to put code in checkmk, so it gets run correctly?
My code so far:
custom_painter.py:
from cmk.gui.view_utils import CellSpec
from cmk.gui.views import Icon, icon_and_action_registry, painter_registry, multisite_builtin_views, \
builtin_views
from cmk.gui.views.painter.v0.base import Cell, Painter
class PainterHgNumServicesUnhandledProblems(Painter):
@property
def ident(self) -> str:
return "hg_num_services_unhandled_problems"
def title(self, cell: Cell) -> str:
return _("Number of unhandled problems")
def short_title(self, cell: Cell) -> str:
return _("Problems")
@property
def columns(self) -> Sequence[ColumnName]:
return ["hostgroup_num_services_unhandled_problems"]
def render(self, row: Row, cell: Cell) -> CellSpec:
return paint_svc_count(2, row["hostgroup_num_services_unhandled_problems"])
painter_registry.register(PainterHgNumServicesUnhandledProblems)
painters section in view:
'painters': [{'name': 'hg_name', 'parameters': {}, 'link_spec': None, 'tooltip': None, 'join_value': None, 'column_title': 'Col1', 'column_type': 'column'},
{'name': 'hg_num_services_unhandled_problems', 'parameters': {}, 'link_spec': None, 'tooltip': None, 'join_value': None, 'column_title': 'Col2', 'column_type': 'column'}],