This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

REST API Creating Nodes

So i am able to consume the API and it does create the node and update the properties how i want however the Caption field is not required and it doesn't ever seem to auto populate also it doesn't seem to ever properly poll or automatically add resources needed.

How can i make sure it does a poll and update the caption with the hostname?

How can i set resources or all discovered resources to be added to monitor?

  • Yes of course sorry.

            // POST call/nodes

            public HttpResponseMessage Post([FromBody]NodeInfo info)

            {

                CustomNodeInfo cnInfo = new CustomNodeInfo();

                #region Hard Coded Values for SaaS

                //Hard coding these for now as this is for just the SaaS Poller currently

                info.EngineID = 4;

                cnInfo.CRM_Account = "AN_CUST1099";

                cnInfo.ACCPAC_SiteID = "MST-SaaS";

                cnInfo.AssetType = "Server";

                ModelState.Remove("value.EngineID");

                //End Hard Coded

                #endregion

                info.EntityType = "Orion.Nodes";

                info.DynamicIP = false;

                info.Status = 1;

                info.UnManaged = false;

                info.Allow64BitCounters = false;

                if (ModelState.IsValid)

                {

                    string query = "{\"query\":\"SELECT PropertyValue FROM Orion.EngineProperties WHERE EngineID=@e AND PropertyName='Orion.Standard.Polling'\",\"parameters\":{\"e\":"+info.EngineID+"}}";

                    JObject pollingRate = JObject.Parse(SWJsonCall.Post("Json/Query", query));

                    int curRate = (Int32)pollingRate["results"][0]["PropertyValue"];

                    if (curRate < 85)

                    {

                        //Create Node First

                        string createNode = SWJsonCall.Post("Json/Create/Orion.Nodes", JsonConvert.SerializeObject(info));

                        //Make the returned swis url nice

                        createNode = createNode.Replace("\\","").Replace("\"","");

                        string updateProps = SWJsonCall.Post("Json/" + createNode + "/CustomProperties", JsonConvert.SerializeObject(cnInfo));

                        return new HttpResponseMessage(HttpStatusCode.Created);

                    }

                    else

                    {

                        return Request.CreateResponse(HttpStatusCode.InternalServerError, "Polling rate at dangerous level " + curRate + "%. Please consult Admins, node NOT added.");

                    }

                }

                else

                {

                    var message = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.ErrorMessage));

                    var execption = string.Join(" | ", ModelState.Values.SelectMany(v => v.Errors).Select(e => e.Exception));

                    return Request.CreateResponse(HttpStatusCode.BadRequest, "Error - " + message + " : " + execption);

                }

            }

  • You also need to add pollers to your new node. See this script for an example: orionsdk-python/add_node.py at master · solarwinds/orionsdk-python · GitHub  .

    Note that the set of pollers you need depends on the type of node (vendor) you are adding.

  • That would do it then thank you sir ... do you have a list of pollers ?

  • Is there a way for it to automatically pick up Volume Utilization and Name resolution?

    And by Name i mean Caption

  • Not using this approach.

    If you switch to using the discovery API, you can add a node with all of the interfaces and volumes including the appropriate pollers for whatever device type it is.

    See this post for details: Triggering discovery of SNMPV2 device through JSON API

  • Well that makes more sense then however the API is throwing an error stating :

    Message\":\"Verb Orion.Discovery.StartDiscovery requires 1 parameters not 0

    Here is the post data values changed to security purposes ...

    "{\"Name\":\"Discovery API Test\",\"EngineID\":4,\"JobTimeoutSeconds\":3600,\"SearchTimeoutMiliseconds\":2000,\"SnmpTimeoutMiliseconds\":3000,\"SnmpRetries\":1,\"RepeatIntervalMiliseconds\":1800,\"SnmpPort\":161,\"HopCount\":0,\"PerferredSnmpVersion\":\"SNMPv2\",\"DisableIcmp\":false,\"AllowDuplicateNodes\":false,\"IsAutoImport\":true,\"IsHidden\":true,\"PluginConfigurations\":\"{PluginConfigurationItem: <PluginItems xmlns=\\\"http://schemas.datacontract.org/2004/07/SolarWinds.Orion.Core.Models.Discovery\\\"><knownTypes><ArrayOfstring xmlns=\\\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\\\" xmlns:i=\\\"http://www.w3.org/2001/XMLSchema-instance\\\"><string>SolarWinds.Orion.Core.Models.Discovery.CoreDiscoveryPluginConfiguration,SolarWinds.Orion.Core.Models</string></ArrayOfstring></knownTypes><pluginItem><ArrayOfDiscoveryPluginConfigurationBase xmlns:i=\\\"http://www.w3.org/2001/XMLSchema-instance\\\"><DiscoveryPluginConfigurationBase i:type=\\\"d2p1:CoreDiscoveryPluginConfiguration\\\" xmlns:d2p1=\\\"http://schemas.solarwinds.com/2008/Orion\\\"><d2p1:AddressRange/><d2p1:AgentsAddresses xmlns:d3p1=\\\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\\\"/><d2p1:BulkList xmlns:d3p1=\\\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\\\"><d3p1:string>127.0.0.1</d3p1:string></d2p1:BulkList><d2p1:Credentials><d2p1:credentials><knownTypes><ArrayOfstring xmlns=\\\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\\\"><string>SolarWinds.Orion.Core.Models.Credentials.SnmpCredentialsV2,SolarWinds.Orion.Core.Models</string></ArrayOfstring></knownTypes><pluginItem><d2p1:ArrayOfCredential><d2p1:Credential i:type=\\\"d2p1:SnmpCredentialsV2\\\"><d2p1:Description i:nil=\\\"true\\\"/><d2p1:ID i:nil=\\\"true\\\"/><d2p1:IsBroken>false</d2p1:IsBroken><d2p1:Name>mud</d2p1:Name><d2p1:Owner i:nil=\\\"true\\\"/><d2p1:Community>ComString</d2p1:Community></d2p1:Credential></d2p1:ArrayOfCredential></pluginItem></d2p1:credentials></d2p1:Credentials><d2p1:DiscoverAgentNodes>false</d2p1:DiscoverAgentNodes><d2p1:SharedCredentials xmlns:d3p1=\\\"http://schemas.microsoft.com/2003/10/Serialization/Arrays\\\"/><d2p1:SubnetList/><d2p1:WmiRetries>1</d2p1:WmiRetries><d2p1:WmiRetryInterval>PT10S</d2p1:WmiRetryInterval></DiscoveryPluginConfigurationBase></ArrayOfDiscoveryPluginConfigurationBase></pluginItem></PluginItems>}\"}"

    I am not sure how it can't see the param as its passed properly below here same way i was doing it with all the other post methods and the above json is validating...

            public HttpResponseMessage Post([FromBody]NodeInfo info)

            {

                DiscoveryInfo dis = new DiscoveryInfo();

                dis.Name = "Discovery API Test";

                dis.EngineID = 4;

                dis.JobTimeoutSeconds = 3600;

                dis.SearchTimeoutMiliseconds = 2000;

                dis.SnmpTimeoutMiliseconds = 3000;

                dis.SnmpRetries = 1;

                dis.RepeatIntervalMiliseconds = 1800;

                dis.SnmpPort = 161;

                dis.HopCount = 0;

                dis.PerferredSnmpVersion = "SNMPv2";

                dis.DisableIcmp = false;

                dis.AllowDuplicateNodes = false;

                dis.IsAutoImport = true;

                dis.IsHidden = true;

                dis.PluginConfigurations = "{PluginConfigurationItem: " + DiscoveryProfiles.SNMPv2(info.Community, info.IPAddress) + "}";

                string createDiscovery = SWJsonCall.Post("Json/Invoke/Orion.Discovery/StartDiscovery", JsonConvert.SerializeObject(dis));

                return new HttpResponseMessage(HttpStatusCode.Created);

            }

  • Post data for an "Invoke" call should always be a json array. StartDiscovery expects one parameter, so it should be an array of one item.

  • So i did that and using the example you gave i checked and its valid json but still having issues with it.

    ss1.JPG