Hello Community
This might be a question for the more experienced users and “modders” of checkmk, but anyone else is welcome to share their knowledge.
I have developed some kind of extension to our checkmk site to (beside some ther stuff) give our users an easy and comfortable opportunity to create a kind of statusbased newsletter and subscribe to them.
Currently this add-on is written in PHP and is more an “add-beside” like NagVis is. That is in some aspects very annoying. So i decided to give it a rebuild using python and the cmk-libraries to really integrate into checkmk.
Browsing through the sources and taking a look in different classes and aspects it seems that it might be the best way to implement the Page class and link it from within the site.
So i wrote a simple “hello world”-page for proof-of-concept
Show file: page_hello_world.py
#!/usr/bin/env python3
from cmk.gui.pages import Page, PageRegistry
from cmk.gui.htmllib.html import html
class PageHelloWorld(Page):
def _title(self) -> str:
return "Hello World Test"
def __init__(self) -> None:
super().__init__()
def page(self) -> None:
html.open_div(id_="test-page")
html.h1("Hello World")
html.span("Nice to see you.")
html.close_div()
def register(page_registry: PageRegistry) -> None:
page_registry.register_page("hello_world")(PageHelloWorld)
placed it at
~/local/lib/python3/cmk/gui/page_hello_world.py
and tried to acces it via
https://<server>/<site>/check_mk/index.py?start_url=%2F<site>%2Fcheck_mk%2Fhello_world.py
but had no success.
I moved the class around through different folders on the server, changed ownership from site-user to root, played around with the file permissions - but i can’t get any further than getting a red box telling me “This page was not found. Sorry.”
It seems my page or the python-file must be registered somewhere somehow - but i don’t know how. I really don’t want to edit the files outside the local folder to be secure to upcoming updates.
Here i am stuck. ![]()
Maybe there is at least one member of this community having a good clue or even the knowledge of how to achieve the goal. In the best case scenario, someone from the development team will read along.
I would be happy about any hint, no matter how small.
Thanks in advance and best wishes
Klaus
PS: May be the registration function of my file has to be called from somewhere or it has to be a PageRegistry.register(...) like call… ![]()