We have a lot of remote Agent based nodes that get re-imaged and therefore we have an UP (new one) and a DOWN one. Sometimes the re-image fails to correctly install the agent I have a PowerShell script, that runs as a scheduled task, that finds Down agent polled Windows devices.
If the script finds an UP one with a matching node caption to the DOWN one, it deleted the DOWN one.
If the script finds an no UP one with a matching node caption to the DOWN one, it Unmanages the DOWN one.
The next challenge is to test the Unmanaged nodes to see if the agent is connectable again (the node was down, the WAN link was down, etc). I am trying to use the Orion.AgentManagement.Agent TestWithEngine verb to see if the agent is responding. Here is my code section and returns:
# Test Unamanaged ATMs connectability between the poller and the agent. Remanage any that have connectable agents
$agentToTest = Get-SwisData $swis 'SELECT Agent.AgentID, Agent.PollingEngineId, Agent.Node.Caption as Name, Agent.Node.NodeID FROM Orion.AgentManagement.Agent where Agent.Node.status = 9' ;
for ($i=0; $i -lt $agentToTest.Length; $i++)
{
$testResults = Invoke-SwisVerb $swis Orion.AgentManagement.Agent TestWithEngine @($agentToTest[$i].AgentID, $agentToTest[$i].PollingEngineId)
If($testResults.'#text' -eq "True")
{
$msg+= ("{0} INFO: Remanaging ATM {1} since it is now connectable. `n" -f `
((get-date -Format s).Replace("T", " ")), (($agentToTest[$i].name | Out-String).Replace("`n", "")) );
$node = "N:" + $agentToTest.nodeID[$i]
Invoke-SwisVerb $swis Orion.Nodes Remanage @($node)
}
else
{
$msg+= ("{0} INFO: ATM {1} agent is still unconnectable. `n" -f `
((get-date -Format s).Replace("T", " ")), (($agentToTest[$i].name | Out-String).Replace("`n", "")) );
}
}
The first get-SwisData call returns this:
AgentID PollingEngineId Name NodeID
76 10 Node026A154P 9690
159 10 Node544A013P 9092
222 10 Node211A202P 9536
256 10 Node086A075P 9699
259 10 Node521A271P 9679
265 10 Node026A154P 9690
269 10 Node086A075P 9699
270 10 Node544A013P 9700
276 10 Node544A013P 9708
Regardless of the state of the agent, I get the same thing as a return from $testResults = Invoke-SwisVerb $swis Orion.AgentManagement.Agent TestWithEngine @($agentToTest[$i].AgentID, $agentToTest[$i].PollingEngineId)
xmlns | #text | |
----- | ----- | |
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract | true |
I thought of using the DiscoverInterfacesOnNode but agent based nodes' NodeID returns InvalidNode as the Result regardless of the Agent state.
Any assistance will be appreciated.
...