Howto mimic parsed_section_name behaviour for "interfaces"

Hi,
I wrote an plugin to enumerate unifi devices per unifi-api.
Everything is looking good even with interfaces over piggyback.
When I dont use register.check_plugin and instead use register.agent_section with parsed_section_name=“interfaces” then all interfaces show up with correct Metric translation and dual in/out graphs ans performeter.
if I change in the same way as the vsphere plugin does.

register.check_plugin(
    name='unifi_network_ports_if',
    sections=["unifi_network_ports"],
    service_name='Interface %s',
    discovery_ruleset_name="inventory_if_rules",
    discovery_ruleset_type=register.RuleSetType.ALL,
    discovery_default_parameters=dict(interfaces.DISCOVERY_DEFAULT_PARAMETERS),
    discovery_function=discovery_unifi_network_port_if,
    check_ruleset_name="if",
    check_default_parameters=interfaces.CHECK_DEFAULT_PARAMETERS,
    check_function=check_unifi_network_port_if,
)

then the interfaces still shows up but seems different from before.
Services will be found as new and old as vanished.

I want the check_function to add additional Metrics for PoE and Satisfaction

Any Help?


with parsed_section_name=“interfaces”


with check_plugin

The problem with your own check_plugin is that the graphing system don’t know how the graphing should be drawn. You need to define the graphing also beside the check plugin.
One quick step would be to define for your check an translation of the performance data.

Something like this.

if_translation = {
    "in": {
        "name": "if_in_bps",
        "scale": 8
    },
    "out": {
        "name": "if_out_bps",
        "scale": 8
    },
    "total": {
        "name": "if_total_bps",
        "scale": 8
    },
    "indisc": {
        "name": "if_in_discards"
    },
    "inerr": {
        "name": "if_in_errors"
    },
    "outdisc": {
        "name": "if_out_discards"
    },
    "outerr": {
        "name": "if_out_errors"
    },
    "inmcast": {
        "name": "if_in_mcast"
    },
    "inbcast": {
        "name": "if_in_bcast"
    },
    "outmcast": {
        "name": "if_out_mcast"
    },
    "outbcast": {
        "name": "if_out_bcast"
    },
    "inucast": {
        "name": "if_in_unicast"
    },
    "innucast": {
        "name": "if_in_non_unicast"
    },
    "outucast": {
        "name": "if_out_unicast"
    },
    "outnucast": {
        "name": "if_out_non_unicast"
    },
}

check_metrics["check_mk-your_check_name"] = if_translation
1 Like

Thanks for the quick reply,

that was what i was looking for and as i found fritz and vsphere were allready in translation.py the magic why they behave different was solved.

i ended up using
from cmk.gui.plugins.metrics import translation
check_metrics[“check_mk-unifi_network_ports_if”] = translation.if_translation
as i also inherited the unify_interface from interface.