I need to have an automated way to r-discover all of our agentless devices. I am using the powershell SDK. Our env have 45 additional pollers for about 16K devices, Our issue is that I need to manage all interfaces that contain "MON#" in the interface descriptions, and manager all non-network disks.
I am able to create generic discoveries for all pollers well enough, but unable to configure the volume and interface rules.
If I cannot get this to work then I have to develop a way to alert when the devices and SolarWinds does not match, and manually write a re-discovery.
Here is what I have so far:
Import-Module SwisPowerShell
$username = "XXX"
$password = ConvertTo-SecureString 'XXX' -AsPlainText -Force
$creds = New-Object System.Management.Automation.PSCredential ($username, $password)
$swis = Connect-Swis -Credential $creds -Hostname XXX
$CorePluginConfigurationContext = ([xml]@"
10.155.167.247
20
1
19
2
28
3
32
4
1
1000
"@).DocumentElement
$CorePluginConfiguration = Invoke-SwisVerb $swis Orion.Discovery CreateCorePluginConfiguration @($CorePluginConfigurationContext)
$InterfacesPluginConfigurationContext = ([xml]@"
Down
Shutdown
Virtual
Physical
Trunk
Access
Unknown
{'Prop':'Descr','Op':'Regex','Val':'.*MON#.*'}
false
"@).DocumentElement
##
## {'Prop':'Descr','Op':'Regex','Val':'.*MON#.*'}
##
$InterfacesPluginConfiguration = Invoke-SwisVerb $swis Orion.NPM.Interfaces CreateInterfacesPluginConfiguration @($InterfacesPluginConfigurationContext)
$EngineID = 2
$DeleteProfileAfterDiscoveryCompletes = "false"
$StartDiscoveryContext = ([xml]@"
Script Discovery $([DateTime]::Now)
$EngineID
3600
2500
2500
1
2500000
161
0
SNMP2c
false
false
false
false
$($CorePluginConfiguration.InnerXml)
$($InterfacesPluginConfiguration.InnerXml)
"@).DocumentElement
$DiscoveryProfileID = (Invoke-SwisVerb $swis Orion.Discovery StartDiscovery @($StartDiscoveryContext)).InnerText
Write-Verbose "$(Get-Date -Format 'dd/MM/yyyy HH:mm:ss'):`t DISCOVERY profile #$DiscoveryProfileID running..."
# WAIT until the discovery completes
do {
Write-Host -NoNewline "."
Start-Sleep -Seconds 1
$Status = Get-SwisData $swis "SELECT Status FROM Orion.DiscoveryProfiles WHERE ProfileID = @profileId" @{profileId = $DiscoveryProfileID }
} while ($Status -eq 1)
$Result = Get-SwisData $swis "SELECT Result, ResultDescription, ErrorMessage, BatchID FROM Orion.DiscoveryLogs WHERE ProfileID = @profileId" @{profileId = $DiscoveryProfileID }
# PRINT the outcome
switch ($Result.Result) {
1 { "InProgress" }
2 { "Finished" }
3 { "Error" }
4 { "NotScheduled" }
5 { "Scheduled" }
6 { "NotCompleted" }
7 { "Canceling" }
8 { "ReadyForImport" }
}
$Result.ResultDescription
$Result.ErrorMessage
$ImportDiscoveryContext = ([xml]@"
false
$DiscoveryProfileID
"@).DocumentElement
$iddiscov = Invoke-SwisVerb $swis Orion.Discovery ImportDiscoveryResults @($ImportDiscoveryContext)
Invoke-SwisVerb $swis Orion.Discovery GetImportDiscoveryResultsProgress @($iddiscov)