Hey Marius, I did some more adjustments and now I get the parsed values. Here is the code:
from .agent_based_api.v1 import *
def parse_arista_port(string_table):
# print(string_table)
# http://www.circitor.fr/Mibs/Html/E/ENTITY-SENSOR-MIB.php#EntitySensorDataType
# Parse Sensor List into a dict
sensors = {}
for data in string_table[0]:
sensorId = data[0]
sensors[sensorId] = {
"sensorType": data[1],
"sensorScale": data[2],
"sensorPrecision": data[3],
"sensorValue": data[4],
"sensorStatus": data[5],
"sensorUnit": data[6]
}
# http://www.circitor.fr/Mibs/Html/E/ENTITY-MIB.php#PhysicalClass
# http://www.circitor.fr/Mibs/Html/E/ENTITY-MIB.php
# Parse the Ports
parsed = []
for data in string_table[1]:
deviceId = data[0]
device = {
'id': deviceId,
'desc': data[2],
'sensor': sensors.get(deviceId)
}
parsed.append(device)
#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.99.1.1.1',
oids = [
OIDEnd(),
'1', # entPhySensorType
'2', # entPhySensorScale
'3', # entPhySensorPrecision
'4', # entPhySensorValue
'5', # entPhySensorOperStatus
'6', # entPhySensorUnitsDisplay
],
),
SNMPTree(
base = '.1.3.6.1.2.1.47.1.1.1.1',
oids = [
OIDEnd(),
'1', # entPhysicalIndex
'2', # entPhysicalDescr
'3', # entPhysicalVendorType
'4', # entPhysicalContainedIn
'5', # entPhysicalClass
'6', # entPhysicalParentRelPos
],
),
]
)
Here are some examples from the output. I think with that it is possible to write the check plugin or register the check plugin, but I am not sure how to proceed from here.
{'id': '1', 'desc': '48 SFP+ +4 QSFP 10Gb 1RU', 'sensor': None}, {'id': '100004002', 'desc': 'Scd Chip 2', 'sensor': None}, {'id': '100006001', 'desc': 'Cpu temp sensor', 'sensor': { 'sensorType': '8', 'sensorScale': '9', 'sensorPrecision': '1', 'sensorValue': '412', 'sensorStatus': '1', 'sensorUnit': 'Celsius'} },
Regards Kai