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