Port Negotiation Template

Started by twparker, August 26, 2025, 10:40:28 PM

Previous topic - Next topic

twparker

Hello,

I'm trying to setup a template that collects port negotiation rates on Mikrotik devices. I get the info that I want on physical ports, but I get 0 results on virtual interfaces. I would like to filter out virtual interfaces so DCIs are not being created.

transport = CreateSNMPTransport($node);
if (transport == null)
 return false;
// get the interface name to return as instance-name
vb = SNMPGet(transport, ".1.3.6.1.2.1.31.1.1.1.1." .. $1);
if (vb == null) or (vb == 0)
 return false;
// filter out loopback
if (vb.value == "lo")
 return false;
return %(true, $1, vb.value);


I've tried using contains(vb.value, "vlan") on the bottom statement, but that just breaks the script.

tolimanjo

Could try using the interface type - RouterOS appears to use type 6 (ethernetCsmacd) exclusively for physical interfaces:

interface = $node?.getInterfaceByIndex($1);
if (interface != null) {
    if (interface.ifType == 6)
        return [true, $1, interface.name];
}

twparker

Thanks tolimanjo. That limited it, but it seems that I can't call the variable interface.name for the display name.

tolimanjo

Not sure about the absent interface.name - possibly a version issue?

I've attached screenshots of an example similar to your approach. It worked for me on server version 5.2.x (Debian) against a 6-port MikroTik.