NetXMS Support Forum

English Support => General Support => Topic started by: Storm-Donovan on November 08, 2022, 07:51:04 PM

Title: Set Interface Expected State by Template?
Post by: Storm-Donovan on November 08, 2022, 07:51:04 PM
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.
Title: Re: Set Interface Expected State by Template?
Post by: Filipp Sudanov on November 09, 2022, 05:27:11 PM
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.


Title: Re: Set Interface Expected State by Template?
Post by: Storm-Donovan on November 09, 2022, 07:48:41 PM
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.
Title: Re: Set Interface Expected State by Template?
Post by: Filipp Sudanov on November 10, 2022, 02:34:28 PM
Just to note - PollerTrace line is optional - it just produces debug output when configuration poll is executed manually.