Inventory plugin not matching even if detection is disabled (matches all hosts)

Hi there,

on my 2.0.0p15 I try to write an inventory plugin to get all VLANs on a Zyxel switch. For this I copied the inv_cisco_vlan.py file as a base and modified the OIDs.
Now I have something like an inventory check but it seems that my plugin is not used at all.

The plugin:

from .agent_based_api.v1 import (
    contains,
    exists,
    OIDEnd,
    register,
    SNMPTree,
    TableRow,
)

from .agent_based_api.v1.type_defs import (
    InventoryResult,
)

register.snmp_section(
    name = "inv_zyxel_vlans",
    detect=exists(".1.3.6.1.2.1.1.1.0"),
    fetch = [
        SNMPTree(
            base=".1.3.6.1.2.1.17.7.1.4.3.1",
            oids=[
                OIDEnd(),
                "1",  # VlanName
                "5",  # VlanRowStatus
                "4",  # VlanUntaggedPorts
                "2",  # VlanTaggedPorts
            ],
        ),
    ],
)


def inventory_zyxel_vlans(section) -> InventoryResult:
    import pprint;
    pprint.pprint("Section!")
    pprint.pprint(section)
    # print (info)
    return [ (None, None) ]

    path = ["networking", "interfaces"]
    map_vlans = {
        '1': 'static',
        '2': 'dynamic',
        '3': 'multi-VLAN',
    }

    for if_id, vlan_type, vlan_single, vlan_multi in section[0]:
        vlan_readable = map_vlans.get(vlan_type, "")
        vlans = None
        if vlan_single != '0' and vlan_type in ['1', '2']:
            vlans = vlan_single
        elif vlan_type == '3':
            vlans = parse_multi_vlan(vlan_multi)

        if vlans:
            yield TableRow(
                path=path,
                key_columns={"index": int(if_id)},
                inventory_columns={
                    "vlans": vlans,
                    "vlantype": vlan_readable,
                },
            )


register.inventory_plugin(
    name='inv_zyxel_vlans',
    inventory_function=inventory_zyxel_vlans,
)

The commandline for checking:

 cmk -IInv --debug --detect-plugins=inv_zyxel_vlans HOSTNAME

The output is:

Discovering services and host labels on: HOSTNAME
HOSTNAME:
+ FETCHING DATA
[SNMPFetcher] Execute data source
No piggyback files for 'HOSTNAME'. Skip processing.
No piggyback files for '192.168.22.250'. Skip processing.
[PiggybackFetcher] Execute data source
+ PARSE FETCHER RESULTS
Received no piggyback data
+ EXECUTING HOST LABEL DISCOVERY
+ PERFORM HOST LABEL DISCOVERY
+ EXECUTING DISCOVERY PLUGINS (0)
SUCCESS - Found no services, no host labels

I have no idea why this shows no output at all. I also tried with -vv but there is nothing related to my plugin and also no error message.

Can anybody tell me what I am doing wrong?

Kind regards

Sebastian

“-II” is only relevant for check plugins. You need to do a “-i” for HW/SW inventory.
I would also omit the “–detect-plugins” as you need to know if your inventory plugin is found automatically or not.

1 Like

if you want this for Zyxel only you should be more specific here. At the moment this matches more ore less every system.

This will only match Zyxel devices

detect=startswith(".1.3.6.1.2.1.1.2.0", ".1.3.6.1.4.1.890"),`

This OID is not Zyxel specific (dot1qVlanStaticTable), so you might change this to a common vlan addon.

1 Like

Thanks a lot

I knew something was off but I couldnt see it. I will put it on Exchange after finalizing it.

cu

Sebastian

Hi thl-cmk,

I know this is not Zyxel relevant and I will modify the name and purpose to show this. My problem was that the inventory routine was not executed and andreas showed my mistake

Thx

Sebastian