Python Plugin SNMP problem

I am new to checkmk plugin development and trying to modify a script written in latest standarts. Now base snmp oid is following,
.1.3.6.1.4.1.12356.101.14.4.3.1.3
returns

.1.3.6.1.4.1.12356.101.14.4.3.1.3.1.16.70.80.50.50.49.69.53.53.49.57.48.50.55.50.55.57 = "AP01"
.1.3.6.1.4.1.12356.101.14.4.3.1.3.1.16.70.80.50.50.49.69.53.53.49.57.48.50.55.50.56.56 = "AP03"
.1.3.6.1.4.1.12356.101.14.4.3.1.3.1.16.70.80.50.50.49.69.53.53.49.57.48.50.55.51.49.57 = "AP02"
.1.3.6.1.4.1.12356.101.14.4.3.1.3.1.16.70.80.50.50.49.69.53.53.50.49.48.57.57.71.88.74 = "AP05"
.1.3.6.1.4.1.12356.101.14.4.3.1.3.1.16.70.80.50.50.49.69.53.53.50.49.48.57.57.72.48.70 = "AP04"

You see it returns 5 Acess Points and script has a bunch of other oids which returns exactly 5 items per Access Point. Now there is oid, 1.3.6.1.4.1.12356.101.14.4.5.1.9 which returns two results per Access point

.1.3.6.1.4.1.12356.101.14.4.5.1.9.1.16.70.80.50.50.49.69.53.53.49.57.48.50.55.50.55.57.1 = 1
.1.3.6.1.4.1.12356.101.14.4.5.1.9.1.16.70.80.50.50.49.69.53.53.49.57.48.50.55.50.55.57.2 = 1
.1.3.6.1.4.1.12356.101.14.4.5.1.9.1.16.70.80.50.50.49.69.53.53.49.57.48.50.55.50.56.56.1 = 1
.1.3.6.1.4.1.12356.101.14.4.5.1.9.1.16.70.80.50.50.49.69.53.53.49.57.48.50.55.50.56.56.2 = 0
.1.3.6.1.4.1.12356.101.14.4.5.1.9.1.16.70.80.50.50.49.69.53.53.49.57.48.50.55.51.49.57.1 = 1
.1.3.6.1.4.1.12356.101.14.4.5.1.9.1.16.70.80.50.50.49.69.53.53.49.57.48.50.55.51.49.57.2 = 2
.1.3.6.1.4.1.12356.101.14.4.5.1.9.1.16.70.80.50.50.49.69.53.53.50.49.48.57.57.71.88.74.1 = 1
.1.3.6.1.4.1.12356.101.14.4.5.1.9.1.16.70.80.50.50.49.69.53.53.50.49.48.57.57.71.88.74.2 = 0
.1.3.6.1.4.1.12356.101.14.4.5.1.9.1.16.70.80.50.50.49.69.53.53.50.49.48.57.57.72.48.70.1 = 0
.1.3.6.1.4.1.12356.101.14.4.5.1.9.1.16.70.80.50.50.49.69.53.53.50.49.48.57.57.72.48.70.2 = 0

above .1 at the end means ghz 2.4, .2 means 5ghz. Now I am stack and can`t parse this oid because it returns 10 items , 2 per main item. I wish developers of device have putten .1 and .2 right after .9 but they did not )

Parse section:

def parse_fortigate_ap_connection(string_table: List[StringTable]) -> Section:
    pprint.pprint(string_table)
    """
    >>> from pprint import pprint
    >>> pprint(parse_fortigate_ap_connection([
    ... [["a"], ["b"]],
    ... [["1", "0"], ["2", "5"]],
    ... ]))
    {'a': AccessPoint(connection_state=ConnectionState(status='offLine', description='The WTP is not connected.'), station_count=0),
     'b': AccessPoint(connection_state=ConnectionState(status='onLine', description='The WTP is connected.'), station_count=5)}
    """
    return {
        wtp_name: AccessPoint(
            ConnectionState(*_CONN_STATE_TO_READABLE[connection_state]),
            int(station_count),
            hwid,
            
        )
        for (wtp_name,), (
            connection_state,
            station_count,
            hwid,
        ) in zip(*string_table)
    }

An example plugin also can help

So, I have to give up on this? or there is a possible way?

It is important to know how your “fetch” part inside the snmp section definition looks like.
In your case it is important to fetch also the “OIDEnd” to identify data that belongs together.

Your pprint example shows only the two lists of single and double elements.

With the OIDEnd i would build a dictionary with this value as the key.

Oh, so there is somthing called OIDEnd? I believe I need just it

You know example script used it? documentation does not explain that part.

The Aruba WLC clients check also uses the function to convert the hex OIDEnd to readable ASCII if possible.

The next example is more complex with two trees and then a merged parsed section.

So this OIDEnd, just gives me the all walked index`s on output? and Still need to some how parse it myself? it would be best if we can also add object identified at the end. Like above some oids returns list with .1, .2, .3 and the end. So like first walk all then grep only .1 or .2 at the end. I think OIDEnd does first part and now I need to grep things I want.

thank you @andreas-doehler this helped me to achieve what I want.

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.