solarwinds / OrionSDK

SDK for the SolarWinds Orion platform, including tools, documentation, and samples in PowerShell, C#, Go, Perl, and Java.
https://thwack.com/OrionSDK
Apache License 2.0
401 stars 143 forks source link

EnablePollingForNodes Verb gives inconsistent results #234

Open AnaCr opened 4 years ago

AnaCr commented 4 years ago

I've been trying to enable asset inventory for nodes using the EnablePollingForNodes verb (Entity Orion.AssetInventory.Polling). Sometimes it works, sometimes it doesn't but I am using the exact same request. I get no errors, only status 200, so I know there aren't any issues with the request. It just doesn't work consistently.

Here is an example where I attempted enabling for one node only. image

One day later I tried again, no changes were made to the request, but now I get a response of "true". image

I also tried with an array of nodes. image

tomasvladik commented 4 years ago

Hi,

the return value true/false gives information that it was possible to set up Asset Inventory(AI) polling for the node (or all nodes in the array) immediately or not.

When you get true, then AI is on for the node and you can see AI subview on the node detail page. When you get false, then Orion doesn't have discovery information, which AI polling description to use for the node and some background mechanism started to gain it.

When the background mechanism finished, AI should be enabled for the node. It takes a few minutes because AI tries more available polling description and choose which one match for the node.

Hope this answer helps. Tom

AnaCr commented 4 years ago

Thanks Tom that explanation makes sense.

Just as an update: I ran it again this morning on 23 nodes. None of them enabled immediately, but after several hours 7 of the 23 are enabled.

martin-vw commented 3 years ago

I'm also having issues with this. Does anyone have insight to if I'm doing something wrong?

Trying to use the SwisPowerShell module. If I do it through the SWQL Studio it works. Doesn't work in PowerShell. Here's the script I tried:

[int]$NodeId = 5334 $A = "<int>$NodeId</int>" $B = "'<int>" + $NodeId + "</int>'" $C = "<ArrayOfint xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/2003/10/Serialization/Arrays"><int>$NodeId</int></ArrayOfint>" # Removed escape characters for double quotes because of the Github codeblock.

Invoke-SwisVerb -SwisConnection $swis -EntityName "Orion.AssetInventory.Polling" -Verb "DisablePollingForNodes" -Arguments @($NodeId) Invoke-SwisVerb -SwisConnection $swis -EntityName "Orion.AssetInventory.Polling" -Verb "DisablePollingForNodes" -Arguments @($A) Invoke-SwisVerb -SwisConnection $swis -EntityName "Orion.AssetInventory.Polling" -Verb "DisablePollingForNodes" -Arguments @($B) Invoke-SwisVerb -SwisConnection $swis -EntityName "Orion.AssetInventory.Polling" -Verb "DisablePollingForNodes" -Arguments @($C) Invoke-SwisVerb -SwisConnection $swis -EntityName "Orion.AssetInventory.Polling" -Verb "DisablePollingForNodes" -Arguments $NodeId Invoke-SwisVerb -SwisConnection $swis -EntityName "Orion.AssetInventory.Polling" -Verb "DisablePollingForNodes" -Arguments $A Invoke-SwisVerb -SwisConnection $swis -EntityName "Orion.AssetInventory.Polling" -Verb "DisablePollingForNodes" -Arguments $B Invoke-SwisVerb -SwisConnection $swis -EntityName "Orion.AssetInventory.Polling" -Verb "DisablePollingForNodes" -Arguments $C

Each variant provided this error: Invoke-SwisVerb : Verb Orion.AssetInventory.Polling.DisablePollingForNodes cannot unpackage parameter 0 of type System.Int32[]

tomasvladik commented 3 years ago

I'm also having issues with this. Does anyone have insight to if I'm doing something wrong?

I think you should use for the nodeIds list standard PowerShell array and don't pass it as XML string which is constructed for SwqlStudio

jeffrey-irwin commented 3 years ago

Having the same issue.

I did get a step further in PowerShell as I was able to get past the error @martin-vw was having by changing the argument/input variable to match the argument format in OPs API call (in PS: a hashtable, with a NodeIds arrary).

Unfortunately, I am still running into the same issue as OP - I am not seeing an entry in Orion.AssetInventory.Polling table or the Asset Inventory box checked on List Resources right away (like is seen when using SWQL method) even though I get a 'true' response in both.

$NodeIds = @{
    NodeIds = @(
        [int]$NewNode["NodeID"]
    )
}
Invoke-SwisVerb -SwisConnection $swis -EntityName "Orion.AssetInventory.Polling" -Verb "EnablePollingForNodes" -Arguments @($NodeIds)

xmlns                                                                          #text
-----                                                                          -----
http://schemas.datacontract.org/2004/07/SolarWinds.InformationService.Contract true

I will check again tomorrow and see if this eventually pops in like OP is finding...

martin-vw commented 3 years ago

Anyone else still experiencing this problem? I also upgraded my Orion install to the most current version (2020.2.6, 24 AUG 2021) and also installed the updated Orion SDK (3.0).

The method that @ji438937 suggested is accepted by the Invoke-SwisVerb commandlet, but doesn't appear to actually make any changes in Orion.