Script errors, but works?

Started by Storm-Donovan, June 01, 2021, 12:07:11 AM

Previous topic - Next topic

Storm-Donovan

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

Storm-Donovan

Never mind, I figured it out.  It was erroring on a device that was misconfigured to not poll SNMP.

Storm-Donovan

No, it's still erroring.  It only errors on the netxms server node.


Storm-Donovan

Thanks, but that didn't fix it.  It's erroring on the NetXMS server node.

Storm-Donovan

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.

Storm-Donovan

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.

Filipp Sudanov

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.

Storm-Donovan

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);
}

Filipp Sudanov

classof($object function should have closing bracket: classof($object). Output of this function is string which is compared to "Node"

Storm-Donovan

Thanks, that's got it sorted out now!