Quantcast
Viewing all 2677 articles
Browse latest View live

REST Orion.NPM.Interfaces/DiscoverInterfacesOnNode - ifOperStatus

Hello Orion SDK Community,

 

I'm using the Orion.NPM.Interfaces/DiscoverInterfacesOnNode verb - when I take a look at the discovery results, I get ifOperStatus = 4 for all interfaces.

 

Upon adding those interfaces with the AddInterfacesOnNode verb - the interfaces show a different status. Wondering if this is this a bug or by design?

When using the GUI/List resources, there is an indicator of the interface status (up/down shown as green/red).

 

I'm wanting to use the DiscoverInterfacesOnNode verb to list all interfaces, filter based on ifType and ifOperStatus (let's say for example, IfType = 6 and ifOperStatus = 1) and then add the resulting interfaces. This would allow me to filter based on interface status/other attributes.


For now, I am using another loop after the interfaces are added to query URI based on status and delete in bulk , but would prefer to do this all in one step if possible.

 

Thank you,

 

=swql

 

 

 

 


SWSQL or TSQL to Delete a Node from Solarwinds Tables when the Node is no longer in Active Directory

I am trying to find a way to delete a node from Solarwinds, using Powershell, TSQL or SWSQL. I would download a list of Nodes in Active Directory that are currently joined to the domain. This would allow Solarwinds to stop monitoring, and alerting, on Nodes that have been removed from the Domain. This is a common problem for us since we use Solarwinds to monitor our Public PCs at the Columbus Library. We are using NPM 12.2

Set-SwisObject : The given key was not present in the dictionary.

Hi, I try to update Alias/Comments for IP but I get error: Set-SwisObject : The given key was not present in the dictionary.

 

Import-Module SwisPowerShell

 

[String]$swisConnectHost = 'localhost'

[String]$swisConnectUserName = 'admin'

[String]$swisConnectPassword = ''

[String]$targetSubnet = '10.0.0.0'

[String]$targetSubnetCIDR = '24'

[string]$IPHostname = 'VM-test-01'

[string]$IPComments = 'Reserved by ServiceNow'

 

$swis = Connect-Swis -UserName $swisConnectUserName -Password $swisConnectPassword -Hostname $swisConnectHost

 

$IP = Invoke-SwisVerb $swis IPAM.SubnetManagement StartIpReservation @($targetSubnet, $targetSubnetCIDR, "0") -Verbose

 

try {

    Invoke-SwisVerb -SwisConnection $swis -EntityName IPAM.SubnetManagement -Verb ChangeIpStatus @($IP, "Blocked") -Verbose

} Catch {

    $_.Exception.ExceptionMessage

}

 

 

try {

    Invoke-SwisVerb -SwisConnection $swis -EntityName IPAM.SubnetManagement -Verb FinishIpReservation @($IP, "Reserved") -Verbose

} Catch {

    $_.Exception.ExceptionMessage

}

 

 

$IPtoIdQuery = "SELECT IpNodeId FROM IPAM.IPNode where IPAddress like '"+ $($Ip.'#text') +"'"

$IPAMNode =  Get-SwisData -SwisConnection $swis -Query $IPtoIdQuery

$URI = 'swis://localhost/Orion/IPAM.IPNode/IpNodeId='+$IPAMNode

 

# Setting IP Node properties needed Admin rights

Set-SwisObject $swis -Uri $URI -Properties @{ Comments = $IPComments }

 

It's very simple operation, I don't know what is wrong. Please help.

SWIS REST/JSON API

Starting with NPM 10.4, SWIS now supports a REST/JSON API in addition to the existing SOAP API. The operations supported by each API are identical: the six basic operations of Query, Invoke, Create, Read, Update, and Delete; and the data you can access through each API is the same. The difference is that the REST/JSON API avoids the complexities of XML and SOAP, though it gives up the ability to have a client wrapper generated from WSDL.

 

Both APIs will be supported by the product indefinitely - the SOAP API is not deprecated or replaced by the REST API.

 

Request and Response Formats

Query

Request

