9 Replies Latest reply on Jul 2, 2014 8:25 AM by dkeyser

    Discovery auto import results

    dkeyser

      Hello all,

       

      New to the SDK game so I'm here with some functionality questions. I'd like to automate the addition of discovered nodes to the Orion platform. I attempting to get the DiscoveredNodes and DiscoveredInterfaces tables into my script so that I can then run through them with the addNode script.

       

      Is there a nice way to get this information into Power Shell so that I can call upon it? The variable I'm populating now is just returning nothing but the test I did for only one row of data will give me the data as long as I know the column name.

       

      Also asked this in another post but figured I'd put it here as well since it pertains to what I'm doing. The XML that gets generated and fed to the discovery now routine has a section for IsAutoImported or something like that. If I change this to true and generate the discovery will Orion finally take care of importing the results automatically?

       

      Thanks guys! Below is what I've used to get something/nothing into my variable.

       

      $imports = Get-SwisData $swis "SELECT NodeID, ProfileID, IPAddress, IPAddressGUID, SnmpVersion, SubType, CredentialID, Hostname, DNS, SysObjectID, Vendor, VendorIcon, MachineType, SysDescription, SysName, Location, Contact, IgnoredNodeID, DisplayName, Description, InstanceType, Uri

      FROM Orion.DiscoveredNodes"

        • Re: Discovery auto import results
          bluefunelemental

          I'Ve been playing with this off and on for the last week. If you are not getting anything passed are you using the correct powershell?

          Off the top of my head after your above query to populate the $imports variable you would call it then pipe for-each into to your add node script

          $imports | foreach-object { your add node script here }

          using $_.property where needed such as $_.uri or $_.ipaddress to expand for each $imports variable array

           

          ping me offline and we can figure out what might work

            • Re: Discovery auto import results
              dkeyser

              That helped immensely! I didn't realize I couldn't just output the contents to a table or was doing it wrong so it only gave me a systemdatasource message a hundred times over.

               

              I've got the first hurdle of my script working and even included some caption logic. Next is some SNMP string logic and I'll need to run this same type of ForEach-Object loop against the interfaces table. I'm looking for examples on this currently but I'm assuming it's the same format as the addNodes was and I can just change it to match the rows in the DB.

               

              Once that is tackled I get to try and make a web form so that someone can add a single node or a CSV list of nodes to the system without touching the server. Fun fun!

               

              Might have a better time using SOAP and 17778 for the single node and interface addition but I haven't even gotten started looking in that direction yet.

               

              Thank you again! Would it be alright if I ping you with questions regarding the other areas I'm going to venture into next or should I post something here first? Wouldn't want to wear out my welcome.

                • Re: Discovery auto import results
                  bluefunelemental
                  1. That's all in the SDK powershell examples - open the sample .ps1 and copy into your script. The filter portion of the script is great once you know what captions and/or types you want to avoid adding.
                  2. From the SDK.pdf in swis 1.9:
                  3. Using DiscoverInterfacesOnNode and AddInterfacesOnNode verbs
                  4. Starting with Orion NPM 10.3, SWIS provides these new verbs:

                    • Orion.NPM.Interfaces.DiscoverInterfacesOnNode
                    • Orion.NPM.Interfaces.AddInterfacesOnNode

                      These verbs provide higher-level API for adding interfaces for nodes already managed by Orion, making the process more efficient and easier. You no longer have to decide which poller types to associate with interfaces.

                      Using the first verb, you can have NPM list all available interfaces. If needed, you may filter out interfaces which you are not interested in before you pass the list to the latter verb which adds the interfaces for monitoring. For complete specifications of these verbs, see the respective sections in "Some Useful Verbs" on page 27.

                      There is an example PowerShell script demonstrating how to use these verbs in the Samples folder in the Orion SDK installation directory. The default location is
                      Installation Folder\SolarWinds\Orion SDK\Samples.

                      These verbs are provided by SWISv3 only. For additional information, see "SWIS Version 3 and 2" on page 4.

              • Re: Discovery auto import results
                dkeyser

                I've managed to get an auto discovery script working for a few hours but now it refuses to run with a provider fault. Do you have any thoughts on why this is? I've included the script I've made below for review. Though when it did work it did not show any credentials that worked int he discovered nodes table so i think there is still something wrong with the way i'm implementing the credential section.

                 

                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

                 

                 

                $StartDiscoveryCfg = ([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

                 

                 

                $out = Invoke-SwisVerb $swis "Orion.Discovery" "StartDiscovery" @($StartDiscoveryCfg)

                 

                 

                $output.innerxml

                  • Re: Discovery auto import results
                    tdanner

                    What does the "provider fault" look like?

                      • Re: Discovery auto import results
                        bluefunelemental

                        Invoke-SwisVerb : ProvideFault failed, check fault information.

                        At C:\Users\chmalone\Desktop\orion_start_discovery.ps1:74 char:23

                        + $out = Invoke-SwisVerb <<<<  $swis "Orion.Discovery" "StartDiscovery" @($StartDiscoveryCfg)

                            + CategoryInfo          : InvalidOperation: (:) [Invoke-SwisVerb], FaultException`1

                            + FullyQualifiedErrorId : SwisError,SwisPowerShell.InvokeSwisVerb

                          • Re: Discovery auto import results
                            dkeyser

                            I think I figured it out.

                             

                            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>

                                </SharedCredentialInfo>

                                <SharedCredentialInfo>

                                <CredentialID>2</CredentialID>

                                <Order>2</Order>

                                </SharedCredentialInfo>

                                <SharedCredentialInfo>

                                <CredentialID>3</CredentialID>

                                <Order>3</Order>

                                </SharedCredentialInfo>

                                <SharedCredentialInfo>

                                <CredentialID>4</CredentialID>

                                <Order>4</Order>

                                </SharedCredentialInfo>

                                <SharedCredentialInfo>

                                <CredentialID>5</CredentialID>

                                <Order>5</Order>

                                </SharedCredentialInfo>

                                <SharedCredentialInfo>

                                <CredentialID>6</CredentialID>

                                <Order>6</Order>

                                </SharedCredentialInfo>

                                <SharedCredentialInfo>

                                <CredentialID>7</CredentialID>

                                <Order>7</Order>

                                </SharedCredentialInfo>

                                <SharedCredentialInfo>

                                <CredentialID>8</CredentialID>

                                <Order>8</Order>

                                </SharedCredentialInfo>

                                <SharedCredentialInfo>

                                <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

                             

                             

                            $CoreConfigInnerPiece

                             

                             

                            $StartDiscoveryCfg = ([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>false</IsAutoImport>

                              <IsHidden>false</IsHidden>

                              <PluginConfigurations>

                                <PluginConfiguration>

                                    <PluginConfigurationItem>$CoreConfigInnerPiece</PluginConfigurationItem>

                                </PluginConfiguration>

                              </PluginConfigurations>

                            </StartDiscoveryContext>"

                            )).DocumentElement

                             

                             

                            $out = Invoke-SwisVerb $swis "Orion.Discovery" "StartDiscovery" @($StartDiscoveryCfg)

                             

                             

                            $output = $out.innerxml

                             

                             

                            $output.ToString()

                        • Re: Discovery auto import results
                          bluefunelemental

                          I copied in and got the same results - kicked it about till I got it to work - I think.

                           

                          removed $coreCfgInnerPiece

                          removed $output.innerxml

                          added $out = @() but I think that's useless here

                           

                          Try that and see if any work for you. It did import in the IP I gave it.