use dynamic IP from SNMPget to PING by subagent icmp.ping

Started by Dani@M3T, March 05, 2014, 10:13:06 PM

Previous topic - Next topic

Dani@M3T

I have the following situation:
some firewalls (call it GATEWAY1) with dynamic WAN-IP addresses. There I have to ping the default gateway of the WAN interface from the NetXMS server and the result should be shown on the node GATEWAY1.

I see two possibilities but can't find a working solution:
1.
On GATEWAY1 a DCI: Origin = Internal, Parameter = Dummy, Proxy-node = NetXMS-server. Than in transformation script SNMPGetValue (is functional) and a call of a subagnet icmp.ping. But I could't find a possibility to call a subagent from the script.
2.
put the SNMPGetValue in a script in the script library
On GATEWAY1 a DCI: Origin = NetXMS Agent, Parameter = something like 'icmp.ping(script:getip)', no proxy node

Does anybody have a hint or better a solution? I hope I described the situation accurate

andrey--k

May be you would try to use ddns systems in combination with server-side script to resolve current IP?

Dani@M3T

yes but its not the WAN IP address (which I could get from resolved DDNS name), it's the default gateway address of the WAN subnet. I can get the default gateway IP address from the local routing table by SNMP, thats not the problem. But than I have to 'ping' this IP from the NetXMS server.

Victor Kirhenshtein

Hi!

Solution #1 seems correct. You can get value from remote agent with AgentReadParameter function. However, easier would be to use proxy node directly:

On GATEWAY1 a DCI: Origin = Agent, Parameter = Icmp.Ping(ip), Proxy-node = NetXMS-server

No transformation script needed in this case.

Best regards,
Victor

Dani@M3T

Hi Victor

But in your suggestion, I have first get 'ip' (as you called it in your post) from a SNMPGetValue on node GATEWAY1. Can I use a script in the 'parameter' field of the DCI for this?

thanks
Dani

Victor Kirhenshtein

Sorry, I misunderstood the situation. Then you can use the following DCI:

Origin = SNMP, Parameter = OID you are using to get IP address

with the following transformation script:


server = FindNodeObject($node, "netxms-server-name");
return AgentReadParameter(server, "Icmp.Ping(" . $1 . ")");


Best regards,
Victor

Dani@M3T

Hi Victor

Many thanks for the very fast solution. It works

The following line is the solution:
return AgentReadParameter(server, "Icmp.Ping(" . $1 . ")"); [I didn't know that]

But can you explain me the syntax you used 'icmp.ping(" . $1 . ")?
From SubAgent documentation I have this syntax 'Icmp.Ping(target,*timeout*,*psize*)'

thanks a lot!

Dani

Dani@M3T

another 'problem' is: now the result of the DCI is the latency of the ping (=ok) but it's a string, not an integer. Maybe because the SNMP Data Type is string (it's an IP address) but the result of the transformation script should be an integer.

Dani@M3T

sorry last post was too early :-)
I changed the Data Type of the DCI to integer and now it's ok. I thought the Data Type must be the type of the SNMP value. But it looks like Data Type is the type of the DCI-result after the transformation script.
So only the question about the icmp.ping syntax is open.

Victor Kirhenshtein

Timeout and packet size are optional arguments and can be omitted. There is word "optional" deep in parameter description :) All following forms are valid:

Icmp.Ping(10.10.10.1)
Icmp.Ping(10.10.10.1,3000)
Icmp.Ping(10.10.10.1,2000,120)
Icmp.Ping(10.10.10.1,,140)

Best regards,
Victor

Dani@M3T

Thanks. I saw that in the documentation. But you gave me this:
Icmp.Ping(" . $1 . ")

I don't understand " . $1 . ".
'$1' is the result of the SNMPget, thats clear, but why these points?
I had expected something like Icmp.Ping("$1")

Victor Kirhenshtein

. is string concatenation operation in NXSL. NXSL does not do macro expansion within strings, so you have to do concatenation. Don't be confused by $ sign - it is valid character in identifiers and has not any special meaning. It's just a naming convention to start names of built-in variables with $. You can name your variable a$ for example.

Best regards,
Victor

Dani@M3T