GET https://localhost:17778/SolarWinds/InformationService/v3/Json/Query?query=SELECT+Uri+FROM+Orion.Pollers+ORDER+BY+PollerID+WITH+ROWS+1+TO+3+WITH+TOTALROWS HTTP/1.1
Authorization: Basic YWRtaW46
User-Agent: curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3
Host: localhost:17778
Accept: */*

Response

HTTP/1.1 200 OK
Content-Length: 244
Content-Type: application/json
Server: Microsoft-HTTPAPI/2.0
Date: Fri, 27 Jul 2012 19:38:52 GMT
{"totalRows":13,"results":[{"Uri":"swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=4"},{"Uri":"swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=6"},{"Uri":"swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=7"}]}

 

Body reformatted for easier reading
{

 

    "totalRows": 13,

    "results": [

        { "Uri": "swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=4"},

        { "Uri": "swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=6"},

        { "Uri": "swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=7"}

    ]

}

Query with Parameters

Request

POST https://localhost:17778/SolarWinds/InformationService/v3/Json/Query HTTP/1.1
Authorization: Basic YWRtaW46
User-Agent: curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3
Host: localhost:17778
Accept: */*
Content-Type: application/json
Content-Length: 130
{"query":"SELECT Uri FROM Orion.Pollers WHERE PollerID=@p ORDER BY PollerID WITH ROWS 1 TO 3 WITH TOTALROWS","parameters":{"p":9}}

 

Response

HTTP/1.1 200 OK
Content-Length: 99
Content-Type: application/json
Server: Microsoft-HTTPAPI/2.0
Date: Tue, 07 Aug 2012 17:36:27 GMT
{"totalRows":1,"results":[{"Uri":"swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=9"}]}

Invoke

Request

POST https://localhost:17778/SolarWinds/InformationService/v3/Json/Invoke/Metadata.Entity/GetAliases HTTP/1.1
Authorization: Basic YWRtaW46
User-Agent: curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3
Host: localhost:17778
Accept: */*
Content-Type: application/json
Content-Length: 39
["SELECT B.Caption FROM Orion.Nodes B"]

Response

HTTP/1.1 200 OK
Content-Length: 19
Content-Type: application/json
Server: Microsoft-HTTPAPI/2.0
Date: Fri, 27 Jul 2012 19:23:27 GMT
{"B":"Orion.Nodes"}
Image may be NSFW.
Clik here to view.

The Metadata.GetAliases verb takes one string argument and returns a PropertyBag.

Create

Request

POST https://localhost:17778/SolarWinds/InformationService/v3/Json/Create/Orion.Pollers HTTP/1.1
Authorization: Basic YWRtaW46
User-Agent: curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3
Host: localhost:17778
Accept: */*
Content-Type: application/json
Content-Length: 92
{"PollerType":"hi from curl 2", "NetObject":"N:123", "NetObjectType":"N", "NetObjectID":123}

Response

HTTP/1.1 200 OK
Content-Length: 69
Content-Type: application/json; charset=utf-8
Server: Microsoft-HTTPAPI/2.0
Date: Fri, 27 Jul 2012 19:27:11 GMT
"swis:\/\/tdanner-dev.swdev.local\/Orion\/Orion.Pollers\/PollerID=19"

Read

Request

GET https://localhost:17778/SolarWinds/InformationService/v3/Json/swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=6 HTTP/1.1
Authorization: Basic YWRtaW46
User-Agent: curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3
Host: localhost:17778
Accept: */*

Response

HTTP/1.1 200 OK
Content-Length: 245
Content-Type: application/json
Server: Microsoft-HTTPAPI/2.0
Date: Fri, 27 Jul 2012 19:30:02 GMT
{"PollerID":6,"PollerType":"V.Details.SNMP.Generic","NetObject":"V:1","NetObjectType":"V","NetObjectID":1,"DisplayName":null,"Description":null,"InstanceType":"Orion.Pollers","Uri":"swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=6"}

Update

Request

POST https://localhost:17778/SolarWinds/InformationService/v3/Json/swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=6 HTTP/1.1
Authorization: Basic YWRtaW46
User-Agent: curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3
Host: localhost:17778
Accept: */*
Content-Type: application/json
Content-Length: 29
{"PollerType":"hi from curl"}

