Baza danych konfiguracji usług AD FS jest niedostępna. Ten monitor będzie wysyłał polecenie ping do serwera SQL lub sprawdzał stan usługi sql wid co 5 minut. Jeśli baza danych konfiguracji usług AD FS stanie się dostępna, monitor zmieni stan na Zielony, a pierwotny alert ostrzegawczy zostanie rozwiązany automatycznie.
Serwer SQL jest niedostępny.
Sprawdź, czy serwer SQL jest dostępny, jeśli magazyn konfiguracji to serwer sql, lub sprawdź, czy usługa sql wid działa, jeśli magazynem konfiguracji jest baza danych wid. Więcej informacji można znaleźć w sekcjach „Verify network connectivity” (Sprawdzanie łączności sieciowej) i „Verify that the Federation Service can connect to the AD FS configuration database” (Sprawdzanie, czy usługa federacyjna może nawiązać połączenie z bazą danych konfiguracji usług AD FS) na stronie AD FS Troubleshooting Guide (Przewodnik rozwiązywania problemów z usługami AD FS).
Target | Microsoft.ActiveDirectoryFederationServices.2016.FederationServer | ||
Parent Monitor | System.Health.ConfigurationState | ||
Category | AvailabilityHealth | ||
Enabled | True | ||
Alert Generate | True | ||
Alert Severity | Error | ||
Alert Priority | Normal | ||
Alert Auto Resolve | True | ||
Monitor Type | Microsoft.ActiveDirectoryFederationServices.2016.TwoStateScriptMonitorType | ||
Remotable | True | ||
Accessibility | Public | ||
Alert Message |
| ||
RunAs | Default |
<UnitMonitor ID="Microsoft.ActiveDirectoryFederationServices.2016.FederationServerRemoteSQLServerPingMonitor" Accessibility="Public" Enabled="true" Target="Microsoft.ActiveDirectoryFederationServices.2016.FederationServer" ParentMonitorID="Health!System.Health.ConfigurationState" Remotable="true" Priority="Normal" TypeID="Microsoft.ActiveDirectoryFederationServices.2016.TwoStateScriptMonitorType" ConfirmDelivery="false">
<Category>AvailabilityHealth</Category>
<AlertSettings AlertMessage="Microsoft.ActiveDirectoryFederationServices.2016.FederationServerRemoteSQLServerPingMonitor_AlertMessageResourceID">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Error</AlertSeverity>
<AlertParameters>
<AlertParameter1>$Data/Context/Property["Server"]$</AlertParameter1>
</AlertParameters>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Success" MonitorTypeStateID="Success" HealthState="Success"/>
<OperationalState ID="Error" MonitorTypeStateID="Error" HealthState="Error"/>
</OperationalStates>
<Configuration>
<PowerShellPath>%windir%\system32\windowspowershell\v1.0\powershell.exe</PowerShellPath>
<ScriptName>FederationServerRemoteSQLServerPing.ps1</ScriptName>
<ScriptBody>
$scomapi = new-object -comObject "MOM.ScriptAPI"
$script:serverReachable = $true
$script:exceptionMessage = ""
$script:server = ""
$stsWMIObject = (Get-WmiObject -Namespace root\ADFS -Class SecurityTokenService)
$sqlConnectionString = $stsWMIObject.ConfigurationDatabaseConnectionString
[System.Data.SqlClient.SqlConnectionStringBuilder] $sqlConnectionBuilder = new-object System.Data.SqlClient.SqlConnectionStringBuilder $sqlConnectionString
$isWID = [StringComparer]::OrdinalIgnoreCase.Equals( $sqlConnectionBuilder.DataSource, 'np:\\.\pipe\Microsoft##WID\tsql\query');
if ($isWID -eq $false)
{
# if sql configuration store, check if remote sql server is pingable
$ping = new-object System.Net.NetworkInformation.Ping
&{
$script:server = $sqlConnectionBuilder.DataSource
if ( $script:server.StartsWith(".") -or $script:server.StartsWith("(local)") )
{
$script:server = "localhost"
}
else
{
$script:server = $script:server.Split('\')[0].Split(',')[0]
}
$scomapi.LogScriptEvent("ActiveDirectoryFederationServices", 1000, 4, "SQL server ping:" + $script:server)
$reply = $ping.Send( $script:server )
if ($reply -ne $null)
{
if ($reply.Status -ne [System.Net.NetworkInformation.IPStatus]::Success)
{
$script:serverReachable = $false
$script:exceptionMessage = $reply.Status.ToString()
}
}
}
}
else
{
# if wid configuration store, check if the sql servcie is running
# TODO: Think of taking the connection string and do a dummy query, instead of just checking status
$widService = get-service MSSQL'$MICROSOFT##WID'
$scomapi.LogScriptEvent("ActiveDirectoryFederationServices", 1001, 4, "WID sql service status:" + $widService.Status)
if ($widService.Status -ne "Running")
{
$script:serverReachable = $false
}
}
Trap [System.Exception]
{
$script:serverReachable = $false
$script:exceptionMessage = $_.Exception.Message
continue
}
$scompb = $scomapi.CreatePropertyBag()
$scompb.AddValue("ServerReachable", $script:serverReachable )
$scompb.AddValue("Server", $script:server )
$scompb.AddValue("ErrorMessage", $script:exceptionMessage )
$scomapi.AddItem($scompb)
$scomapi.ReturnItems()
</ScriptBody>
<IntervalSeconds>300</IntervalSeconds>
<TimeoutSeconds>180</TimeoutSeconds>
<ErrorExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='ServerReachable']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">false</Value>
</ValueExpression>
</SimpleExpression>
</ErrorExpression>
<SuccessExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='ServerReachable']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">true</Value>
</ValueExpression>
</SimpleExpression>
</SuccessExpression>
</Configuration>
</UnitMonitor>