NetXMS Support Forum

English Support => General Support => Topic started by: Storm-Donovan on June 01, 2021, 12:07:11 AM

Title: Script errors, but works?
Post by: Storm-Donovan on June 01, 2021, 12:07:11 AM
The following script is erroring, but it's working.  So I'm not sure what's wrong.  I'm not very good at scripting, can anyone help out? Thanks!

Quoteif (($node->snmpSysName != null) && ($node->snmpSysName != "") && (($node->driver == "MIKROTIK") || ($node->driver ~= "CAMBIUM")))
{
   RenameObject($node, $node->snmpSysName);
}

Here's the error:

QuoteScript (Hook::ConfigurationPoll) execution error: Error 14 in line 8: Function or operation argument is not an object
Title: Re: Script errors, but works?
Post by: Storm-Donovan on June 01, 2021, 12:14:59 AM
Never mind, I figured it out.  It was erroring on a device that was misconfigured to not poll SNMP.
Title: Re: Script errors, but works?
Post by: Storm-Donovan on June 01, 2021, 12:20:18 AM
No, it's still erroring.  It only errors on the netxms server node.
Title: Re: Script errors, but works?
Post by: Zebble on June 01, 2021, 03:28:14 AM
Check this thread:

https://www.netxms.org/forum/general-support/script-execution-error/ (https://www.netxms.org/forum/general-support/script-execution-error/)
Title: Re: Script errors, but works?
Post by: Storm-Donovan on June 01, 2021, 03:00:29 PM
Thanks, but that didn't fix it.  It's erroring on the NetXMS server node.
Title: Re: Script errors, but works?
Post by: Storm-Donovan on June 01, 2021, 04:11:59 PM
The NetXMS server node reports the alarm, but I think it's erroring on every device.  I'm at 2400 alarms since my last message.
Title: Re: Script errors, but works?
Post by: Storm-Donovan on June 01, 2021, 04:24:29 PM
I just confirmed that script doesnt work anymore.  It worked 4 weeks ago when I first set it up, but it's not working now.
Title: Re: Script errors, but works?
Post by: Filipp Sudanov on June 01, 2021, 05:35:05 PM
Can you show the full script. Original error message says the error is in line 8, but it's not clear what line is it.
Title: Re: Script errors, but works?
Post by: Storm-Donovan on June 01, 2021, 05:52:54 PM
Line 8 is the first line, here's the script currently after the other changes suggested above.

Quote/* Available global variables:
*  $object - current object, one of 'NetObj' subclasses
*  $node - current object if it is 'Node' class
*
* Expected return value:
*  none - returned value is ignored
*/
if (classof($object =="Node") && (($node->snmpSysName != null) && ($node->snmpSysName != "")) && (($node->driver == "MIKROTIK") || ($node->driver ~= "CAMBIUM")))
{
   RenameObject($node, $node->snmpSysName);
}
Title: Re: Script errors, but works?
Post by: Filipp Sudanov on June 01, 2021, 05:56:05 PM
classof($object function should have closing bracket: classof($object). Output of this function is string which is compared to "Node"
Title: Re: Script errors, but works?
Post by: Storm-Donovan on June 01, 2021, 06:09:05 PM
Thanks, that's got it sorted out now!