Response

HTTP/1.1 200 OK
Content-Length: 0
Server: Microsoft-HTTPAPI/2.0
Date: Fri, 27 Jul 2012 19:32:06 GMT

Delete

Request

DELETE https://localhost:17778/SolarWinds/InformationService/v3/Json/swis://tdanner-dev.swdev.local/Orion/Orion.Pollers/PollerID=16 HTTP/1.1
Authorization: Basic YWRtaW46
User-Agent: curl/7.20.0 (i386-pc-win32) libcurl/7.20.0 OpenSSL/0.9.8l zlib/1.2.3
Host: localhost:17778
Accept: */*

Response

HTTP/1.1 200 OK
Content-Length: 0
Server: Microsoft-HTTPAPI/2.0
Date: Fri, 27 Jul 2012 19:37:33 GMT
Image may be NSFW.
Clik here to view.

Solarwinds Integration with Netcool

We have project of Integrating all EMS/NMS to Netcool for umbrella monitoring. Can you assist to provide info about Solarwind, whether is capable of being integrated to Netcool; is NBI feature available? If yes, is enabled? What are requirements to enable NBI, licenses required, protocol to use like CORBA/SNMP.

Network Discovery returning Unknown

Hi, I am trying to modify the sample discovery powershell script in the Orion SDK package in hopes of automating our network discovery tasks. I am trying to feed the IP addresses from a .csv and the credentials from the Orion DB, but so far is getting Unknown results only. Hope someone can help and maybe you'll find something wrong in this portion of the code. Thanks so much in advance.

 

$credlist = Get-SwisData $swis "SELECT ID FROM Orion.Credential" | % {"<SharedCredentialInfo>

<CredentialID>$_</CredentialID>

<Order>$_</Order>

</SharedCredentialInfo>"}       

 

$ipcontainer = import-csv -Path "$($env:USERPROFILE)\ScanResults_20190124.csv" | Select-Object 'Address'| % {$_ -replace "@{Address=",""} | % {$_ -replace "}",""} | % {"<IPAddress>

<Address>$_</Address>

</IPAddress>"}

 

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

<BulkList>

        $ipcontainer

</BulkList>

<Credentials>

     $credlist

</Credentials>

<WmiRetriesCount>1</WmiRetriesCount>

<WmiRetryIntervalMiliseconds>1000</WmiRetryIntervalMiliseconds>

</CorePluginConfigurationContext>"

 

$CorePluginConfigurationContext = ([xml]$InitialCorePluginXml).DocumentElement

 

$CorePluginConfiguration = Invoke-SwisVerb $swis Orion.Discovery CreateCorePluginConfiguration @($CorePluginConfigurationContext)

 

$StartDiscoveryContext = ([xml]"

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

<Name>Test Script Discovery $([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>false</DisableIcmp>

<AllowDuplicateNodes>false</AllowDuplicateNodes>

<IsAutoImport>false</IsAutoImport>

<IsHidden>false</IsHidden>

<PluginConfigurations>

<PluginConfiguration>

<PluginConfigurationItem>$($CorePluginConfiguration.InnerXml)</PluginConfigurationItem>

</PluginConfiguration>

</PluginConfigurations>

</StartDiscoveryContext>

").DocumentElement

Image may be NSFW.
Clik here to view.

After running powershell script to add group and members, the members do not show up

I am using a powershell script to add a group and a dynamic query to add members to that group.  The group is added, but no members show up.  If it edit the group, I can see the dynamic query was created.  I edit the dynamic query and I can see that the query is accurate.  If I hit save, then the members show up now.  It seems like the script adds the config in correctly, but doesn't "apply" it.  I am using the standard script I found online that everyone else says works.  I am on 2018.4 and was wondering if there is a bug in the latest version that is causing this.  Here is my script to add just one group/members.

 

import-module SwisPowerShell

# Connect to SWIS

$hostname = <Removed>

$swis = Connect-Swis -host $hostname

$GroupName = <Removed>

#

# CREATING A NEW GROUP

#

$members = @(

    @{ Name = $GroupName; Definition = "filter:/Orion.Nodes[CustomProperties.NMS_Role=$GroupName]" }

)

 

 

$groupId = (Invoke-SwisVerb $swis "Orion.Container" "CreateContainer" @(

    # group name

    "Building - $GroupName",

 

 

    # owner, must be 'Core'

    "Core",

 

 

    # refresh frequency

    60,

 

 

    # Status rollup mode:

    # 0 = Mixed status shows warning

    # 1 = Show worst status

    # 2 = Show best status

    0,

 

 

    # group description

    "Devices that are located in building $GroupName",

 

 

    # polling enabled/disabled = true/false (in lowercase)

    "true",

 

 

    # group members 

    ([xml]@( 

       "<ArrayOfMemberDefinitionInfo xmlns='http://schemas.solarwinds.com/2008/Orion'>", 

       [string]($members |% { 

         "<MemberDefinitionInfo><Name>$($_.Name)</Name><Definition>$($_.Definition)</Definition></MemberDefinitionInfo>" 

         } 

       ), 

       "</ArrayOfMemberDefinitionInfo>" 

    )).DocumentElement 

  )).InnerText 

Image may be NSFW.
Clik here to view.

What is the curl command to update my fetched available IP address as reserved or used

I am using the following curl command which is fetching me the first available IP address from my subnet ID.

 

curl -k -v -u "myuser:password" https://mysolarwinds:17778/SolarWinds/InformationService/v3/Json/Query?query=SELECT+TOP+1+STATUS,+DisplayName+FROM+IPAM.IPNode+WHERE+Status=2+AND+SubnetId=10

 

Output

* About to connect() to mysolarwinds port 17778 (#0)

*   Trying mysolarwinds...

* Connected to mysolarwinds (mysolarwinds) port 17778 (#0)

* Initializing NSS with certpath: sql:/etc/pki/nssdb

* skipping SSL peer certificate verification

* SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384

* Server certificate:

*       subject: CN=SolarWinds-Orion

*       start date: Nov 23 00:21:10 2017 GMT

*       expire date: Dec 31 23:59:59 2039 GMT

*       common name: SolarWinds-Orion

*       issuer: CN=SolarWinds-Orion

* Server auth using Basic with user 'myuser'

> GET /SolarWinds/InformationService/v3/Json/Query?query=SELECT+TOP+1+STATUS,+DisplayName+FROM+IPAM.IPNode+WHERE+Status=2+AND+SubnetId=100 HTTP/1.1

> Authorization: Basic XYZW245R

> User-Agent: curl/7.29.0

> Host: mysolarwinds:17778

> Accept: */*

