You are right there was a change between these versions.
If i look at the old code and the new one i cannot see why it is not working now without further investigation.
Old Code
def perfometer_bandwidth(in_traffic, out_traffic, in_bw, out_bw, unit = "B"):
txt = []
have_bw = True
h = '<table><tr>'
traffic_multiplier = unit == "B" and 1 or 8
for name, bytes, bw, color in [
("in", in_traffic, in_bw, "#0e6"),
("out", out_traffic, out_bw, "#2af") ]:
if bw > 0.0:
rrate = bytes / bw
else:
have_bw = False
break
drate = max(0.02, rrate ** 0.5 ** 0.5)
rperc = 100 * rrate
dperc = 100 * drate
a = perfometer_td(dperc / 2, color)
b = perfometer_td(50 - dperc/2, "#fff")
if name == "in":
h += b + a # white left, color right
else:
h += a + b # color right, white left
txt.append("%.1f%%" % rperc)
if have_bw:
h += '</tr></table>'
return " ".join(txt), h
# make logarithmic perf-o-meter
MB = 1000000.0
text = "%s/s %s/s" % (
number_human_readable(in_traffic * traffic_multiplier, 1, unit), number_human_readable(out_traffic * traffic_multiplier, 1, unit))
return text, perfometer_logarithmic_dual(
in_traffic, "#0e6", out_traffic, "#2af", 1000000, 5)
def perfometer_check_mk_if(row, check_command, perf_data):
unit = "Bit/s" in row["service_plugin_output"] and "Bit" or "B"
return perfometer_bandwidth(
in_traffic = savefloat(perf_data[0][1]),
out_traffic = savefloat(perf_data[5][1]),
in_bw = savefloat(perf_data[0][6]),
out_bw = savefloat(perf_data[5][6]),
unit = unit
)
New Code
def perfometer_bandwidth(in_traffic, out_traffic, in_bw, out_bw, unit = "B"):
traffic_multiplier = 1 if (unit == "B") else 8
# if we do not have bandwith make logarithmic perf-o-meter
if in_bw <= 0.0 or out_bw <= 0.0:
MB = 1000000.0
readable_in = number_human_readable(in_traffic * traffic_multiplier, 1, unit)
readable_out = number_human_readable(out_traffic * traffic_multiplier, 1, unit)
text = "%s/s %s/s" % (readable_in, readable_out)
return text, perfometer_logarithmic_dual(in_traffic, "#0e6", out_traffic, "#2af", MB, 5)
# if we have bandwidth
else:
txt, data = [], []
for name, bytes, bw, color in [("in", in_traffic, in_bw, "#0e6"),
("out", out_traffic, out_bw, "#2af")]:
rrate = bytes / bw
drate = max(0.02, rrate ** 0.5 ** 0.5)
rperc = 100 * rrate
dperc = 100 * drate
a = (dperc/2, color)
b = (50 - dperc/2, "#fff")
txt.append("%.1f%%" % rperc)
if name == "in":
data.extend([b, a]) # white left, color right
else:
data.extend([a, b]) # color right, white left
return " ".join(txt), render_perfometer(data)
def perfometer_check_mk_if(row, check_command, perf_data):
unit = "Bit" if "Bit/s" in row["service_plugin_output"] else "B"
return perfometer_bandwidth(
in_traffic = savefloat(perf_data[0][1]),
out_traffic = savefloat(perf_data[5][1]),
in_bw = savefloat(perf_data[0][6]),
out_bw = savefloat(perf_data[5][6]),
unit = unit
)