I am trying to monitor the search index for SharePoint.
I would need to monitor when the state for index component state= degraded
anyone able to help me create a custom monitor?
the powershell command would be:
$ssappn = Get-SPEnterpriseSearchServiceApplication
Get-SPEnterpriseSearchStatus –SearchApplication $ssappn[0].Name
My super quick attempt to write a PS monitor.
$ErrorActionPreference = "silentlycontinue";
Add-PSSnapin "Microsoft.SharePoint.PowerShell"
$Error.Clear();
$stat1=$stat2=$stat3=$stat4=0;
$ssappn = Get-SPEnterpriseSearchServiceApplication
$out=Get-SPEnterpriseSearchStatus –SearchApplication $ssappn[0].Name
if ($out.State -eq 'Active')
{
Write-host "Message: Search Index is active!";
Write-host "Statistic: $stat";
Exit 0;
}
Elseif
($out.State -eq 'degraded')
{
Write-host "Message: Search Index is degraded!";
Write-host "Statistic: $stat";
Exit 1;
}
However, i don't know how i would filter out just one line to check for the status. I really only care if the Index is Degraded