GetNodeInterfaces - parameters [SOLVED]

Started by sperlm, January 23, 2014, 04:35:53 PM

Previous topic - Next topic

sperlm

In the GetNodeInterfaces example there are used two parameters - name and id.

My question is - can other parameters from Interfaces be used the same way or it is not possible at all ?

I'm trying to get a list of peers with "i->peerInterface", no results with GetNodeIntefaces or GetObectChildren too - script fails at this point with "invalid operation on object".

Any help?

Victor Kirhenshtein

Hi!

Can you explaint in more detail what you are trying to achieve or maybe post whole script? There are also example of using peerNode and peerInterface attributes: http://wiki.netxms.org/wiki/Script_Example:_Additional_Information_About_Connected_Node.

Best regards,
Victor

sperlm

Hello,

   there is no description for GetInterfaceName/Object functions so I am constructing script with GetNodeInterfaces or GetObjectChildren (with the same results).

The goal is to list peer nodes of subjected node.
The following macro works fine, returning a list of all ports and then another list with ports which have any peer connection listed.
ports = "PORTs:\n";
peers = "PEERs:\n";
interfaces = GetObjectChildren($node); (or GetNodeInterfaces function)
foreach (i : interface)
{
ports = ports."- name=".i->name.", id=".i->id."\n";
if (i->peerNode != null)
{
peers = peers."- name=".i->name.", IP=".i->ipAddr.", peer=".i->peerNode."\n";
}
}
return ports.peers;


Whole macro works fine except the last statement which returns error message.
After removing the "i->peerNode" part I get nice output in this form:
QuotePORTs:
* name='Vl1 id=5699'
* name='Vl91 id=5700'
* name='Fa0/1 id=5701'
* name='Fa0/2 id=5702'
...
* name='Fa0/23 id=5723'
* name='Fa0/24 id=5724'
* name='Gi0/1 id=5725'
* name='Gi0/2 id=5726'
* name='Nu0 id=5727'
PEERs:
* name='Gi0/1' IP=0.0.0.0 peer='
* name='Gi0/2' IP=0.0.0.0 peer='

Tried to use structure with GetInterfaceObject in the foreach loop...
iface = GetInterfaceObject(i,  $5];
... to get iface->peerNode, but I get immediately "Function not found" on the line with GetInterfaceObject function.

With regards,
Milan Sperl

Victor Kirhenshtein

Your problem here is that i->peerNode is an object, not a string, so you should use something like i->peerNode->name.

Best regards,
Victor

sperlm

Thanks! Work like a charm  ;D

p.s. could I get my old topic Dependency script based on infrastructure unlocked to post what I came up with to share with others ?

Victor Kirhenshtein

Quote from: sperlm on January 24, 2014, 03:02:06 PM
p.s. could I get my old topic Dependency script based on infrastructure unlocked to post what I came up with to share with others ?

unlocked.

Best regards,
Victor