>

< HTTP/1.1 200 OK

< Content-Length: 56

< Content-Type: application/json

< Server: Microsoft-HTTPAPI/2.0

< Date: Wed, 19 Dec 2018 13:06:40 GMT

<

* Connection #0 to host mysolarwinds left intact

{"results":[{"STATUS":2,"DisplayName":"10.248.1.10"}]}

 

Now what do I have to do to my above curl commad to mar the fetched IP address as reserved or used, so that next time when I run the above command it will fetch the second IP instead of he first one. Kindly assist me on this

 

Thanks and Regards,

Azhar


What is the curl command to update MAC and Hostname as used in Solarwinds

Hi Team,

     Could you please let me know what curl command I can use to mark the MAC and Hostname of my vm as used, so that solarwinds can update DHCP accordingly. Our setup has Solarwinds integrated with DHCP, so once we mark the IP,MAC and Hostname as Available or Used, it will get reflected on our DHCP server

     I currently use the following curl command for updating my IP address

curl -k -v -u "myuser:password" -d '["10.248.1.10","Used"]' -H "Content-Type: application/json" https://mysolarwinds:17778/SolarWinds/InformationService/v3/Json/Invoke/IPAM.SubnetManagement/ChangeIPStatus

 

Kindly assist on this

 

Thanks and Regards,

Azhar

Image may be NSFW.
Clik here to view.

