Strangely it works if I move the “0” OID from the beginning to the end:
register.snmp_section(
name = "rzp_data",
detect = contains(".1.3.6.1.2.1.1.1.0", "RZ-Products GmbH, DCM Agent"), # sysDescr
fetch = SNMPTree(
base = '.1.3.6.1.3.1.0',
oids = [
# '0', # does not work, leads to [snmp] IndexError('list index out of range')(!!), Got no information from host(!!)
'2', # firePre
'3', # fireMain
'4', # ups
'5', # coolLeft
'6', # coolRight
'7', # pump
'16', # powerA
'17', # powerB
'20', # temp
'21', # humid
'0', # doorOpen
],
),
parse_function = parse_rzp_data,
)
We do have the enterprise edition but no support contract. It seems to be a bug, but I can live with it as long as the plugin is working as expected.
If any other newbie (like me) is interested here’s the whole py-file again (although it contains many copy/paste, which for sure can be improved when knowing the syntax better than me):
from .agent_based_api.v1 import *
def check_fire_pre(section):
fire_pre = int(section["fire_pre"])
if(fire_pre != 1):
yield Result(state=State.CRIT, summary="Brandfrüherkennung Voralarm hat ausgelöst")
else:
yield Result(state=State.OK, summary="Brandfrüherkennung Voralarm ist nicht aktiv")
def check_fire_main(section):
fire_main = int(section["fire_main"])
if(fire_main != 1):
yield Result(state=State.CRIT, summary="Brandfrüherkennung Hauptalarm hat ausgelöst")
else:
yield Result(state=State.OK, summary="Brandfrüherkennung Hauptalarm ist nicht aktiv")
def check_ups(section):
ups = int(section["ups"])
if(ups != 1):
yield Result(state=State.CRIT, summary="USV ist gestört")
else:
yield Result(state=State.OK, summary="USV ist nicht gestört")
def check_cool_left(section):
cool_left = int(section["cool_left"])
if(cool_left != 1):
yield Result(state=State.CRIT, summary="Klimagerät 1 (links) ist gestört")
else:
yield Result(state=State.OK, summary="Klimagerät 1 (links) ist nicht gestört")
def check_cool_right(section):
cool_right = int(section["cool_right"])
if(cool_right != 1):
yield Result(state=State.CRIT, summary="Klimagerät 2 (rechts) ist gestört")
else:
yield Result(state=State.OK, summary="Klimagerät 2 (rechts) ist nicht gestört")
def check_pump(section):
pump = int(section["pump"])
if(pump != 1):
yield Result(state=State.CRIT, summary="Kondensatpumpe ist gestört")
else:
yield Result(state=State.OK, summary="Kondensatpumpe ist nicht gestört")
def check_power_a(section):
power_a = int(section["power_a"])
if(power_a != 1):
yield Result(state=State.CRIT, summary="Netzteil A ist gestört")
else:
yield Result(state=State.OK, summary="Netzteil A ist nicht gestört")
def check_power_b(section):
power_b = int(section["power_b"])
if(power_b != 1):
yield Result(state=State.CRIT, summary="Netzteil B ist gestört")
else:
yield Result(state=State.OK, summary="Netzteil B ist nicht gestört")
def check_temp(section):
temp = float(section["temp"])
minTemp = 1 # minimum temperature possible
maxTemp = 50 # maximum temperature possible
warnHigh = 30 # warn if temperature is equal to or higher than this value
critHigh = 33 # alarm if temperature is equal to or higher than this value
warnLow = 19 # warn if temperature is equal to or lower than this value
critLow = 15 # alarm if temperature is equal to or lower than this value
yield Metric("Temperatur", temp, levels=(warnHigh, critHigh), boundaries=(minTemp, maxTemp))
if(temp >= critHigh):
yield Result(state=State.CRIT, summary=f"Temperatur ist zu hoch: {temp} °C")
elif(temp >= warnHigh):
yield Result(state=State.WARN, summary=f"Temperatur ist leicht erhöht: {temp} °C")
elif(temp <= critLow):
yield Result(state=State.CRIT, summary=f"Temperatur ist zu niedrig: {temp} °C")
elif(temp <= warnLow):
yield Result(state=State.WARN, summary=f"Temperatur ist etwas zu niedrig: {temp} °C")
else:
yield Result(state=State.OK, summary=f"Temperatur ist normal: {temp} °C")
def check_humid(section):
humid = float(section["humid"])
minHumid = 1 # minimum humidity possible
maxHumid = 100 # maximum humidity possible
warnHigh = 55 # warn if humidity is equal to or higher than this value
critHigh = 65 # alarm if humidity is equal to or higher than this value
warnLow = 24 # warn if humidity is equal to or lower than this value
critLow = 19 # alarm if humidity is equal to or lower than this value
yield Metric("Luftfeuchtigkeit", humid, levels=(warnHigh, critHigh), boundaries=(minHumid, maxHumid))
if(humid >= critHigh):
yield Result(state=State.CRIT, summary=f"Luftfeuchtigkeit ist zu hoch: {humid} %")
elif(humid >= warnHigh):
yield Result(state=State.WARN, summary=f"Luftfeuchtigkeit ist leicht erhöht: {humid} %")
elif(humid <= critLow):
yield Result(state=State.CRIT, summary=f"Luftfeuchtigkeit ist zu niedrig: {humid} %")
elif(humid <= warnLow):
yield Result(state=State.WARN, summary=f"Luftfeuchtigkeit ist etwas zu niedrig: {humid} %")
else:
yield Result(state=State.OK, summary=f"Luftfeuchtigkeit ist normal: {humid} %")
def check_door_open(section):
door_open = int(section["door_open"])
if(door_open != 1):
yield Result(state=State.CRIT, summary="Türen sind offen, Löschanlage ist blockiert")
else:
yield Result(state=State.OK, summary="Türen sind geschlossen, Löschanlage ist aktiv")
def discover_generic(section):
yield Service()
register.check_plugin(
name = "rzp_fire_pre",
sections = ['rzp_data'],
service_name = "Brandfrüherkennung Voralarm",
discovery_function = discover_generic,
check_function = check_fire_pre,
)
register.check_plugin(
name = "rzp_fire_main",
sections = ['rzp_data'],
service_name = "Brandfrüherkennung Hauptalarm",
discovery_function = discover_generic,
check_function = check_fire_main,
)
register.check_plugin(
name = "rzp_ups",
sections = ['rzp_data'],
service_name = "USV",
discovery_function = discover_generic,
check_function = check_ups,
)
register.check_plugin(
name = "rzp_cool_left",
sections = ['rzp_data'],
service_name = "Klimagerät 1 (links)",
discovery_function = discover_generic,
check_function = check_cool_left,
)
register.check_plugin(
name = "rzp_cool_right",
sections = ['rzp_data'],
service_name = "Klimagerät 2 (rechts)",
discovery_function = discover_generic,
check_function = check_cool_right,
)
register.check_plugin(
name = "rzp_pump",
sections = ['rzp_data'],
service_name = "Kondensatpumpe",
discovery_function = discover_generic,
check_function = check_pump,
)
register.check_plugin(
name = "rzp_power_a",
sections = ['rzp_data'],
service_name = "Netzteil A",
discovery_function = discover_generic,
check_function = check_power_a,
)
register.check_plugin(
name = "rzp_power_b",
sections = ['rzp_data'],
service_name = "Netzteil B",
discovery_function = discover_generic,
check_function = check_power_b,
)
register.check_plugin(
name = "rzp_temp",
sections = ['rzp_data'],
service_name = "Temperatur",
discovery_function = discover_generic,
check_function = check_temp,
)
register.check_plugin(
name = "rzp_humid",
sections = ['rzp_data'],
service_name = "rel. Luftfeuchtigkeit",
discovery_function = discover_generic,
check_function = check_humid,
)
register.check_plugin(
name = "rzp_door_open",
sections = ['rzp_data'],
service_name = "Tür(en) offen, Löschanlage blockiert",
discovery_function = discover_generic,
check_function = check_door_open,
)
def parse_rzp_data(string_table):
section = {}
section["fire_pre"] = string_table[0][0]
section["fire_main"] = string_table[0][1]
section["ups"] = string_table[0][2]
section["cool_left"] = string_table[0][3]
section["cool_right"] = string_table[0][4]
section["pump"] = string_table[0][5]
section["power_a"] = string_table[0][6]
section["power_b"] = string_table[0][7]
section["temp"] = string_table[0][8]
section["humid"] = string_table[0][9]
section["door_open"] = string_table[0][10]
return section
register.snmp_section(
name = "rzp_data",
detect = contains(".1.3.6.1.2.1.1.1.0", "RZ-Products GmbH, DCM Agent"), # sysDescr
fetch = SNMPTree(
base = '.1.3.6.1.3.1.0',
oids = [
# '0', # does not work, leads to [snmp] IndexError('list index out of range')(!!), Got no information from host(!!)
'2', # firePre
'3', # fireMain
'4', # ups
'5', # coolLeft
'6', # coolRight
'7', # pump
'16', # powerA
'17', # powerB
'20', # temp
'21', # humid
'0', # doorOpen
],
),
parse_function = parse_rzp_data,
)
@ thl-cmk Thank you again for your great support!