Custom gui acknowlege command not working

I need some guidance on developing a custom acknowledge button in cmk gui to create a ticket in BMC/Remedy and acknowledge a host or service problem with the ticket number.

The feature should be migrated from a cmk 1.6 instance to a 2.3.0p42.cee.
It is working in cmk 1.6 and looks like this in the gui (Acknowledge with Ticket):

I put this into folder local/lib/python3/cmk/gui/plugins/views/commands/bmc_remedy_ack.py

#!/usr/bin/env python3
# -*- encoding: utf-8; py-indent-offset: 4 -*-
import suds,  ssl
from suds.client import Client

import cmk.gui.views.command as commands

import time
import livestatus

from cmk.gui.log import logger

import cmk.gui.config as config
import cmk.gui.utils as utils
import cmk.gui.bi as bi
import cmk.gui.sites as sites
from cmk.gui.i18n import _, _l, _u, ungettext
from cmk.gui.htmllib.html import html
from cmk.gui.exceptions import MKUserError
from cmk.gui.valuespec import Age
from cmk.gui.utils.speaklater import LazyString
from typing import Any, Literal, Protocol

from cmk.gui.permissions import (
    Permission,
    PermissionSection,
    PermissionRegistry,
    PermissionSectionRegistry,
)

from cmk.gui.views.command import (
    command_group_registry,
    CommandGroup,
    command_registry,
    Command,
    CommandActionResult,
    PermissionSectionAction,
)

PermissionActionAcknowledgeWithTicket = Permission(
    section=PermissionSectionAction,
    name="acknowledge_inc",
    title=_l("Acknowledge with Ticket"),
    description=_l("Acknowledge with Ticket host and service problems and remove acknowledgements"),
    defaults=["user", "admin"],
)


@command_registry.register
class CommandAcknowledgeWithTicket(commands.Command):
    @property
    def ident(self):
        return "acknowledge_inc"

    @property
    def title(self):
        return _("Acknowledge with Ticket")

    @property
    def confirm_title(self) -> str:
        return _("Acknowledge problems?")

    @property
    def confirm_button(self) -> LazyString:
        return _l("Yes, acknowledge")

    @property
    def cancel_button(self) -> LazyString:
        return _l("No, discard")

    @property
    def deny_button(self) -> LazyString | None:
        return _l("No, adjust settings")

    @property
    def deny_js_function(self) -> str | None:
        return '() => cmk.page_menu.toggle_popup("popup_command_acknowledge")'

    @property
    def icon_name(self):
        return "ack"

    @property
    def is_shortcut(self) -> bool:
        return True

    @property
    def is_suggested(self) -> bool:
        return True

    @property
    def permission(self) -> Permission:
        return PermissionActionAcknowledgeWithTicket

    @property
    def group(self) -> type[CommandGroup]:
        return CommandGroupAcknowledge

    @property
    def tables(self):
        return ["host", "service", "aggr"]


    def render(self, what):
        submit_id = "_acknowledge"
        html.open_div(class_="group buttons")
        html.button(
            submit_id,
            _("Acknowledge INC"),
            cssclass="hot disabled",
        )
        html.close_div()

#        html.hr()
#        html.button("_acknowledge_inc", _("Acknowledge INC"))

    def _action(self, cmdtag: Literal["HOST", "SVC"], spec, row, row_index, num_rows) -> CommandActionResult:
        if "aggr_tree" in row:  # BI mode
.
.
.
.


The code will be executed, but there appears no additional ack command in gui.

In web.log there is no error. I have no idea what is missing here and how to get this working with cmk version 2.3 and also in 2.4 in the future.

Is something additional needed to get it working?
Should the file be in another location/folder?

Any hint is welcome :wink:

evtl hilft dir das hier:

ist zwar für ServiceNow geht aber in ein ähnliche Richtung

Gruß Bernd

Hilft in meinem Fall leider nicht weiter.

Hi @SuperChecker,
hab mir das nochmal angeschaut und hier meine Gedanken dazu:

du hast zwei Probleme, wobei eines möglicherweise die Hauptursache ist:

Problem 1 — Falsche Dateispeicherort
Die Datei befindet sich in local/lib/python3/cmk/gui/plugins/views/commands/ — das ist der interne Checkmk-Namespace-Pfad, nicht das korrekte Erweiterungsverzeichnis. Für GUI-View-Command-Plugins in Checkmk 2.x ist der richtige Pfad:

local/share/check_mk/web/plugins/views/bmc_remedy_ack.py

Danach Apache neu starten: omd restart apache oder Komplett omd restart

Problem 2 — Permission-Objekt wurde nie registriert
Du erstellst das Permission-Objekt, registrierst es aber nie in der Permission-Registry. Checkmk 2.3 verwirft stillschweigend jeden Command, dessen Permission nicht registriert ist — kein Fehler in web.log, der Button erscheint einfach nicht.

Füge dies nach der Erstellung des Permission-Objekts hinzu:

from cmk.gui.permissions import permission_registry

PermissionActionAcknowledgeWithTicket = Permission(
    section=PermissionSectionAction,
    name="acknowledge_inc",
    title=_l("Acknowledge with Ticket"),
    description=_l("..."),
    defaults=["user", "admin"],
)

# Diese Zeile fehlte:
permission_registry.register(PermissionActionAcknowledgeWithTicket)

Zum Debuggen: grep -i "bmc_remedy\|acknowledge_inc" ~/var/log/web.log ausführen, nachdem du die Datei am richtigen Ort platziert und Apache neu gestartet hast.

Happy Monday … !!!

leider hat das registrieren auch nix gebracht.

Es wird noch immer kein html Inhalt angezeigt im Webgui.