Update Alert Notes via SDK

Ahoy,

I am trying to figure out how I can update an alert's note via the SDK and I'm not having much luck getting it done. I am trying to integrate a specific alert with our ticket system so that when a ticket is opened on this specific alert, the ticket system performs an HTTP POST to Orion to post the ticket ID into the alert notes. Now, I know that there seem to be two types of 'notes' in alerts - the view in the database shows 'Notes' and 'AlertNotes'. I want to be able to overwrite whatever is in the 'Notes' column with just the 6-digit ticket ID. Here is what I have so far:

 

I copied a previously configured POST update from my ticket system which updates some custom properties, but replaced the SWIS URL with what I thought was the right schema. As a test, I am using cURL on a server to make the POST:

 

curl -v -X POST -H "Content-Type: application/json" -k -u user:pass -d '{"Notes":"123456"}' https://orion-server:17778/SolarWinds/InformationService/v3/Json/swis://orion-server/Orion/Orion.AlertStatus/AlertObjectID=7849

 

This is the error that I get back:

 

{"Message":"Invalid key properties specified for entity Orion.AlertStatus.\u000d\u000aParameter name: filter","ExceptionType":"System.ArgumentException","FullException":"System.ArgumentException: Invalid key properties specified for entity Orion.AlertStatus.\u000d\u000aParameter name: filter\u000d\u000a   at SolarWinds.InformationService.Core.SwisUriResolver.ValidateAndResolveFilter(IEntityType entity, SwisUriFilter filter, Boolean isHosted)\u000d\u000a   at SolarWinds.InformationService.Core.SwisUriResolver.ValidateAndResolveUri(SwisUri uri, IQueryExecutionContext context)\u000d\u000a   at SolarWinds.InformationService.Core.SwisUriResolver.GetResolver(SwisUri uri, Boolean queryKeysOnly, IQueryProcessor queryProcessor, IQueryPlanCache queryPlanCache, IQueryExecutionContext context)\u000d\u000a   at SolarWinds.InformationService.Core.CrudProcessor.Update(SwisUri uri, IDictionary`2 propertiesToUpdate, IQueryExecutionContext context)\u000d\u000a   at SolarWinds.InformationService.Core.InformationService.Update(S*

 

I am not sure what this all means. Any assistance understanding will be much appreciated.

Image may be NSFW.
Clik here to view.

SWQL Studio connection issues after migrating to a new primary polling engine

We recently migrated Solarwinds off of a Win 2012 R2 system to a Windows 2016 system.  After the migration we can't establish a connection to the DB via SWQL Studio.

 

When we login we get the following error:

 

Unable to connect to Information Service.

An error occurred when verifying security for the message

Can anyone point me in the write direction on how to resolve this issue?

Image may be NSFW.
Clik here to view.

Python command to create dependencies

in a old post found the following command: but what's the existing one please

 

$swis = Connect-Swis -UserName admin -Password ''

 

New-SwisObject $swis Orion.Dependencies @{Name="test1";ParentUri='swis://tdanner-dev.swdev.local/Orion/Orion.Nodes/NodeID=1';ChildUri='swis://tdanner-dev.swdev.local/Orion/Orion.Nodes/NodeID=2'}

SolarWinds SDK Powershell WMI Add script

I'm having trouble with adding nodes using powershell.  I've started with the CRUD.AddWMINode.ps1 script and am able to get all the information to go in properly but the authenticated user is not set on the node.

 

I think I've narrowed it down to the user definitions.  I came to this conclusion by running the commands separately and there are 3 values that return for my user name, 2 of which are owned by "Orion".  I've tried setting the ID number for the variable but that didn't make a difference.

 

$credentialName = "ValidCredentialName"

$credentialId = Get-SwisData$swis"SELECT ID FROM Orion.Credential where Name = '$credentialName'"

 

I've seen people have similar issues and it doesn't seem to have been resolved.  I'm hoping someone can tell if the issue is in the script or something miss configured in the app.

 

Thanks in advance.

 

Charlie

Update SecureCRT using SW

Image may be NSFW.
Clik here to view.

Use SDK to assign credentials and run NCM job

Hello,

I am trying to programmatically run NCM jobs via the SDK.  The primary reason is because I am trying to increase the security of how I run jobs.  I want to create a script that runs jobs only with the lowest rights credentials (on the target system) that are needed to perform the task.  I can see verbs that start and update jobs, but I don't see a place where I can change the credentials other than in the NCM.NodeProperties table. So would I need to create a script that:

 

1) Selects the Nodes in Question

