Exclude one of the Template DCI's from some nodes

Started by Shebarn, May 09, 2019, 01:00:47 PM

Previous topic - Next topic

Shebarn

Good Day.

I have a template with 5 DCI's.
Just a few of the nodes (3 out of 150) does not support the specific OID (Voltage Check) of the DCI (See screenshot attached).

How can I exclude only this one DCI from executing on these nodes?

The other 4 still need to execute and generally I want all the DCI's in the Template.

Thank you in advance and kind regards!

Tursiops

If a DCI is in a template that is applied to a device, then that DCI will be applied to the device.

That leaves you with a couple of options:

  • Hide it from view
  • Move it into a different template

Option 1 could be as simple as right-clicking inside your Last Values tab and unchecking "Show unsupported items". You simply won't see the DCI (or any other unsupported DCI) anymore.

Option 2 could be accomplished by creating another template and using the same auto-apply rule with one minor exception: You add something like this as the first line:
if (ignoreMikrotikVoltage@$node != null) return false;
Then you add a custom attribute called ignoreMicrotikVoltage to the nodes in question and set it to 1, true or whatever. The template will no longer be applied.

You could also add something more complex, e.g. an actual connection to the device to check if that SNMP OID exists. If it doesn't, then don't apply the template. That means you don't have to fiddle around with custom attributes.
That solution would look more like this (again, something you'd add to your existing auto-apply rule):
transport = CreateSNMPTransport($node);
if ( transport == null ) return NULL;
voltageCheck = SNMPGetValue(transport,".1.3.6.1.4.1.14988.1.1.3.8.0");
if ( voltageCheck == null ) return null;
else return true;

You could return false instead of null in line 4, but in this case, null is probably safer.

I'll attempt to explain the difference between return null and return false in this scenario.
Note that all this assumes you have ticked both the "Apply this template automatically..." and "Remove this template automatically..." checkboxes in the Automatic Apply Rules section.
return null means the node will neither be added nor removed to/from the template. If the template is currently applied to the node, it won't be removed. If it is not applied, it won't be added.
return false on the other hand means the node will be removed from the template. As a consequence any DCIs from the template would be removed. All data would be lost.
In situations where an auto-apply rule looks at an immutable feature of a device, return null is usually the safer approach. You are not expecting a device to suddenly lose that feature. For example a Windows system should not suddenly return a Linux OS. If there is some glitch and the device does not return "Windows", you don't want the template to be removed.
In situations where an auto-apply rule looks at something variable, e.g. some software that's installed on a computer which could be removed at any time, you'd want to use return false. That way if the software is uninstalled the template is removed as expected.