Set Interface Expected State by Template?

Started by Storm-Donovan, November 08, 2022, 07:51:04 PM

Previous topic - Next topic

Storm-Donovan

Is there a way to set interface expected state by a template?  We use Unifi APs and these things change their interface state as often as I change my underwear it seems.  I would like to set NetXMS so that if the device is a Unifi AP, then all interfaces are automatically set to Ignore for expected state.

I searched the forums and didn't find this situation.  Any help would be much appreciated.

Filipp Sudanov

That's a moment when the scripting kicks in. Simplest is in HOOK::CreateInterface script - it's being called when creating a new interface. E.g. (for Mikrotik, adjust the OID for Unifi AP):

if ($node->snmpOID == ".1.3.6.1.4.1.14988.1") {
  PollerTrace("  Setting " . $1->name . " expected state to ignore"); 
  $1->setExpectedState("IGNORE");
}
return true;

If you return false from the script, the interface won't be created at all.

But for this to work you'd need to delete all interfaces for already created nodes. Alternative approach is to make a script that will loop through all nodes and their interfaces and set expected state - give a note if you need example of such script.



Storm-Donovan

Thanks Filipp, this is perfect.  We've been changing the expected state when alarms come up, so most of the existing ones are done.  I just wanted something so that new ones are done automagically.

Filipp Sudanov

Just to note - PollerTrace line is optional - it just produces debug output when configuration poll is executed manually.