
You may notice on your Vital Stats subview that there is a real-time polling widget for CPU and Memory. It shows CPU as a Percentage and Memory as a number (bytes consumed).
I, personally, do not care for this. I like my percentage charts to show percentages and my raw number charts to show raw numbers. It's a personal preference but it was something that annoyed me whenever I saw it and since it's on every Vital Stats page I was getting prone to annoyance.
I knew that much of the management can now be done via the Orion API, so I started to dig around a little bit within the SWQL Studio. Specifically, I looked at the Orion.Resources
and the Orion.ResourceProperties
tables.
After noodling around a little bit I found that the VisibilityConfigurationUri
and ChartConfiguration
properties contained references to Orion.CPULoad.AvgMemoryUsed
. This is the value I swapped out for Orion.CPULoad.AvgPercentMemoryUsed
. I figured out the correct metric's name by going to Performance Analysis, dragging on the chart I wanted and looking at the resulting URL.
I wrote a little script to automate this work and documented a bunch of it. I've gotten in the habit of writing pseudo-code all in comments as I work out my logic. Then it's just easy to convert them to valuable comments down the line.
<#
MANDATORY DISCLAIMER
------------------------------------------------------------------------------------------------------------------
Please note, any custom scripts or other content posted herein are provided as a suggestion or recommendation
to you for your internal use. This is not part of the SolarWinds software that you have purchased from SolarWinds,
and the information set forth herein may come from third party customers. Your organization should internally
review and assess to what extent, if any, such custom scripts or recommendations will be incorporated into your
environment. Any custom scripts obtained herein are provided to you "AS IS" without indemnification, support, or
warranty of any kind, express or implied. You elect to utilize the custom scripts at your own risk, and you will
be solely responsible for the incorporation of the same, if any.
------------------------------------------------------------------------------------------------------------------
Standard script warning:
Do not use this on production systems unless you are 100% confident that you a) have a backup and b) understand
what the script is doing. I'm just trying to be educational.
#>
# Your SolarWinds Orion Server's FQDN or IP Address
$SwisHost = "kmsorion01v.kmsigma.local"
# if you don't already have credentials saved, let's store them
if ( -not ( $SwisCreds ) ) {
# Using Orion-based credentails
$SwisCreds = Get-Credential -Message "Enter your Orion credentails to connect to `"$SwisHost`""
}
# Build Swis Connection
$SwisConnection = Connect-Swis -Hostname $SwisHost -Credential $SwisCreds
# Query for the existing resource information
$ChartToChange = 'CPU Load & Memory Usage - Real Time Data'
# This is the query to pull the necessary information we want to update
$SwqlQuery = @"
SELECT [Props].PropertyValue
, [Props].Uri
FROM Orion.ResourceProperties AS [Props]
INNER JOIN Orion.Resources AS [Resources]
ON [Resources].ResourceID = [Props].ResourceID
WHERE [Resources].ResourceTitle = '$ChartToChange'
AND [Props].PropertyName IN ('VisibilityConfigurationUri', 'ChartConfiguration' )
# Query the API to get the information
$ConfigsToChange = Get-SwisData -SwisConnection $SwisConnection -Query $SwqlQuery
# If we found matches on the resource name and property names, then we can proceed, otherwise throw an error (near the bottom)
if ( $ConfigsToChange ) {
<#
The Add-Member function is a way to extend a pre-existing PowerShell object with new 'fields' (technically called properties)
Details on how to use it fall WAY outside the scope of this script, but it's a useful function and you should learn about it
If you are going to continue to use PowerShell
#>
# We can extract the Property Name from the URI and add it as "PropertyName"
$ConfigsToChange | Add-Member -MemberType ScriptProperty -Name PropertyName -Value { $this.Uri.Split('"')[1] } -Force
# We can build a property hashtable (what we'll eventually send to the API) containing the relevant details (Property Name and Property Value)
$ConfigsToChange | Add-Member -MemberType ScriptProperty -Name Properties -Value {
@{
PropertyName = $this.PropertyName
# ########################################
# You need to uncomment one of the two below lines starting with "PropertyValue" to set your charts one way or another.
# Basically, we just do a find an replace between AvgMemoryUsed and AvgPercentMemoryUsed
# ########################################
# This will set the above chart to use Average Percent Memory Used (0..100%)
PropertyValue = $this.PropertyValue.Replace('Orion.CPULoad.AvgMemoryUsed', 'Orion.CPULoad.AvgPercentMemoryUsed')
# This will set the above chart to use Average Memory Used (KB, MB, GB, TB, etc.)
# PropertyValue = $this.PropertyValue.Replace('Orion.CPULoad.AvgPercentMemoryUsed', 'Orion.CPULoad.AvgMemoryUsed')
}
} -Force
# Now that we have the configuration changes we want to make, we can cycle through them
ForEach ( $ConfigChange in $ConfigsToChange ) {
Write-Host "Updating $( $ConfigChange.PropertyName ) for the $( $ChartToChange ) widget/chart..." -NoNewline
# Make the request to update the data via the API
Set-SwisObject -SwisConnection $SwisConnection -Uri $ConfigChange.Uri -Properties $ConfigChange.Properties
Write-Host " [COMPLETED]" -ForegroundColor Green
}
} else {
# This is the error I was talking about earlier if we get zero results back from our initial.
Write-Error "Unable to find matching properties"
}
I
and then ran it. It executed without errors and I refreshed the Orion page to see if it worked.

EUREKA! My 2020.2.5 server is now now showing percentages only! I can already feel my annoyance going down. Maybe I should put a request like this in as a Feature Request for the Orion Platform, but I really just wrote this as a 'see if I could do it' task.
I'll consider that another bump in my skillset regarding PowerShell and the SolarWinds Orion API. So that was my day in the API - what have you done lately?
Final disclaimer: This is my own non-production system and this was written as an exploration piece and is not a replacement for support. If you even consider doing work like this, be sure to backup your servers and databases (even if it's a development environment) before working with any scripts - even those you author yourself. I have first-hand experience of these things going poorly.