Follow Me

 

Today I’ve written a simple powershell check for nagios to check if all the storage group scr replication is healthy.

Script

Param($sourceserver, $destinationserver)

$snapins = "Microsoft.Exchange.Management.Powershell.Admin"

$snapins | ForEach-Object { 

 if ( Get-PSSnapin -Registered $_ -ErrorAction SilentlyContinue ) {

 Add-PSSnapin $_

 }

}

$storagegroupcopystatus = Get-StorageGroupCopyStatus -Server $sourceserver -StandbyMachine $destinationserver

$status = 0;
$warning_array = @()
$perfdata_string_array = @();

foreach ($storagegroup in $storagegroupcopystatus)
{
 if ($storagegroup.SummaryCopyStatus -ne 'Healthy')
 {
 $status = 2;
 $warning_array += $storagegroup.StorageGroupName
 }

 $perfdata_string_array += "'Copy Queue Length - $($storagegroup.StorageGroupName)': " + $storagegroup.CopyQueueLength
 $perfdata_string_array += "'Replay Queue Length - $($storagegroup.StorageGroupName)': " + $storagegroup.ReplayQueueLength

}

switch ($status)
{
 0 {
 $message = "OK - All storagegroups are correctly being replicated"
 }
 2 {
 $warning_array_string = [string]::join(",", $warning_array)
 $message = "ERROR - Storage Groups (" + $warning_array_string + ") are not correctly being replicated. Check replication!"
 }
}

$perfdata_string = [string]::join(" ", $perfdata_string_array)
Write-Host "$($message) | $($perfdata_string)"
$host.SetShouldExit($status)

Entry in nsc.ini

check_exchange_scr=cmd /c echo scripts\check_exchange_scr.ps1 $ARG1$ $ARG2$ | powershell.exe -command -

 Leave a Reply

(required)

(required)

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

   
© 2011 Oppergod's Weblog Suffusion theme by Sayontan Sinha