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.

Using PowerShell To Automatically Provision A Series Of Graphs Per View

For the past many moons, I have been searching for a way to improve our process of adding/viewing graphs. Our Engineer(s) ask to see views with various graphs, from many different nodes/interfaces, together in a single place. Over the years, this has piled up into too many views to manage. We have come up with various different solutions, mostly outside of SolarWinds, as well as attempting to utilize PerfStack, and a few other native SolarWinds options. Currently, we are exploring 2 different paths, with the expectations of utilizing both paths, depending on what is needed.

The first path will be an "On-The-Fly" path, so to speak. This option was developed internally, so I cannot go into too much detail. However, it will basically be used for quick troubleshooting, as it will generate a page of graphs based on the results returned from a master query. The first page allows you to select various options, applying filters for each to the query. Then you submit that page, and the following page builds a graph for each result returned, all on a single page. This allows us to quickly view different scenarios, areas, groups, etc. without actually having to put the time in to build the graphs.

Here is a link to get a better idea of our process for this path: Generating Graphs Dynamically

The second path, on the other hand, will be pretty much the exact opposite. We will use this path when we need to build a static page of graphs. Previously, in order to build this page of graphs, we would need to edit the view, add the custom object resource, copy that resource, then customize the resource. Afterwards, we would need to repeat these steps to create an identical graph for a different interface. If we needed to build a page of 10 graphs for different interfaces, this process would take far more time than necessary. We could build the graph how we want it, copy it, and then go through and change the interface on the copied graphs. I say "could" because there is some sort of long standing "bug" that basically resets the graph to default, removing all settings, any time you go in to edit the graph. Ideally, we would just want to define a page to produce a specific type of graph for ANY item returned, either from a view limitation, or a query. Instead, we have come up with a way in between the two. The following process will let you build, in bulk, many graphs on a view. Each graph can be the same, or you can have a page of various graph types. Everything is based on the custom property values you assign to the interfaces.

Let's get started:

ESTIMATED TIME TO INSTALL/PERFORM MODIFICATION: <15 Minutes

DIFFICULTY LEVEL: 2-Padawan

  1. Youngling (Easiest/Most Basic; no coding experience required, no config wizard required, no system restart required, no system downtime.)
  2. Padawan (Easy/Basic; no coding experience required, possible config wizard required, possible system/services restart required, limited/no downtime.)
  3. Jedi Knight (Moderately Difficult/Advanced; some coding experience required/recommended, config wizard required, possible system/services restart required, limited/short duration downtime.)
  4. Jedi Master (Most Difficult/Advanced; advanced coding experience required, config wizard required, system/services restarts required, 30+ minutes downtime/maintenance window recommended, and other things that I do not even know I would need to know, required...)

What do you need?

  1. Orion SDK (Installed on your Primary Orion Server) Releases · solarwinds/OrionSDK · GitHub
  2. PowerShell (Installed on your Primary Orion Server) Download Windows Management Framework 5.1 from Official Microsoft Download Center
  3. Interface Custom Properties (6 of them)
  4. This PowerShell script (Located at the bottom of this post)
  5. Advanced Alert - Interface (Also located at the bottom of this post)

Custom Properties:

You must create the following interface custom properties:

GraphType     Text

GraphViewID     Integer Number

GraphViewIDColumn     Integer Number

GraphViewIDCreate     Yes/No

GraphViewIDRow     Integer Number

GraphViewProcessed     Yes/No

Setting "GraphType" to use a drop down select box, add the following values as options to select:

MMAvgPps

TotalPackets

AvgBps-Line

AvgBps-Step

MMAvgBps

AvgUtil-Step

MMAvgUtil

TotalBytesBar

AvgPps

TotalPackets

InterfaceErrors

InterfaceDiscards

These custom properties are going to drive the script, determining which types of graph(s) to build, as well as the column(s), and/or row(s), in which to build the graph(s).

Interface_Custom_Properties-001.png

The PowerShell Script:

In my example, I have the script simply located in the root/"C" drive.

C:\New-SW_Add_Interface_Graphs_To_View_v2-1_CPvars.ps1

The Advanced Alert:

This alert is what will trigger the script to build the graphs. This is configured to trigger/alert on Interfaces. This entire process can easily be adapted to run on nodes, volumes, or pretty much any other elements which have graphs/graph types.

Trigger Condition:

Scope:

GraphType = is not empty

GraphViewID = is greater than 0

GraphViewIDColumn = is greater than 0

GraphViewProcessed = is equal to No

GraphViewIDRow = is empty OR is equal to 0

Trigger:

GraphViewIDCreate = is equal to Yes

Edit Alert - _Copy of 000-Auto_Interface_Graphing-000__20180319_0834.png

Reset Condition:

GraphViewProcessed = is equal to Yes

Edit Alert - _Copy of 000-Auto_Interface_Graphing-000__20180319_0840.png

Trigger Actions:

     Run the script

     Change CP Value

     Change CP Value

This is what I have working as the command, when executing external program:

C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -Command "C:\New-SW_Add_Interface_Graphs_To_View_v2-1_CPvars.ps1 "${N=SwisEntity;M=InterfaceID} ${N=SwisEntity;M=CustomProperties.GraphViewID} ${N=SwisEntity;M=CustomProperties.GraphType} ${N=SwisEntity;M=CustomProperties.GraphViewIDColumn}

Then we change GraphViewProcessed to Yes.

(Optional)

I have a 3rd action that logs the interface/view information, which I had been using during testing.

