Recalculate, not Reset, monitors in bulk?

Does anyone know of a method to use to perform bulk monitor health recalculation? I’m not talking about resetting the monitor, I’m talking about RECALCULATING it. Anyone?

Occasionally we see an issue where a temporary DNS “glitch” will cause Heartbeat Failures and Failed to Connect alerts; but the Heartbeat Failures (HB) will sometimes clear so fast that the Failed to Connect (FTC) doesn’t recalculate. We’re assuming based on what we’ve observed that the FTC diagnostic is running when the HB’s start to flow back in; leaving the FTC stranded without a HB.

The only way we’ve been able to bulk clear is to stop the agents, wait for the new HB failure, and then start the agent again, where the monitor will recalculate its health and clear the alert.

I’m looking for something like a powershell script to do the recalc, but not the existing script that resets. I hope that makes sense.

1 Like

Glad I’m not the only one who’s seen this before ?

Previously we’ve used maintenance mode for 5 minutes against the Agent Watcher which can be found under the Operations Manager mp > Agent Details > Agent Health State

As the watcher resides on the management server, the health data is still collected, meaning you won’t miss anything.

 

As with anything, this can be scripted:

 

$object = “ServerName”

$class = Get-SCOMClass -DisplayName “Health Service Watcher (Agent)”

$instance = $class | Get-SCOMClassInstance | where { $_.DisplayName -eq $object }

$endtime = [DateTime]::Now.AddMinutes(5)

Start-SCOMMaintenanceMode -EndTime $endtime -Instance $instance -Reason UnplannedOther

 

It shouldn’t be too difficult to map this to an array to have several objects included.

 

Let me know if this helps ?

2 Likes

This is possible with PS, but in a super unintuitive fashion you don’t ask the monitor to reset but the object the monitor is attached to. You can either pass in a specific monitor guid (which will request recalculation on that monitor only) or you can omit this and just have all monitors on this object recalculate.

Disclaimer: Unlike resetting the health state, not all monitors support health state recalculation – so triggering this task may have no effect if they don’t. As such I’m going to assume you want to do this for specific alerts where you know the monitor does support it, or certain objects, but ultimately you can use any technique that gets you the object you want to reset health for and (optionally) the monitor id.

Example 1

#Recalculate all currently open monitor-based Alerts… ideally be more specific with your Get-SCOMAlert filtering
$Alerts = Get-SCOMAlert -ResolutionState 0 | where {$_.IsMonitorAlert -eq $true }
Foreach ($alert in $alerts)
{
	$monitoringObject = Get-SCOMClassInstance -Id $alert.MonitoringObjectId
	$monitoringObject.RecalculateMonitoringState($alert.MonitoringRuleId)
}

Example 2

#Recalculate all monitors for a specific object, in this case a Health Service Watcher for server MyServerName
$agentWatcherClass = Get-SCOMClass -Name ‘Microsoft.SystemCenter.HealthServiceWatcher
$agentWatcher = $agentWatcherClass | Get-SCOMClassInstance | where {$_.DisplayName -match ‘MyServerName’} | Select -First 1
$agentWatcher.RecalculateMonitoringState()

Hope that helps!

1 Like

Hi,

just want to underpin Vyper’s statement about Recalculations.

According to my experience this functionality is rather unpopular. - At least in my MPs I don’t setup a recalculations and it’s not worth the effort imo …

Keep us posted for the result please,@BlakeTheITGuy :slight_smile: