Showing posts with label Clusters. Show all posts
Showing posts with label Clusters. Show all posts

Monday, February 8, 2010

Automating "Proxying Enabled" for Cluster Nodes

If you perform a "mass installation" of OpsMgr, the task of turning agent proxying on is quite a mission. The way I see it is as follows: most people use clusters for SQL redundancy, meaning that it is pretty safe to assume that every object contained in the Microsoft.Windows.Cluster.Service class will need to have agent proxying enabled for this to actually work.

If we use this Powershell code, we can loop through all objects contained within the Cluster class and enable it in one step.

Code:


$rootMS = "RMS1"
$targetClass = "Microsoft.Windows.Cluster.Service";
Set-Location OperationsManagerMonitoring::
New-ManagementGroupConnection $rootMS
Set-Location $rootMS
$matches = Get-MonitoringClass -name $targetClass | Get-MonitoringObject | Select-Object
Foreach($object in $matches) {
[string]$currentAgent = $object.Path
$agent = Get-Agent | Where-Object {$_.Name -eq $currentAgent}
if($agent.proxyingEnabled -eq 'False')
{
Write-Host "$currentAgent doesn't have proxying enabled yet, enabling now"
$agent.proxyingEnabled = $true;
$agent.applyChanges();
}
else
{
Write-Host "Proxying already enabled for $currentAgent, skipping..."
}
}


Easy peasy.

Maintenance Mode - Clusters, Nodes, SQL Instances

One frustrating thing about OpsMgr's Maintenance Mode system is that if you put both nodes of a cluster into maintenance mode the "Virtual" system will continue to alert. This is a common oversight and the cause of many unnecessary cluster and/or SQL alerts.

The reason for this is that the virtual computer is the top parent which hosts the Cluster Service and SQL DB Engine. Although the nodes form part of this, they are not all-encompassing and will not suffice. Although standard logic dictates that if you're putting a node into maintenance mode you're probably working on the cluster, there is an extra step needed when dealing with this.

This powershell snippet demonstrates how to put a related "Virtual Computer" into maintenance mode. This will also result in the SQL Instance being in maintenance mode as the Virtual Computer is the host of it.

Code:

$class = get-monitoringclass -name:"Microsoft.Windows.Server.Computer"
$node = get-monitoringobject -monitoringclass:$class -criteria:"DisplayName = 'Node1'"
$agent = get-agent | ?{$_.DisplayName -eq $node.DisplayName}
$clusterMachines = $agent.GetRemotelyManagedComputers()
foreach($cluster in $clusterMachines)
{
get-monitoringobject -monitoringclass:$class -criteria:"DisplayName = $cluster.DisplayName" | Select DisplayName
#Here we can carry on and put these associated objects into maintenance mode too
}


As you can see, we make use of $agent.GetRemotelyManagedComputers() to get a list of computers which the specific agent is managing. As you are well aware, we need to Set Proxying = On if we're using clusters, so this is a sure-fire way of determining if anything "virutal" is running of it.