How to create a common DCI for different vendors?

Started by Millenium7, March 10, 2021, 02:57:40 AM

Previous topic - Next topic

Millenium7

We have many different vendors equipment in our network that have different OID's for the same value
I.e. radio frequency on cambium ePMP radio's is a different OID to Ubiquiti AirFiber for example
I have created templates for all the radio's, and they all pull the data for each vendor/model

However I want to have a common DCI for all of them, so that when I run scripts or summary tables I can use a common 'Center Frequency' DCI and not have to create 1 for all the different DCI's
If this makes any sense?
How do I go about that? I'm guessing I have to create another DCI with type Script and then have a script run and find which DCI's exist on that node and use it? But I don't know the correct way to do this without causing potential script errors

Victor Kirhenshtein

I see two options here:

1. Use regular expression for DCI matching in summary table to match all possible OID options. This will work only for summary tables though.

2. Create script DCI that will request correct OID depending on device type. For example:


oid = ".1.3.6.1.2.1.1.1.0";
snmp = $node->createSNMPTransport();
if (snmp == null)
   abort;
return SNMPGetValue(snmp, oid);


You can replace direct OID assignment in first line with actual logic for selecting correct OID.

Best regards,
Victor

Millenium7

#2
Is there a way to either 'discover' if an OID returns a valid result and if so, use it? I.e. that way I can create a 'Wireless - ALL' template that applies to every single radio in our network, and the same DCI applies to them, but it sets the OID correctly (I don't think I want to use a script type DCI though because it would create a lot of unnecessary SNMP polling on every poll)

Alternatively can I again create a 'Wireless - ALL' template and create an additional script type DCI, and it simply checks for which DCI's already exist? Or better yet, detects the device make/model (already do that with specific templates for all the manufacturers/models we use) and then points to the appropriate DCI?

Just not sure how to go about it. My pseudo-code I imagine looking something like this

if DeviceManufacturer == "Ubiquiti" then...
...if DeviceModelType == "AirMAX" then use the value from DCI with OID .1.3.6.1.4.1.41112.1.4.1.1.4.1
...if DeviceModelType == "AirFiber" then use the value from DCI with OID .1.3.6.1.4.1.41112.1.3.1.1.5.1
if DeviceManufacturer == "MikroTik" then...
...if DeviceModelType == "60ghz" then use the value from DCI with OID .1.3.6.1.4.1.14988.1.1.1.8.1.6.1
etc etc


So that way every radio ends up with 2 DCI's
1 with the correctly applied OID from the discovery script for that specific make/model
And another with the name of "Radio (Universal) - Tx Frequency"

Victor Kirhenshtein

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