Edit 2020-02-11 - Moving this from the NPM forum to the appropriate forum (Orion SDK)
I'm attempting discovery via PowerShell. We’ve got a lot of teams spread through the business that are responsible for systems, so our monitoring targets add/change/remove pretty frequently and I’d prefer to have the teams that manage nodes define the monitoring criteria and not have to worry about updating the monitoring system when things change. Our NOC would accomplish the manual tasks.
The process I’m considering looks a bit like this:
- Using a CSV to define targets for discovery (ip addresses, ranges, and subnets)
- Discover all volumes & interfaces on targets that respond to SNMP
- Unmanage nodes during auto import (to prevent alerts from triggering)
- Auto import all volumes and interfaces
- Clean up interfaces and volumes using SQL/SWQL and Remove-SwisObject
- Remanage nodes
- Use PowerShell to set custom properties that define alert priorities, notification targets, etc.
I was hoping to get help with two things:
- Given the two constaints here (frequently changing targets/resources and not wanting the teams that own monitored nodes to have to regularly update the monitoring system), is this the most appropriate way to approach this?
- When I run the discovery, I’m getting volumes back as expected, but not interfaces.
Here’s the script I’m using:
# Connect to SWIS
if (!(Get-PSSnapin | Where-Object { $_.Name -eq "SwisSnapin" })) {
Add-PSSnapin "SwisSnapin"
}
if ($swis -eq $null){
$swis = Connect-Swis -Hostname localhost
}
# build the raw XML first
$header = "<CorePluginConfigurationContext xmlns='http://schemas.solarwinds.com/2012/Orion/Core' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>"
$bulklist = "<BulkList>"
$addresses = @("192.168.1.7","192.168.1.8","192.168.1.9")
foreach ($address in $addresses) {
$bulklist += "<IpAddress><Address>$($address)</Address></IpAddress>"
}
$bulklist += "</BulkList>"
# Define credentials block
$query = @"
SELECT ID
FROM Orion.Credential
WHERE Name != 'public' AND Name != 'private' AND (CredentialType = 'SolarWinds.Orion.Core.Models.Credentials.SnmpCredentialsV2' OR CredentialType = 'SolarWinds.Orion.Core.Models.Credentials.SnmpCredentialsV3')
"@
$creds = Get-SwisData $swis $query
$order = 0
$credentials = "<Credentials>"
foreach ($row in $creds) {
$order ++
$credentials += "<SharedCredentialInfo><CredentialID>$($row)</CredentialID><Order>$order</Order></SharedCredentialInfo>"
}
$credentials += "</Credentials>"
$footer = @"
<WmiRetriesCount>1</WmiRetriesCount>
<WmiRetryIntervalMiliseconds>1000</WmiRetryIntervalMiliseconds>
</CorePluginConfigurationContext>
"@
$CorePluginConfigurationContext = ([xml]($header + $bulklist + $credentials + $footer)).DocumentElement
$CorePluginConfiguration = Invoke-SwisVerb $swis Orion.Discovery CreateCorePluginConfiguration @($CorePluginConfigurationContext)
$InterfacesPluginConfigurationContext = ([xml]"
<InterfacesDiscoveryPluginContext xmlns='http://schemas.solarwinds.com/2008/Interfaces'
xmlns:a='http://schemas.microsoft.com/2003/10/Serialization/Arrays'>
<AutoImportStatus>
<a:string>Up</a:string>
<a:string>Down</a:string>
<a:string>Shutdown</a:string>
</AutoImportStatus>
<AutoImportVirtualTypes>
<a:string>Virtual</a:string>
<a:string>Physical</a:string>
</AutoImportVirtualTypes>
<AutoImportVlanPortTypes>
<a:string>Trunk</a:string>
<a:string>Access</a:string>
<a:string>Unknown</a:string>
</AutoImportVlanPortTypes>
<UseDefaults>false</UseDefaults>
</InterfacesDiscoveryPluginContext>
").DocumentElement
$InterfacesPluginConfiguration = Invoke-SwisVerb $swis Orion.NPM.Interfaces CreateInterfacesPluginConfiguration @($InterfacesPluginConfigurationContext)
# Discovery context variables
$discoveryName = 'Scripted Discovery'
$autoImport = 'true'
$EngineID = 1
$DeleteProfileAfterDiscoveryCompletes = "false"
$StartDiscoveryContext = ([xml]"
<StartDiscoveryContext xmlns='http://schemas.solarwinds.com/2012/Orion/Core' xmlns:i='http://www.w3.org/2001/XMLSchema-instance'>
<Name>$discoveryName $([DateTime]::Now)</Name>
<EngineId>$EngineID</EngineId>
<JobTimeoutSeconds>3600</JobTimeoutSeconds>
<SearchTimeoutMiliseconds>2000</SearchTimeoutMiliseconds>
<SnmpTimeoutMiliseconds>2000</SnmpTimeoutMiliseconds>
<SnmpRetries>1</SnmpRetries>
<RepeatIntervalMiliseconds>1500</RepeatIntervalMiliseconds>
<SnmpPort>161</SnmpPort>
<HopCount>0</HopCount>
<PreferredSnmpVersion>SNMP2c</PreferredSnmpVersion>
<DisableIcmp>true</DisableIcmp>
<AllowDuplicateNodes>false</AllowDuplicateNodes>
<IsAutoImport>$autoImport</IsAutoImport>
<IsHidden>$DeleteProfileAfterDiscoveryCompletes</IsHidden>
<PluginConfigurations>
<PluginConfiguration>
<PluginConfigurationItem>$($CorePluginConfiguration.InnerXml)</PluginConfigurationItem>
<PluginConfigurationItem>$($InterfacesPluginConfiguration.InnerXml)</PluginConfigurationItem>
</PluginConfiguration>
</PluginConfigurations>
</StartDiscoveryContext>
").DocumentElement
# Start Discovery
$DiscoveryProfileID = (Invoke-SwisVerb $swis Orion.Discovery StartDiscovery @($StartDiscoveryContext)).InnerText
Here’s what the OrionDiscoveryJob.log file shows for interfaces:
2020-02-10 13:35:00,937 [STP SmartThreadPool Thread #49] INFO InterfacesSnmpInventory - Starting SNMP Inventory for 192.168.1.7
2020-02-10 13:35:01,062 [STP SmartThreadPool Thread #49] INFO InterfacesSnmpInventory - SNMP Inventory for 192.168.1.7 finished after 0.1250028 seconds, 10 interfaces found
When I edit the discovery in the UI and look at monitoring settings, this is what it shows:
Before the discovery, I can open the manage nodes page, delete all listed resources for the discovered nodes and the volumes reappear after the discovery, but the interfaces never do.
Orion 2019.4 is the platform.