Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Local Check_MK: check_Exchange_StorageGroups.ps1
$Host.UI.RawUI.BufferSize = New-Object Management.Automation.Host.Size(900,900)
Add-PSSnapin Microsoft.Exchange.Management.PowerShell.Admin
$check_name = "Exchange_SG_CopyStatus"
$OK = 0
$Warn = 1
$Crit = 2
$Unk = 3
$now = Get-Date
$deltac = -1.0
$deltaw = -0.5
$deltatc = $now.AddHours($deltac)
$deltatw = $now.AddHours($deltaw)
#Populate SG's to check based on current domain (obtained from calling user). Make sure these are SG's that should be replicating by checking target node:
[array]$SGS = Get-ExchangeServer -Domain ([System.DirectoryServices.ActiveDirectory.Domain]::getCurrentDomain()).Name | ?{$_.ServerRole -eq "Mailbox"} | Get-StorageGroupCopyStatus | ?{$_.CCRTargetNode -ne $null}
#echo $deltatc
#echo $deltatw
Function get-epochdate ($epochdate) { [timezone]::CurrentTimeZone.ToLocalTime(([datetime]'1/1/1970').AddSeconds($epochdate)) }
$statustxt = ""
$retw = 0
$retc = 0
$reto = 0
foreach ($s in $SGS)
{
#Generate dynamic check names for inventory based on SG Name:
$Check = $check_name+"_"+($s.StorageGroupName).Replace(" ", "_")
#Check Output
echo "`<`<`<local`>`>`>"
#If healthy and inspection time is within CRIT and WARN delta thresholds, then we're good:
if ($s.SummaryCopyStatus -eq "Healthy" -and ($s.LastInspectedLogTime -gt $deltatc -and $s.LastInspectedLogTime -gt $deltatw))
{
echo "$Ok $Check - OK - $($s.StorageGroupName) is $($s.SummaryCopyStatus). LastInspected $($s.LastInspectedLogTime)"
}
#If healthy but inspection time is stale (WARN):
elseif ($s.SummaryCopyStatus -eq "Healthy" -and ($s.LastInspectedLogTime -gt $deltatc -and $s.LastInspectedLogTime -lt $deltatw))
{
echo "$Warn $Check - WARN - Stale time. $($s.StorageGroupName) is $($s.SummaryCopyStatus). LastInspected $($s.LastInspectedLogTime)"
}
#If healthy but inspection time is stale (CRIT):
elseif ($s.SummaryCopyStatus -eq "Healthy" -and ($s.LastInspectedLogTime -gt $deltatc -and $s.LastInspectedLogTime -lt $deltatw))
{
echo "$Crit $Check - CRIT - Stale time. $($s.StorageGroupName) is $($s.SummaryCopyStatus). LastInspected $($s.LastInspectedLogTime)"
}
#If not healthy, disregard inspection time and alarm CRIT:
elseif ($s.SummaryCopyStatus -ne "Healthy")
{
echo "$Crit $Check - CRIT - $($s.StorageGroupName) is $($s.SummaryCopyStatus). LastInspected $($s.LastInspectedLogTime)"
}
else
{
echo "$Unk $Check - UNKNOWN - Problem evaluating health. $($s.StorageGroupName) is $($s.SummaryCopyStatus). LastInspected $($s.LastInspectedLogTime)"
}
}
@liveaverage

This comment has been minimized.

Copy link
Owner Author

liveaverage commented Jul 29, 2014

Checks the replication health of each Storage Group that has a CCRTargetNode defined. Also checks the "freshness" of the LastInspectedLogTime.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.