NetXMS Support Forum

English Support => General Support => Topic started by: squeezypiano on May 20, 2021, 01:51:41 PM

Title: Script execution error
Post by: squeezypiano on May 20, 2021, 01:51:41 PM
Hi,

I have a script execution error since upgrading to 3.8-366.  Is it a problem with the script?

Script (Hook::ConfigurationPoll) execution error: Error 14 in line 2: Function or operation argument is not an object

// remove dynamic interfaces on Mikrotik, e.g. VPN users
if ($node->driver  == "MIKROTIK")
{
  intArray = GetNodeInterfaces($node);
 
  foreach (int : intArray)
  {
    // if the interface is dynamic
    if ((left(int->name, 1) == "<") && (right(int->name, 1) == ">"))
    {
      // delete the interface
      DeleteObject(int);
    }
  }
}


Thanks in advance.
Title: Re: Script execution error
Post by: Filipp Sudanov on May 21, 2021, 05:26:40 PM
The code is correct for nodes. But configuration poll could happen for other objects, e.g. clusters. In that case there is $object variable, but $node is not available.
You can change the 2-nd line to:
if (classof($object) == "Node" && $node->driver  == "MIKROTIK")



Title: Re: Script execution error
Post by: squeezypiano on May 24, 2021, 10:39:04 AM
Thanks, that looks to have sorted it. Strange that script has been running for a year and only broke after the last update.