Octet conversion trouble

I am working on a plugin for some nokia 9500MPR microwave systems. I’m sure I’m just missing something but the input/output octets is a counter64 so it is just feeding raw octet counter. I have that pushing into checkmk as a metric and then in the local/share/check_mk/web/plugins/metrics directory I have created a .py file to place both the in and out counters together making a bandwidth graph but I seem to be missing something to get the octets to convert to a human readable bits/s kind of number. i have tried several of the units provided by check mk but the numbers just don’t look right. thoughts?

from cmk.gui.plugins.metrics import metric_info

metric_info["nokia_inbound_octets"] = {
    "title": "input bandwidth",
    "unit": "bits/s",
    "color": "15/a",
}

metric_info["nokia_outbound_octets"] = {
    "title": "output bandwidth",
    "unit": "bits/s",
    "color": "24/a",
}

graph_info["nokia_Bandwidth"] = {
    "title": "Bandwidth",
    "metrics": [
        ("nokia_inbound_octets", "area"),
        ("nokia_outbound_octets", "area"),
    ],
}

do you have a sample to show what you mean by “don’t look right”?

apologies I should have included more information.

here is just the snmpbulkwalk from the linux cli:

snmpbulkwalk -v2c -c <community> <ipaddress> .1.3.6.1.4.1.637.54.1.25.4.9.1.1
iso.3.6.1.4.1.637.54.1.25.4.9.1.1.50122 = Counter64: 0
iso.3.6.1.4.1.637.54.1.25.4.9.1.1.70105 = Counter64: 0
iso.3.6.1.4.1.637.54.1.25.4.9.1.1.70301 = Counter64: 16964338046694
iso.3.6.1.4.1.637.54.1.25.4.9.1.1.70302 = Counter64: 5026114425735
iso.3.6.1.4.1.637.54.1.25.4.9.1.1.70303 = Counter64: 363058367215795
iso.3.6.1.4.1.637.54.1.25.4.9.1.1.70304 = Counter64: 227470355119356
iso.3.6.1.4.1.637.54.1.25.4.9.1.1.70405 = Counter64: 227470355119356
iso.3.6.1.4.1.637.54.1.25.4.9.1.1.70406 = Counter64: 227470355119356
iso.3.6.1.4.1.637.54.1.25.4.9.1.1.70407 = Counter64: 227470355119356
iso.3.6.1.4.1.637.54.1.25.4.9.1.1.70408 = Counter64: 227470355119356

and then of course I am pumping that into a metric like so:

yield Metric("nokia_inbound_octets", int(x[9]))

Then you see how I am using the unit above and then on the graph it comes our like so:

Do you convert this to bits/s or do you just pass the counter along? I guess you should have a look at the “get_rate” function in the plugin API.

1 Like

Ok that makes a lot of sense based on how speed is calculated with the octets. I did some implamentation using that function but I still must be understanding something incorrect cause the numbers are not lining up when i look at both ends of a connection.

here is the plugin code where i am using the function suggested.

def check_nokia_9500(item, section):
    for x in section:
        if item == "Interface " + x[1] + " " + x[0][2:3] + "/" + x[0][3:5]:
            now = time.time()

            value_store = get_value_store()

            try:
                inputvalue = get_rate(value_store, 'nokia_inbound_octets', now, float(x[9]), raise_overflow=False)
            except GetRateError:
                inputvalue = 0
            try:
                outboundvalue = get_rate(value_store, 'nokia_outbound_octets', now, float(x[10]), raise_overflow=False)
            except GetRateError:
                outboundvalue = 0

            yield Metric("nokia_inbound_octets", float(inputvalue))
            yield Metric("nokia_outbound_octets", float(outboundvalue))

            yield Result(state = State.OK, summary = "[" + x[1] + "], Speed: " + render.nicspeed(int(x[3]) / 10))
            return
        elif item == "Interface " + x[0]:
            yield Result(state = State.OK, summary = "[" + x[1] + "], Speed: " + render.nicspeed(int(x[3]) / 10))
            return

I was hoping now with the new calculated value that is being put into the “yield metric” I would just be able to apply the “bits/s” unit in the metric file but that isn’t coming out with the right numbers. Is there a calculation I am missing? or maybe I’m not doing the get_rate correctly and so the data I’m putting in isn’t correct?

The code don’t look bad.
So the questions are

  • how has the output changed?
  • in what unit are your input data (i mean the Counter64 form the SNMP)? Are this Bits, Bytes, Octets?

The original value is supposed to be octets. Here is an example of a reading where this went in 16998667560342 and after the get_rate returned this 342277.02682026796

This looks ok.

342277 Octets per second → arroud 2.6MBit/s. You need to convert this in to Bits per second before the yield Metric. Or you can also convert the input values from Octets to Bits. I asume one Octet eq eight Bits

on the get_rate

            try:
                inputvalue = get_rate(value_store, 'nokia_inbound_octets', now, float(x[9]) * 8, raise_overflow=False)
            except GetRateError:
                inputvalue = 0
            try:
                outboundvalue = get_rate(value_store, 'nokia_outbound_octets', now, float(x[10]) * 8, raise_overflow=False)
            except GetRateError:
                outboundvalue = 0

or on the yield Metric

            yield Metric("nokia_inbound_octets", float(inputvalue) * 8)
            yield Metric("nokia_outbound_octets", float(outboundvalue) * 8)

well, I feel silly I didn’t remember that conversion. Now that we are converting the numbers look very much in line with the other side of the link. very much appreciate your help.