scripting management functions [SOLVED]
-
Hello,
I have been creating filtering and even some scripts that imitate snmpwalk or trying to polish tool to mass-create DCI (based on my snmpwalk) but some problems with management functions arised.
(I am looking into python for nxshell functionality now, but I believe commands from Function Reference should be working without nxshell.)Some functions work, but some do not and I don't know why..
For example - GetNodeParents, GetNodeInterfaces, GetObjectParents, GetObjectChildren
The first line where I use these functions makes the script broken, even test scripts like this are not working...
interfaces = GetNodeInterfaces($1); foreach(i : interfaces) { println "Interface: name='" . i->name . "' id=" . i->id; }All I get is: ERROR: Script finished with error: Error 14 in line 1: Function or operation argument is not an object
Can someone enlighten me what I do wrong please?
With regards
Milan Sperl
-
Hi!
You pass $1 to GetNodeInterfaces. It's a first argument of the script. It depends on context, but it's unlikely that it will be node object. If you want to work with "current" node (i.e. owner node of DCI in transformation script), you can use built-in variable $node. In other cases, you can use FindNodeObject function to obtain reference to node object you are interested in.
Best regards,
Victor -
Sorry for not explaining - I am using $1 because I am running the script from Server Console and provide node name as first parameter of course. That is why I am "printing" the results.
I even tried to set node name (or ID) instead of $1 to remove the possibility this parameter is at fault.
If I set node name (e.g. Core1-SW) the error changes to:
_Error 5: Invalid operation with NULL value_Thanks for the reply
Milan Sperl
-
Node name is a string, not an object reference. If you want to find node object by name, you could use FindObject or FindNodeObject function, like this:
node = FindNodeObject(null, $1); println "Node ID: " node->id;Also check this script example: http://wiki.netxms.org/wiki/Script_Example:_Read_SNMP_Value_From_Node
Best regards,
Victor -
Thanks for pointing the problem for me.
I should have used the findObject function and I have to use ID of the tested node only. Cannot use Object Name, which is OK for testing purposes, in called scripts I can use $node again.
The "null" parameter in findObjectNode was not clear to me (but it works with it too).Thanks once more.
Milan Sperl
-
@sperlm said in scripting management functions [SOLVED]:
The "null" parameter in findObjectNode was not clear to me (but it works with it too).
It's a reference to already known object. Here is the explanation: http://wiki.netxms.org/wiki/SG:Security_Issues.
Best regards,
Victor
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login