SNMP Check Switch Interface Alias

I was able to create a new check for the moxa switch. It is basically a copy and paste from the already existing checks if64 and if64_tplink

It is working, but not usable for all moxa switches because the vendor ifAlias ID is different for every switch series (.1.3.6.1.4.1.8691.7.18.1.9.1.1.7 EDS-G509) (.1.3.6.1.4.1.8691.7.7.1.9.1.1.7 EDS-408A)

So for a check to work for all moxa switches it would be necessary to determine the correct OID for the switch inside the check.
Because we only use this two types I just created two checks one for each switch series.

Here is the code, maybe it helps someone elseā€¦

#!/usr/bin/python
# -*- encoding: utf-8; py-indent-offset: 4 -*-

@network_interface_scan_registry.register
def snmp_scan_function_if64_moxa(oid):
return oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.8691.7.18")

def inventory_if64_moxa(info):
return inventory_if_common(info, has_nodeinfo=True)

def check_if64_moxa(item, params, info):
return check_if_common(item, params, info, has_nodeinfo=True)

check_info["if64_moxa_EDS-G509"] = {
'parse_function': parse_if64,
'check_function': check_if64_moxa,
'inventory_function': inventory_if64_moxa,
'service_description': 'Interface %s',
'has_perfdata': True,
'includes': ['if.include'],
'snmp_info': (
    ".1.3.6.1",
    [
        "2.1.2.2.1.1",  # ifIndex                    0
        "2.1.2.2.1.2",  # ifDescr                    1
        "2.1.2.2.1.3",  # ifType                     2
        "2.1.2.2.1.5",  # ifSpeed                    3
        "2.1.2.2.1.8",  # ifOperStatus               4
        "2.1.31.1.1.1.6",  # ifHCInOctets            5
        "2.1.31.1.1.1.7",  # ifHCInUcastPkts         6
        "2.1.31.1.1.1.8",  # ifHCInMulticastPkts     7
        "2.1.31.1.1.1.9",  # ifHCInBroadcastPkts     8
        "2.1.2.2.1.13",  # ifInDiscards              9
        "2.1.2.2.1.14",  # ifInErrors               10
        "2.1.31.1.1.1.10",  # ifHCOutOctets         11
        "2.1.31.1.1.1.11",  # ifHCOutUcastPkts      12
        "2.1.31.1.1.1.12",  # ifHCOutMulticastPkts  13
        "2.1.31.1.1.1.13",  # ifHCOutBroadcastPkts  14
        "2.1.2.2.1.19",  # ifOutDiscards            15
        "2.1.2.2.1.20",  # ifOutErrors              16
        "2.1.2.2.1.21",  # ifOutQLen                17
        "4.1.8691.7.18.1.9.1.1.7",  # ifAlias special for Moxa Switch EDS G509
        BINARY("2.1.2.2.1.6"),  # ifPhysAddress            19
        "2.1.31.1.1.1.15",  # ifHighSpeed              -1  (parse_if64 assumes this is the last element)
    ]),
'snmp_scan_function': snmp_scan_function_if64_moxa,
'group': 'if',
'node_info': True,
'default_levels_variable': 'if_default_levels',
}

Thanks for the quick responses, this solves the problem for my environment :slight_smile: