This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

Orion SDK Performance Tips

We just got a developer that will be working to develop helpful programs to aid us in administering our Orion environment.  For now though we use a lot of PowerShell scripts that I write to automate many tasks, usually those tasks are automating custom properties.  One issue I run into often is my PowerShell scripts take a long time to run.  I've gotten better at improving my code to loop through items less often and things like that, but I'm looking for some additional tips.

- When I'm invoking verbs, specifically the Set-SwisObject verb, am I able to send multiple objects to this, or do I need to do one object at a time?  I know I can send multiple properties for a single node to it, but can I just send a whole hash table full of Node Custom Property URI's, Properties, and their desired values at it, or is looping through each node necessary?  If so how should this look?

- Same question with other verbs?

- Our Developer will be re-creating my PowerShell scripts into more robust .Net Programs using C# mostly.  Are there any general performance tips for interacting with the API via C#?

- Any general performance tips for the API in general or just the API via PowerShell?

Thanks for any assistance you may be able to offer.

  • Interesting question xtraspecialj​! It's actually something I was thinking of doing a post on at some stage (my plan is to do some tests with a few different techniques, and then compare the efficiency of the approaches).

    If we consider the 2 approaches below for example, I know the second approach is faster than the first, because whereas the first it's handling them one at a time, in the second SWIS is handling a lot of hte overhead directly. It's not X times faster (because of auditing, etc), but still should be faster than the first. (As in the cmdlets were designed to accept URIs from the pipeline, so should be faster)

    1. 1.$uris |foreach { Set-SwisObject $swis $_ -Properties @{UnmanageFrom=$start;UnmanageUntil=$end} }
    2. 2.$uris | Set-SwisObject $swis -Properties @{UnmanageFrom=$start;UnmanageUntil=$end}

    Same should apply for remove-swisobject. As far as I'm aware C# doesn't have pipleline equivalance, so that's another hurdle to jump

    tdanner​ is obviously the guru on this however, I may be wrong on the above.

  • This is all correct.

    If you want to work in C#, you will be targeting the REST API instead of the PowerShell API. They are similar and you can do batch operations that way as well. The REST equivalent to "$uris | Set-SwisObject ..." is a BulkUpdate request. You can see what that looks like on the wiki: https://github.com/solarwinds/OrionSDK/wiki/REST#bulkupdate-request .

  • Ahh, OK, so I can just send a group of URI's to the verb as long as the same properties and values are being set?  So the script would need to go through, evaluate all of the objects and determine what properties and values need to be set, then group the objects based on this and set them in groups.  OK, so there is no way to pipe a hash table to these verbs with URI's, properties, and values then, correct?  Not without doing a foreach loop, right?

  • Right - in one operation you can set the same properties and values on a set of objects. If you need to set different values then you will have to use a loop. SWIS doesn't have a way to accept different values for different objects in a single operation.

    (A note on terminology: in SWIS we use the term "verb" to refer to things like Orion.AlertActive.Acknowledge or Orion.AgentManagement.Agent.Deploy that are part of the schema.)

  • xtraspecialj​ key thing I like to remember is that the URI's are kinda the most important thing when using the *-swisobject cmdlets, as they are basically the identifier that the tasks run