Hi,
you could choose OID right before doing actual SNMP request in script DCI - so no extra SNMP requests will be done. Like this:
switch($node->vendor)
{
case "Mikrotik":
switch($node->productName)
{
case "60ghz": oid = ".1.3.6.1.4.1.14988.1.1.1.8.1.6.1";
}
break;
case "Ubiquity":
switch($node->productName)
{
case "AirMAX": oid = ".1.3.6.1.4.1.41112.1.4.1.1.4.1";
case "AirFiber": oid = ".1.3.6.1.4.1.41112.1.3.1.1.5.1";
}
break;
}
if (oid == null)
return null; // OID was not selected, null will mark DCI as unsupported
snmp = $node->createSNMPTransport();
if (snmp == null)
abort;
return SNMPGetValue(snmp, oid);
This of course relies on correctly set vendor and product name values. This should be the case for Mikrotik devices, but may not be for Ubiquity - you should double check.
Alternative approach could be probing for different OIDs in configuration poll hook andd setting correct OID as node's custom attribute, and then use it in script DCI. For example:
HOOK::ConfigurationPoll:
oids = %( ".1.3.6.1.4.1.41112.1.4.1.1.4.1", ".1.3.6.1.4.1.41112.1.3.1.1.5.1", ".1.3.6.1.4.1.14988.1.1.1.8.1.6.1" );
snmp = $node->createSNMPTransport();
if (snmp != null)
{
for(oid : oids)
{
if (SNMPGetValue(snmp, oid) != null) // You may use more sophisticated checks here if needed
{
selectedOID = oid;
break;
}
}
}
SetCustomAttribute($node, "WirelessCenterFrequencyOID", selectedOID);
and script DCI:
oid = GetCustomAttribute($node, "WirelessCenterFrequencyOID");
if (oid == null)
return null; // No OID selected, mark as unsupported
snmp = $node->createSNMPTransport();
if (snmp == null)
abort;
return SNMPGetValue(snmp, oid);
Best regards,
Victor