17 Replies Latest reply on Jul 2, 2014 4:46 PM by dkeyser

    10.4.1 - use of Orion.Discovery verbs

    robert.simpson

      I was using the SWQL Studio to look through a server newly updated to NPM 10.4.1 and noticed the verbs "CreateCorePluginConfiguration" and "StartDiscovery" on the new Orion.Discovery object. I was able to pull out the XML templates for their parameters from the Metadata.VerbArgument section, but I'm not clear on their usage. For some context, we're trying to programmatically add interfaces to a node and only add the new interfaces that are in an up/up state. It looks like we can do it if the interfaces are in the Orion.NPM.DiscoveredInterfaces table, but we don't know how to get them there and we're hoping/assuming that using these verbs will get them there.

       

      I have three questions about actually using these verbs, and hoping someone here can provide some insight:

      1. Would using these verbs actually add a node/interfaces to the DiscoveredNodes/DiscoveredInterfaces tables, as we're hoping?
      2. It looks like we could use StartDiscovery if we can update the discovery engine on the fly to only discover the relevant IP address. Is this possible via SWIS? If so, does anyone have any guidance on updating the ranges for the discovery engine?
      3. It looks like CreateCorePluginConfiguration might get us what we want (i.e., a request to only discover specific IPs in a range.) Is there any guidance available on using this method in conjunction with StartDiscovery to do that?

       

      Thanks!

        • Re: 10.4.1 - use of Orion.Discovery verbs
          robert.simpson

          Figured it out on my own. Explanation below, but please note that I'm coming at this almost entirely from an integration perspective (and so may have some specifics about how NPM works somewhat wrong).

           

          Working from the XSD also stored in the metadata, you use the "CreateCorePluginConfiguration" verb and build out the following XML as the argument (if you're using the Bulk List of IPs):

           

          <CorePluginConfigurationContext xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.solarwinds.com/2012/Orion/Core">

          <BulkList>

          <IpAddress>

          <Address>(device address)</Address>

          </IpAddress>

          </BulkList>

          <Credentials>

          <SharedCredentialInfo>

          <CredentialID>(credential ID as in Orion.Credentials)</CredentialID>

          <Order>(order to try credentials in)</Order>

          </SharedCredentialInfo>

          </Credentials>

          <WmiRetriesCount>0</WmiRetriesCount>

          <WmiRetryIntervalMiliseconds>0</WmiRetryIntervalMiliseconds>

          </CorePluginConfigurationContext>

           

          The XML response passes back an xml-encoded string that contains the XML configuration for the discovery. For my particular use case, I had to strip off the XML header from this return - your mileage may vary depending on the tools you're using. You stuff this string into the argument for "StartDiscovery", which will be an XML block that looks like the following (timeout and retry parameters not described - should be pretty straightforward):

           

          <StartDiscoveryContext xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.solarwinds.com/2012/Orion/Core">

          <Name>(discovery name to use)</Name>

          <EngineId>(Engine ID - as Orion.Engines)</EngineId>

          <JobTimeoutSeconds>3600</JobTimeoutSeconds>

          <SearchTimeoutMiliseconds>2000</SearchTimeoutMiliseconds>

          <SnmpTimeoutMiliseconds>3000</SnmpTimeoutMiliseconds>

          <SnmpRetries>1</SnmpRetries>

          <RepeatIntervalMiliseconds>1800000</RepeatIntervalMiliseconds>

          <SnmpPort>161</SnmpPort>

          <HopCount>0</HopCount>

          <PreferredSnmpVersion>SNMP2c</PreferredSnmpVersion>

          <DisableIcmp>false</DisableIcmp>

          <AllowDuplicateNodes>true</AllowDuplicateNodes>

          <IsAutoImport>false</IsAutoImport>

          <IsHidden>true</IsHidden>

          <PluginConfigurations>

          <PluginConfiguration>

          <PluginConfigurationItem>

          (the plugin configuration string from the previous call)

          </PluginConfigurationItem>

          </PluginConfiguration>

          </PluginConfigurations>

          </StartDiscoveryContext>


          The response contains the ID of the created discovery profile, which starts immediately. From there results are in the Orion.DiscoveryProfiles, Orion.DiscoveredNodes, and Orion.NPM.DiscoveredInterfaces tables as you'd expect.

          • Re: 10.4.1 - use of Orion.Discovery verbs
            dkeyser

            Can setting the IsAutoImport section to true make the discovery import all results after it's completed? If so then this is fantastic as I won't have to pull in the Discovered Nodes and Discovered Interfaces and add them all in using more scripting.

            • Re: 10.4.1 - use of Orion.Discovery verbs
              dkeyser

              I've found the framework for the discovery request in the SWQL studio but I'm not sure how to work with it. I'm seeing tags like <BulkList /> and I'm not familiar with them. Below is what I'm getting as output and would like to know a little more about the <something /> tags I'm seeing. I've not worked with XML much but a little html so the / at the end is confusing me.

               

              <CorePluginConfigurationContext xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.solarwinds.com/2012/Orion/Core"><BulkList /><IpRanges /><Subnets /><Credentials /><WmiRetriesCount>0</WmiRetriesCount><WmiRetryIntervalMiliseconds>0</WmiRetryIntervalMiliseconds></CorePluginConfigurationContext>

                • Re: 10.4.1 - use of Orion.Discovery verbs
                  dkeyser

                  Ok so a little digging and I found that <something /> is an empty set and is the same as <something></something>. Now my question is do we need these empty sets or can we remove them. My attempts all lead to the following error message:

                   

                    • Re: 10.4.1 - use of Orion.Discovery verbs
                      tdanner

                      If you post the inputs that are leading to this error message, I might be able to guide you.

                        • Re: 10.4.1 - use of Orion.Discovery verbs
                          dkeyser

                          Here is what I'm doing in PowerShell. SWQL studio seems to have added one discovery but I can't tell if subsequent runs of the verb overwrite the job or if it's not working any more.

                           

                          if (! (Get-PSSnapin | where {$_.Name -eq "SwisSnapin"})) {

                              Add-PSSnapin "SwisSnapin"

                          }

                           

                          $hostname = "localhost"

                          $username = "admin"

                          $password = New-Object System.Security.SecureString

                          $cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password

                          $swis = Connect-Swis -host $hostname -cred $cred

                           

                          $z = '<CorePluginConfigurationContext xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.solarwinds.com/2012/Orion/Core">

                          <BulkList >

                          <IpAddress>

                          <Address>192.168.21.3</Address>

                          </IpAddress>

                          </BulkList>

                          <IpRanges />

                          <Subnets />

                          <Credentials>

                          <SharedCredentialInfo>

                          <CredentialID>1</CredentialID>

                          <Order>1</Order>

                          </SharedCredentialInfo>

                          </Credentials>

                          <WmiRetriesCount>0</WmiRetriesCount>

                          <WmiRetryIntervalMiliseconds>0</WmiRetryIntervalMiliseconds>

                          </CorePluginConfigurationContext>'

                          $discovered = Invoke-SwisVerb $swis Orion.Discovery CreateCorePluginConfiguration $z

                            • Re: 10.4.1 - use of Orion.Discovery verbs
                              tdanner

                              CreateCorePluginConfiguration does not create a discovery profile in the database. It just takes the input (CorePluginConfigurationContext), combines it with some other data, and returns a blob of XML that you need for the next step: calling Orion.Discovery.StartDiscovery. That verb expects a StartDiscoveryContext object. This object has a bunch of properties including PluginConfigurations, which has type List<PluginConfiguration>. A PluginConfiguration just has one property of type string called PluginConfigurationItem. Take the XML that was returned by CreateCorePluginConfiguration and use it as the value for PluginConfigurationItem.

                                • Re: 10.4.1 - use of Orion.Discovery verbs
                                  dkeyser

                                  Further reading and face palming when I realized I missed the section where it was described where you put the output of the core verb and I have a working discovery PowerShell script! The only thing I'm missing now is how to delete these discoveries after they have been executed. I tried the following:

                                   

                                  $temp = Get-SwisData $swis "Select URI FROM Orion.DiscoveryProfiles WHERE name = 'Test Discovery'"

                                  $final = remove-swisobject $swis -uri $temp

                                   

                                  This came back with the error "Operation not supported on Orion.DiscoveryProfiles". Is there a way to remove these after they have been run or do I just need to make a script that runs daily to clean all these jobs out? The latter may work but I like to keep things tidy.

                                   

                                  I appreciate all your efforts!

                                    • Re: 10.4.1 - use of Orion.Discovery verbs
                                      tdanner

                                      Glad to hear you got it working! We don't have a way to clean these up programmatically at this time.

                                        • Re: 10.4.1 - use of Orion.Discovery verbs
                                          dkeyser

                                          Unfortunately it doesn't seem to be making the discoveries any longer. I did get one job to stay but anything afterwards shows up for a brief second and then vanishes. Even now when I'm attempting to execute the script to make a new job to discover a node I have removed for testing the job disappears after a second and nothing is discovered. Closing the ISE and opening the script again has caused a ProvideFault. I'm not sure what happened since this was working for a bit today. The script I have is below.

                                           

                                          if (! (Get-PSSnapin | where {$_.Name -eq "SwisSnapin"})) {

                                              Add-PSSnapin "SwisSnapin"

                                          }

                                           

                                           

                                          $hostname = "localhost"

                                          $username = "admin"

                                          $password = New-Object System.Security.SecureString

                                          $cred = New-Object -typename System.Management.Automation.PSCredential -argumentlist $username, $password

                                          $swis = Connect-Swis -host $hostname -cred $cred

                                           

                                           

                                          $CoreParameter = ([xml]"<CorePluginConfigurationContext xmlns:i='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://schemas.solarwinds.com/2012/Orion/Core'>

                                          <BulkList >

                                          <IpAddress>

                                          <Address>192.168.240.2</Address>

                                          </IpAddress>

                                          </BulkList>

                                          <Credentials>

                                          <SharedCredentialInfo>

                                          <CredentialID>1</CredentialID>

                                          <Order>1</Order>

                                          <CredentialID>2</CredentialID>

                                          <Order>2</Order>

                                          <CredentialID>3</CredentialID>

                                          <Order>3</Order>

                                          <CredentialID>4</CredentialID>

                                          <Order>4</Order>

                                          <CredentialID>5</CredentialID>

                                          <Order>5</Order>

                                          <CredentialID>6</CredentialID>

                                          <Order>6</Order>

                                          <CredentialID>7</CredentialID>

                                          <Order>7</Order>

                                          <CredentialID>8</CredentialID>

                                          <Order>8</Order>

                                          <CredentialID>9</CredentialID>

                                          <Order>9</Order>

                                          </SharedCredentialInfo>

                                          </Credentials>

                                          <WmiRetriesCount>0</WmiRetriesCount>

                                          <WmiRetryIntervalMiliseconds>0</WmiRetryIntervalMiliseconds>

                                          </CorePluginConfigurationContext>").DocumentElement

                                           

                                           

                                          $CoreConfig = Invoke-SwisVerb $swis "Orion.Discovery" "CreateCorePluginConfiguration" @($CoreParameter)

                                          $CoreConfigInnerPiece = $coreConfig.InnerXml

                                           

                                           

                                          $coreCfgInnerPiece

                                           

                                           

                                          $StartDiscoveryConfig = ([xml]@("

                                          <StartDiscoveryContext xmlns:i='http://www.w3.org/2001/XMLSchema-instance' xmlns='http://schemas.solarwinds.com/2012/Orion/Core'>

                                            <Name>Test Discovery1</Name>

                                            <EngineId>1</EngineId>

                                            <JobTimeoutSeconds>3600</JobTimeoutSeconds>

                                            <SearchTimeoutMiliseconds>2000</SearchTimeoutMiliseconds>

                                            <SnmpTimeoutMiliseconds>3000</SnmpTimeoutMiliseconds>

                                            <SnmpRetries>4</SnmpRetries>

                                            <RepeatIntervalMiliseconds>1800</RepeatIntervalMiliseconds>

                                            <SnmpPort>161</SnmpPort>

                                            <HopCount>0</HopCount>

                                            <PreferredSnmpVersion>SNMP2c</PreferredSnmpVersion>

                                            <DisableIcmp>false</DisableIcmp>

                                            <AllowDuplicateNodes>false</AllowDuplicateNodes>

                                            <IsAutoImport>true</IsAutoImport>

                                            <IsHidden>true</IsHidden>

                                            <PluginConfigurations>",

                                              "<PluginConfiguration>

                                                  <PluginConfigurationItem>$coreCfgInnerPiece</PluginConfigurationItem>

                                              </PluginConfiguration>",

                                            "</PluginConfigurations>

                                          </StartDiscoveryContext>"

                                          )).DocumentElement

                                           

                                           

                                          $output = Invoke-SwisVerb $swis "Orion.Discovery" "StartDiscovery" @($StartDiscoveryConfig)

                                           

                                           

                                          $output.innerxml

                                          • Re: 10.4.1 - use of Orion.Discovery verbs
                                            bluefunelemental

                                            @tdanner

                                            It looks to me like unsuccessful discoveries stay behind in the discovery profiles table whereas successful ones are deleted. Is that true?

                                              • Re: 10.4.1 - use of Orion.Discovery verbs
                                                dkeyser

                                                From my testing all discoveries are being left behind. The hidden parameter was doing something funky when set to true but as soon as I set it to false all of them came back in the DiscoveryProfiles table. Not sure what it's purpose is as I assumed it'd only hide it from the GUI.

                                                 

                                                I'm thinking  that scheduling a script to purge the jobs with the name I'm using would do the trick but it'd really be nice to use the remove-swisobject against the DiscoveryProfiles table.

                                • Re: 10.4.1 - use of Orion.Discovery verbs
                                  dkeyser

                                  Also when running my discoveries and setting autoimport to true it's pulling in all interfaces even though I haven't specified those columns to be true. That and the retry interval in miliseconds isn't being read and is defaulting to 1 milisecond. Final note is that when I run the discovery it will also import the node but it'll use the IP address for the name instead of anything else like the other discoveries do.

                                   

                                  Any way to fix these things?

                                  Maybe specifying that I don't want it to auto import any interfaces will stop it from doing that but the caption thing is weird along with the milisecond field. I was thinking that a work around would be to update the captions of the nodes using the IPs from the discovery to populate the caption field correctly.

                                  • Re: 10.4.1 - use of Orion.Discovery verbs
                                    dkeyser

                                    I'd like to give an update. I've got my automatic discovery script working with static IPs in the xml document. I have the script waiting around for the discovery job to complete and the discovery job will then auto import all nodes found along with all interfaces and will also enable hardware health monitoring. I then have the script remove the pollers for the interfaces I don't want at the end. Currently that is me having the script remove all interfaces from the added node. I've attempted to add the columns for AddUpInterfaces, AddDownInterfaces, and AddShutdownInterfaces as false but this did not stop the discovery from importing them. All discoveries are being left behind regardless of completing correctly or not.

                                     

                                    As a side note I'm not seeing any of my scheduled jobs removed by DB maintenance any longer so I may have to go ahead and set up that script in SQL.

                                     

                                    I believe there is a better way of doing all of this but I've not found one. If anyone has other suggestions I'd be glad to hear them. The final step for this part is to get my script to import from a CSV and then Build a website that can call this script and pass/create a CSV. This has proven very interesting and educational.

                                     

                                    Thank you for all your help so far.