Hi @kano
I tried to cobble something together. I do not know if it will work.
It queries two SnmpTables. From .1.3.6.1.2.1.47.1.1.1.1
the entPhysicalTable
it gets the ID of the Entity, its description, where its contained in and its type. From the .1.3.6.1.2.1.99.1.1.1
the entPhySensorTable
it gets the Id, type, scale, value, status and unit. Most of those values are numeric, however the following link may help you decode the values.
The parsing function first converts the list of sensors into a dict to simplify the access to sensor data.
Then it loops over the Enties and for each port it tries to find sensors contained within the port. For each port it should return a dict with its id, description and the sensors contained within.
If this works it should give you some sensor data for the ports to work with.
from .agent_based_api.v1 import *
def parse_arista_port(string_table):
print(string_table)
# Parse Sensor List into a dict
sensors = {}
for sensorId, sensorType, sensorScale, sensorValue, sensorStatus, sensorUnit in string_table[1]:
sensors[sensorID] = (sensorType, sensorScale, sensorValue, sensorStatus, sensorUnit)
# Parse the Ports
parsed = []
for portId, portDesc, portContained, portClass in string_table[0]:
if portClass != '10': # not a port
continue
port = {'id': entId, 'desc': entDesc, 'sensors': []}
for sensorId, sensorDesc, sensorContained, sensorClass in string_table[0]:
if portId != sensorContained:
continue
if sensorId not in sensors:
continue
port['sensors'].append(sensors[sensorId])
print(sensors)
print(parsed)
return parsed
register.snmp_section(
name = "arista_port",
detect = startswith(".1.3.6.1.2.1.1.1.0", "Arista"),
parse_function=parse_arista_port,
fetch = [
SNMPTree(
base = '.1.3.6.1.2.1.47.1.1.1.1',
oids = [
OIDEnd(),
'2', # entPhysicalDescr
'4', # entPhysicalContainedIn
'5', # entPhysicalClass
],
),
SNMPTree(
base = '.1.3.6.1.2.1.99.1.1.1',
oids = [
OIDEnd(),
'1', # entPhySensorType
'2', # entPhySensorScale
'4', # entPhySensorValue
'5', # entPhySensorOperStatus
'6', # entPhySensorUnitsDisplay
],
),
]
)
Regards Marius