ARISTA Switch SNMP Checks

Hi @kano

This was only the first part of the process. Basically the data gathering and parsing. In the same file you now need to define a check_plugin. The discovery_function is called with the list returned from the parsinf function and sould yield a Service object for each service which should be discovered. The check_function is then called with the list returned from the parsinf function and the item from the yielded Service in the discovery. This function should yield one or more `Results Checkmk will combine the texts of all and take the worst state. Something along those lines could work.

def discovery_arista_port(section):
    for device in section:
        yield Service(item=device['desc'])


def check_arista_port(item, section):
    for device in section:
        if device['desc'] != item:
            continue

        if device['sensor']:
            yield Result(state=State.OK, summary='%s %s' % (device['sensor']['sensorValue'], device['sensor']['sensorUnit']))
        else:
            yield Result(state=State.WARN, summary='No sensor found')


register.check_plugin(
    name='arista_port',
    service_name='Port %s',
    discovery_function=discovery_arista_port,
    check_function=check_arista_port,
)

In the parse_arista_port function you may should take EntitySensorPrecision into consideration. In the example output for the Cpu temp sensor the precision of 1 mean the valuer of 412 needs to be divided by 10. Its 41.2°C. The following code would probably handle this case.

value = int(data[4])
precision = int(data[3])

if precision > 0:
    value = value / (10**precision)

Regards Marius

1 Like