SCOM 2012 – Distribut Agents Evenly (50:50)

I am sure you have a small SCOM infrastructure containing 2 management servers and probably 1 SQL server. If you and your colleagues deploy SCOM agents on a daily basis it can easily happen that not all management servers receive the equal amount of agents. Maybe management server 1 has 300 agents to monitor and management server 2 has 100 agents to monitor. This is of course not an ideal situation. Why? As you know the Windows agents do NOT report to Resource Pools instead they report directly to the management servers as they did in SCOM 2007 R2. What does that mean? If you have a Resource Pool containing 2 management servers then the the Resource Pool does not load balance the agents and therefore one management server has more load than the other! Yes, right the Resource Pool is used for other functionality get some more details here.

Therefore if you have a Resource Pool containing 2 management servers which is only responsible for Windows agents it makes sense to distribute the agents evenly across the management servers so every management server will have about the same load.  Now wouldn’t it be cool, just to let Orchestrator do all the distribution work?

My fellow MVP Marcel Zehner has written a cool Runbook which I would like to share. It looks like this…

image

The Runbook has two activities. The first “Monitor Date/Time” activity is just for scheduling. In my case it runs every night at 10:00 PM.

image

The second “Run .Net Script” activity runs a Powershell script which distributes the agents evenly across 2 management servers.

image

As you see in the script are two variables used “SCOM RMS Emulator” and “SCOM Windows Agent Resource Pool Name”. The “SCOM RMS Emulator” variable is used as target to create a connection to the management group. The “SCOM Windows Agent Resource Pool Name” variable is the name of the Resource Pool where your management servers are. Both variables are defined in Orchestrator…

image

I think the script is self-explaining. If you want to build this Runbook replace the bold text in the script through the corresponding Orchestrator variable.

Script:

#######################################################

#Create the SCOM connection
Import-Module “C:\Program Files\System Center 2012\Operations Manager\Powershell\OperationsManager\OperationsManager.psm1” -force
New-SCOMManagementGroupConnection –computername “SCOM RMS Emulator”

# Get Resource Pool Members
$ResourcePoolMembers = get-scomresourcepool | where{$_.displayname –eq “SCOM Windows Agent Resource Pool Name”} | foreach{$_.members}

$MS1 = get-scommanagementserver | where{$_.displayname -eq $ResourcePoolmembers[0]}
$MS2 = get-scommanagementserver | where{$_.displayname -eq $ResourcePoolmembers[1]}

# Get Agents
$Agents = get-scomagent
foreach($Agent in $Agents)
    {
    set-scomparentmanagementserver -agent $agent -failoverserver $null
    set-scomparentmanagementserver -agent $agent -primaryserver $ms1
    set-scomparentmanagementserver -agent $agent -failoverserver $ms2

$ms3 = $ms1
$ms4 = $ms2
$ms1 = $ms4
$ms2 = $ms3

    }

#Unload the SCOM module
remove-module operationsmanager –force

#######################################################

If you schedule this Runbook daily, as I did, your management servers will have the equal amount of agents and maybe you will see better performance of the SCOM management group because of that.

Note: This script just works if you have two management servers! It does not work with 3 or more management servers.

2 Comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s