Instance Discovery (Port Admin State, Port OperState)

Started by mike, August 16, 2016, 03:47:42 PM

Previous topic - Next topic

mike

Hi,

I tried to get a List of my Ports. The DCI should give me the operState. But just for Port with Admin = up.

This is what i tried:

dci Name: Port {instance-name}
SNMP OID: .1.3.6.1.2.1.2.2.1.8.{instance}

Base OID: .1.3.6.1.2.1.2.2.1.8

snmp = CreateSNMPTransport($node);

value = SNMPGetValue(snmp, ".1.3.6.1.2.1.2.2.1.8." . $1);
nam = SNMPGetValue(snmp, ".1.3.6.1.2.1.31.1.1.1.18." . $1);
adm = SNMPGet(snmp, ".1.3.6.1.2.1.2.2.1.7." . $1);

if (value != null && value != 0 && nam != null && adm->value == 1)
                return %(true, value, nam);
else return false;




Victor Kirhenshtein

Hi,

you are using undefined variable "transport" here:


adm = SNMPGet(transport, ".1.3.6.1.2.1.2.2.1.7." . $1);


Best regards,
Victor

mike

hi, thanks for reply.
Unfortunately this was a mistake while writing the post.

This is my last version:

snmp = CreateSNMPTransport($node);

oper = SNMPGetValue(snmp, ".1.3.6.1.2.1.2.2.1.8." . $1);
nam = SNMPGetValue(snmp, ".1.3.6.1.2.1.31.1.1.1.18." . $1);
adm = SNMPGetValue(snmp, ".1.3.6.1.2.1.2.2.1.7." . $1);
dec = SNMPGetValue(snmp, ".1.3.6.1.2.1.31.1.1.1.1." . $1);

if (oper != null && oper != 0 && nam != null && adm == 1)
      return %(true, oper, dec . " - " . nam);
else return false;



/edit:
I saw that i corrected my mistake 3 seconds before your post. I was a bit too late :)

Victor Kirhenshtein

One (or two) issues here. First of all, ensure that you are using "SNMP walk - OIDs" as discovery method (because you want instance to be interface index). Alternatively, you can change base OID to return interfaces indexes as values.
And most important, you replace original instance value with interface operational state:


return %(true, oper, dec . " - " . nam);


effectively reducing all instances into few. Correct will be to keep interface index as instance:\


return %(true, $1, dec . " - " . nam);


Best regards,
Victor

mike

Thank you, the "$1" solved the Problem. I attached my configuration in case someone is interested.

Is there a chance to check for just the first (or any) part of the description name? I have many ports named "Test_xxx". It would be nice to search for "Test" in the first 4 letters and exclude them too.

tomaskir

Simply do a regex compariston

if (someVar ~= "Test_.*") {
  println("Its a test interface!");
}

mike