Wednesday 4 October 2017

We use SquaredUp quite heavily for visualising SCOM.   Once thing I was asked was to find the number of connections to each RDS Collection we have.


SCOM can graph RDS performance counters for each server. Which is all fine, unless you have 10+ servers for a collection.  It ends up looking quite messy with similar colours.




The result isn't that useful for anyone wanting to see how many total users are currently on the collection.

The easy solution was to use the SquaredUp Community Management Pack (free!).

I created a new rule in SCOM using the MP to query the RDS Connection Broker and find out the name of the farms, and then work out the total connections and return it as a property bag.
I then used SquaredUp to display this value.

Net result : 

The rule is targeted to "Remote Desktop Connection Broker Role Service" and set to gather every 2 mins.  We have two brokers, so I can gather stats from either server.

Code (I could probably make it more efficient if I get time):

<#
CountRDSFarmActiveConnections.ps1
This script will count the number of active connections to the RD Connection Brokers per farm  
Initially created August 2017 by Darren Joyce

If this script is altered, make sure all rules using it are updated otherwise cookdown will be broken.
The rule needs to be scoped to the RDS Connection brokers only.
#>

function Event-Log {
    param (
        [string] $logtext
    )
    $Global:EventLog += $logtext
}

$api = New-Object -comObject "MOM.ScriptAPI"

$computer = (Get-WmiObject Win32_ComputerSystem)
$servers = Get-WMIObject -Class Win32_SessionDirectoryServer
$clusters = $servers.ClusterName | get-unique
  Event-Log "Beginning Script 1.0 `n"
$hash = @()
$hash = $servers | group "clustername" | select Name,@{Name="Sessions";Expression={[System.Math]::Round($($_.group | measure-object -sum NumberOfSessions).sum,2)}}

foreach ($h in $hash){
$propertybag = $api.CreatePropertyBag()
$propertybag.addvalue("Farm",("RDSFarm:" +($h.name).tolower()))
$propertybag.addvalue("TotalActiveSessions",$h.sessions)
      $propertybag
Event-Log "   Created PropertyBag for $h `n" 
}

$totalRDSSessions `n"
write-EventLog -Source 'Health Service Script' -LogName 'Operations Manager' -EventId 335 `
                  -Message $Global:EventLog `
                  -EntryType Information
Write-Verbose $Global:EventLog 
Clear-variable -Name "EventLog" -scope Global



The mapping on the rule is as follows : 



I left it for a while to do it's thing. Although it's set for every 2 mins to run, I found sometimes when I built a new performance rule it could take an hour or so before I could initially start using the results in SquaredUp.

In SquaredUp, the tile performance metric is configured like this :



Conclusion : An example of how the SquaredUp Community MP can be used to combine performance values.    We are also doing it with SNMP queries on our PBX gateways - something that there is no SCOM MP for, and the SquaredUp Community MP fits right in for that.


If you found this useful, please leave a comment.  I might post some other bits and pieces about SquaredUp, SCOM and interesting things I'm doing.  :)