cancel
Showing results for 
Search instead for 
Did you mean: 
Create Post
Level 13

SAM Script Monitor returns 127.0.0.1 when using ${IP} variable on Agent Polled Nodes

I have a PowerShell script monitor component running in my NPM 12.0.1, SAM 6.3 environment and it is returning the 127.0.0.1 loopback IP address when providing it the ${IP} variable instead of the Node's polling IP Address.  This is odd to me because as far as I knew the ${IP} variable is just a macro that queries the database and returns the Node's selected polling IP Address, but instead it seems to be asking the node itself for its IP address, at least when the Node is polled via Agent polling, and since the script is being run locally by the agent it is returning its loopback address for some weirdo reason.  I've been able to workaround this by using the ${Node.Caption} variable, but that workaround may not work for many of my other script monitors. 

I would like to know if this is a known issue or a weird bug or something?

The closest article I've found to my issue is this:

Agent Polling and PowerShell Scripts

The issue in that post seemed to be they were having problems with the ${Credential} variable working on agent polled nodes, which is funny because I had no problems with that once I reformatted my PowerShell script from this:

$creds = '${Credential}'

to this:

$creds = Get-Credential -Credential '${Credential}'

But when I put ${IP} in the Script Arguments box and then call it by doing this:

$ipAddress = $args[0]

It always returns 127.0.0.1 despite the node's IP_Address value in the NodesData table being it's real IP address, something like 10.0.0.150.


I'm using Local Execution mode, which means the script is being ran by the target node itself.  I'm not sure if the issue persists in Remote Execution mode.  I've also tried turning Impersonation on and off but it doesn't change the ${IP} returning as 127.0.0.1.  I wouldn't expect the impersonation mode to change that anyways since that is more about how the credentials are handled than anything else.  I also tried changing the App Monitor's preferred polling method to agentless but it didn't matter.

Labels (1)
0 Kudos
2 Replies
Level 11

I have the same problem, I want to retrieve the IP (not the dns), is there another solarwinds variable to get it ? (powershell script)

0 Kudos
Level 13

This is intentional behavior specific to agent polling. As agent node can be registered in Orion with NAT IP (that can be unknown/unreachable from agent machine) node's IP on orion side is considered unreliable/irrelevant and thus replaced by loopback IP before polling starts. Agent should always poll machine on which it is currently running so loopback IP was most logical choice.

If you still need some identification of node from orion database, macros ${Node.SysName} and ${Node.DNS} should be available and not modified by this logic.

0 Kudos