2) Updates the Connection Profile ID to what I want to use

3) Run the Job via StartJob verb in Cirrus.NCM_NCMJobs

4) Check for Job Completion (GetJobStatus verb)

5) Change ConnectionProfile back (if needed)

 

I have a few questions.  What do these verbs above need for inputs, just the JobID?  I see the value in the table but wanted to check if it needed anything else.

Also what does the UpdateJob/CreateJob need?

Where is the connectionProfile information stored?  I don't see it in the NCM, or Cirrus tables.

 

Thanks


Is there a way to integrate or pull creditials from Cyberark to Solarwinds?

My company uses Cyberark and when talking with the Solarwinds Engineers, they seem unsure of how to pull credentials from Cyberark and create them in Solarwinds. This is sort of a deal breaker for us and I REALLY want to switch off of our current solution to Solarwinds.

Image may be NSFW.
Clik here to view.

[Python] How to create a subnet into the smallest available supernet?

Pretty much the above. Does anyone know a nice way to create subnets into a most specific supernet?

Unmanage nodes with Powershell

I'm trying to unmanage agents with powershell using the sdk and the following thwack: SW PowerShell Bulk Unmanage API script

 

The script runs but I don't see the node unmanaged in the UI. Is there a way for me to check the node status in powershell to confirm if the script worked? I'm thinking the UI doesn't get updated frequently.

Image may be NSFW.
Clik here to view.

Unable to put nodes in maintenance mode with SDK since upgrading

I now get an error from the power shell script i got from the sdk github page. Here is the error i'm getting.

 

Get-SwisData : An error occurred when verifying security for the message.

At line:19 char:13

+     $uris = Get-SwisData $swis $strQuery

+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (:) [Get-SwisData], MessageSecurityException

    + FullyQualifiedErrorId : SwisError,SwisPowerShell.GetSwisData

 

here is line 18 and 19

    [String]$strQuery = "SELECT uri FROM Orion.Nodes WHERE SysName LIKE '" + "$server" + "%'" 

    $uris = Get-SwisData $swis $strQuery

 

 

Does anyone have any idea why i'm getting this since upgrading to Orion Platform 2018.4 HF1. Here is the full script

 

#Region PSSnapin presence check/add 

if (!(Get-PSSnapin -Name "SwisSnapin" -ErrorAction SilentlyContinue)) 

