Mikrotik Plugin v2.5.3 fixed mikrotik_power Problems [Solved]

As we implemented the MikroTik Plugin from Exchange made by @ttr we ran in to some Problems with the checks for powerconsumption.

We did get these crash reports:

1 Like

After a bit of changing the Code in the mikrotik_power.py we did get that fixed for the CRS328 Switches.
But we did ran in to another Problem with the RB960PGS and RB760iGS.

So another bit of Coding in the mikrotik_power.py to fix the data we receive from the switches.

We did make these Changes in the “mikrotik_power.py”:

# calc power-consumption if missing
    powerConsumption = 0
    for psu in data:
        if 'power-consumption' not in psu:
            try:
                powerConsumption += data[psu]['current'] * data[psu]['voltage'] / 1000
            except:
                powerConsumption = 0

    data['power-consumption'] = powerConsumption
# power
    if section['power-consumption'] == 0:
        mysummary.append('Voltage: %s V' % round(section['voltage'],2))
    else:
        mysummary.append('Power: %s W' % round(section['power-consumption']))
1 Like

So now we do get two different Summarys:
image

  1. We get the intended Powerconsumption if there is a “voltage” and “current” output from the switch.
  2. We geht the max Voltage.
    This is only given, if there is eighter no “current” given by the switch or the “current” is 0.

Maybe @ttr wants to add this or something similar in the next Version, that more of the different Mikrotik switches are covered with the Plugin without getting Crash Reports.

If you Tom has any questions, feel free to text me.

PS: Sorry for 3 Texts, but as “new Member” i can only put one Mediafile in each Message^^

1 Like

Hi,

Thanks for pointing this out, a bug indeed. Mikrotik API responses are sometimes kinda gambling. I will fix this in future releases and will make it more robust.

Regards,
ttr