The ${N=Alerting;M=AlertName} Alert Created A New Graph In Row ${N=SwisEntity;M=CustomProperties.GraphViewIDColumn} Of Column ${N=SwisEntity;M=CustomProperties.GraphViewIDColumn} On ViewID ${N=SwisEntity;M=CustomProperties.GraphViewID} For Node/Interface ${N=SwisEntity;M=FullName}.

Edit Alert - _Copy of 000-Auto_Interface_Graphing-000__20180319_0843.png

Finally, to finish out the alert, we change the GraphViewIDCreate value to No.

Edit Alert - _Copy of 000-Auto_Interface_Graphing-000__20180319_0848.png

Play Time?

Now, we should have everything completed to a point where we can start seeing the benefits of our hard work. Next stop, the Custom Property Editor.

While there are many ways to mange the various settings we need, in order to trigger the alert/script, I find the custom property editor does the trick nicely. It allows us to pull elements, and filter/sort of multiple points.

Either navigate to the "Manage Custom Properties" page, from the Admin/Settings page, or add the following URL to your server hostname/IP.

/Orion/Admin/CPE/Default.aspx

Now that you're on the Manage Custom Properties page, group by Object, select Interfaces, and select the "Graph*" properties we need to work with.

You can jump directly to the Custom Property Editor, /Orion/Admin/CPE/InlineEditor.aspx, however, I find going through the manage CP page helpful, as it is a quicker way to add the CPs we need to work with.

Manage Custom Properties_20180319_0856.png

Clicking the View/Edit Values button will take you to the Custom Property Editor page, which we will use to select multiple interfaces at once, and set all of our graph settings.

From here, we can set which type of graph we want to create for each interface, as well as determine the column in which the graph will be created. (For this example, our alert will not accept the row value, however, it is easy to add and works pretty well.)

Custom Property Editor_20180319_0917.png

To keep it simple, I have selected 10 different interfaces, adding 5 as "AvgBps-Line" graphs, to column 1, and the other 5 as "TotalBytesBar" to column 2.

Now it's time to activate the script. Select all, then click on "Edit Multiple Values".

Custom Property Editor_20180319_0920.png

Since all interfaces already have the graphtype and columns set, all we need to do now is tell it which view we want to build on, and then trigger the alert/script.

In this example, I have created a new "Summary" view, and I know the viewID for that view is 141.

So, I put 141 as the value for the "GraphViewID" CP, set the GraphViewIDCreate value to "True", and make sure the "GraphViewProcessed" value is set to "False".

Once those values are correct, click "Save Changes", which should trigger our alert/script.

Custom Property Editor_20180319_0931.png

Our alert should only take a few moments to trigger, and should then start building our page.

Here is our page (ViewID=141), before:

Graphs_Uplinks - Graph Test 4_20180319_0929.png

And here is our page a minute or so after we submitted those custom property changes to the interfaces. (While this screenshot only shows 4 graphs, out of the 10 we wanted, the remaining 6 graphs are certainly there.)

Graphs_Uplinks - Graph Test 4_20180319_0939.png

A nice feature here, is the script is configured to pull the "StatCollection" interval for each interface, and configure the corresponding graph to sample at the same interval. So if you have a handful of interfaces, each with different polling cycles/intervals, the sample rates of each graph will be adjusted to reflect the interval of each interface. (This only applies at the time of creation. If you change the interval after creating the graph, you will need to recreate the graph, or manually update the graph sample rate.)

This has been a long standing project for us, and I feel this solution is a fairly comfortable compromise, for the time being. Over the years, I have read numerous posts, and attempted various methods. I would like to thank the many folks that have assisted me, and here are some links to some of the posts that I have used, in some way or another. The first link, listed below, is the most recent post on this topic, for which tdanner​​ basically built this script. He took my garbage script, and pretty much started over, building a completely new, and CORRECT, script. I have only filled in a few steps to get this up and running in our environment. Other than that, here are most of the links I have found over the last few years, either directly relating to this project/goal, or containing some information I found valuable, possibly indirectly related to this project/goal.

How do I use PowerShell To Add Graphs To A View?

VerbArgument Example for 'AddResourceToView'

Invoking Orion.Views - AddViewToGroup

Re: Invoke-SwisVerb parameters

OrionSDK/Samples/PowerShell at master · solarwinds/OrionSDK · GitHub

Generating Graphs Dynamically

Custom SQL Dynamic Graphing Resource

How to create a simple custom view of multiple interfaces' bandwidth utilization

Custom Graphing: Fun With Highcharts

Re: Multi-column Custom HTML Page

Orion SDK - Is there a way to generate a interface graph as a JPG/PNG/GIF via the SDK?

Custom Sparkline Charts

Re: How to modify size of interface utilization charts?

Re: 1 Page - All interface Graphs Wanted ... Help me kill MRTG

Re: HTML/Javacript

Re: Javascript in a Custom HTML Resource and the API

Interface aggregate chart (swql)

Using SWis query to get interface utilization

Moving Content from View to View

Creating views using OrionSDK REST API's

Re: Showing Graph from different nodes

Possible to embed SWQL inside of custom HTML

For more ways to customize your SolarWinds environment, make sure to check out this link, by CourtesyIT

How to do various customizations with your Solarwinds

Thank you,

-Will

attachments.zip
  • Oh, My Goodness!    wluther​, you ARE a gem on the infinite shores of the world!

    I don't know how you found time to discover this, much less document it so well, but my hat's off to you so fast that it took some of my hair with it.

    It'll take me some time to run through your (EXCELLENT!) documentation and build up the custom properties, but I'm looking forward to the exercise and its results.

    It could totally fail, and I'd STILL send you my professional and undying admiration for such beautiful descriptions (complete with all the helpful and needed links!)  in your documentation.

  • I second this. Will give it a whirl and see if I can get it to work.