{     

    Add-PSSnapin SwisSnapin -ErrorAction SilentlyContinue 

#EndRegion 

$serverlist = Get-Content -Path "C:\Temp\unmanageservers.txt" 

$username = "user"

$password = "password"

$secstr = New-Object -TypeName System.Security.SecureString

$password.ToCharArray() | ForEach-Object {$secstr.AppendChar($_)}

$cred = new-object -typename System.Management.Automation.PSCredential -argumentlist $username,$secstr

 

$strOrionServer="solarwinds" 

$swis = Connect-Swis -Hostname $strOrionServer -Credential $cred

foreach($server in $serverlist){ 

 

    [String]$strQuery = "SELECT uri FROM Orion.Nodes WHERE SysName LIKE '" + "$server" + "%'" 

    $uris = Get-SwisData $swis $strQuery

 

 

    $uris | ForEach-Object { Set-SwisObject $swis $_ @{Status=9;Unmanaged=$true;UnmanageFrom=[DateTime]::UtcNow;UnmanageUntil=[DateTime]::UtcNow.AddHours(2)}}  

}

Using PowerShell and the API to clean-up down volumes and find new volumes for those devices.

I don't know about yourselves, but we suffer with volumes reporting as down and Orion not picking up on their new instances automatically.

We think this is down to VM migrations or just configuration changes.

 

I used to go through a process of using SQL to find the dead volumes, then going to Node Manager, removing the down volumes and then running List Resources against the node to pick up on the new drive instances. This was a long winded and slow process, with an average of 140 down volumes found every week.

So I thought to myself, this needs some automation!

 

Steps:

 

1. Find the down Volumes with a bit of SWQL

2. Remove these volumes using the API

3. Create URLs for each NodeID (found with down volumes) to open the 'List Resources' in a internet browser, with auto-refresh, so that you can manually select the volumes.

    As you can't do this via the API yet.

 

So here's a PowerShell script, that hopefully you can use to assist you.

Relies on having Chrome installed, to change chrome.exe to delete the Stat-Process chrome.exe line and un-comment the iexplorer.exe line.

The SELECT statement is limited to the first 10 down volumes, this limits the script to opening 10 List Resources at a time. You may want to increase or decrease this number.

 

Please ensure that you test this, somewhere safe, as I wouldn't want you to break anything.

 

 

# Description: SWIS PowerShell to find , then delete and then open the List Resources for that Node, so we can reselect the hard drives manually.

# Author: Richard Graham

# Date: 2019/02/06

# Notes: How-To make an encypted password file - https://www.altaro.com/msp-dojo/encrypt-password-powershell/

 

#Load SwisSnapin if required

if ( (Get-PSSnapin -Name SwisSnapin -ErrorAction SilentlyContinue) -eq $null )

      { Add-PSSnapin SwisSnapin }

 

#Alter these variables to suit your environment

$server = '<FQDN of Orion>'                                                # Your Orion server

$user ='SWISuser'                                                                # Orion username

$file = 'C:\Users\admin\encrypted-password.bin'                  # Orion user encrypted password file, see Notes for URL on how-to

$outfile = 'C:\Users\admin\resource_links.txt'                  

 

#URL link

$resourcelink = 'http://' + $server + '/Orion/Nodes/ListResources.aspx?Nodes='

 

If ([System.IO.File]::Exists($outfile))

   { Remove-Item $outfile }

 

#Read encrypted file into $credential - see Notes for URL on how-to

$password = Get-Content $file | ConvertTo-SecureString

$creds = New-Object System.Management.Automation.PsCredential($user,$password)

 

#SWIS connection string

$swis = Connect-Swis -host $server -Credential $creds

 

#Get the down volume details

$results = Get-SwisData $swis "TOP 10 SELECT Uri, FullName, NodeID, VolumeID FROM Orion.Volumes WHERE Status = 2"

#$results = Get-SwisData $swis "SELECT Uri, FullName, NodeID, VolumeID FROM Orion.Volumes WHERE Status = 2"

 

#If no down Volumes then exit

Write-Host "There were" $results.Count "volumes reporting as down"

If ($result -eq $null) {exit(0)}

 

#Remove dead volumes and create resource URL file

ForEach ($result IN $results)

         {

           #Write-Host $result.FullName "(NodeID :" $result.NodeID "VolumeID :" $result.VolumeID ") is down"

   

           #Delete Down VolumeIDs

           Write-Host "Deleting VolumeID:" $result.FullName

           Remove-SwisObject $swis -Uri $result.Uri

 

           #List resources for $result.NodeID adding all disk volumes (not memory, swap, etc)

           #This function is not yet available via the API, so we'll output URLs to file

           $link = $resourcelink + $result.NodeID + '&ForceRefresh=true'

           Out-File -Append -FilePath $outfile -InputObject $link

         }

 

#Sort $outfile to be unique URLs

$unique = Get-Content $outfile | Sort | Get-Unique

Out-File -FilePath $outfile -InputObject $unique

 

#And then open Chrome tabs for each List Resources URL (make sure you are logged into Orion web GUI first)

$urls = Get-Content $outfile

ForEach ($url in $urls)

        { Start-Process "chrome.exe" $url

          #Start-Process 'C:\Program Files (x86)\Internet Explorer\iexplore.exe' $url

         }

Image may be NSFW.
Clik here to view.
Viewing all 2677 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>