mrxinu / gosolar

A SolarWinds client written in Go.
Apache License 2.0
15 stars 6 forks source link

Node creation sample #14

Open AmbicaY opened 4 years ago

AmbicaY commented 4 years ago

13 Node creation sample. Please review if it is good for a merge.

mrxinu commented 4 years ago

Hey @AmbicaY! Thanks so much for the PR. The first part looks good where it creates the node but then you have to add all the pollers which is where things can get confusing. If you're adding a Windows machine it's easy enough to get a distinct list of pollers that have been set to enabled in Orion.Pollers with this query:

SELECT DISTINCT PollerType
FROM Orion.Nodes AS Nodes
INNER JOIN Orion.Pollers AS Pollers ON Nodes.NodeID = Pollers.NetObjectID
WHERE Nodes.Vendor = 'Windows'
AND Pollers.NetObjectType = 'N'
AND Pollers.Enabled = 'True'
AND Nodes.ObjectSubType = 'SNMP'

That should produce this list:

N.AssetInventory.Snmp.Generic
N.Cpu.SNMP.HrProcessorLoad
N.Details.SNMP.Generic
N.Memory.SNMP.HrStorage
N.ResponseTime.ICMP.Native
N.Routing.SNMP.Ipv4RoutingTable
N.Routing.SNMP.Ipv6RoutingTable
N.Status.ICMP.Native
N.Topology_Layer3.SNMP.ipNetToMedia
N.Uptime.SNMP.Generic

The fields that are required to create a new poller are these:

  1. PollerType (example, "N.Uptime.SNMP.Generic")
  2. NetObject (example, "N:2")
  3. NetObjectType (example, "N")
  4. NetObjectID (example, 2)
  5. Enabled (example, "True")

This is the entire process in PowerShell for reference.

https://github.com/solarwinds/OrionSDK/blob/master/Samples/PowerShell/CRUD.AddNode.ps1

You want to make some changes to it and send me a note when you want me to review it again? I promise I won't wait weeks this time! :)