Service Provider Foundation database connection monitor

Microsoft.SystemCenter.SPF.Monitor.SpfDatabaseScriptMonitor (UnitMonitor)

Monitors the connection between SPF web endpoint and SPF database.

Knowledge Base article:

Summary

Monitors database connectivity from the SPF web servers. This is done by periodically making a test connection to the Service Provider Foundation database.

Configuration

For this monitor to work correctly, it must have permission to read the Service Management Automation database. Create a Run As Account that has read permissions to the database and add it to the Run As Profile called Microsoft Service Provider Foundation Database Account.

The following options can be configured on this monitor:

Option

Definition

Default

Alert On State

Health state for the monitor that generates an alert.

The monitor is in a critical health state

Alert Priority

Priority of the alert generated for this monitor.

High

Alert Severity

Priority of the alert generated for this monitor.

Critical

Auto-Resolve Alert

Specifies whether the alert should automatically be resolved when the monitor returns to a healthy state.

True

Enabled

Specifies whether the monitor should run.

True

Generates Alert

Specifies whether the monitor should generate an alert when changing to a warning or critical state.

True

Interval

Number of seconds between times that the monitor is run.

300

Causes

If this monitor is in error, then either the database is not available from the server or the security for the monitor is not configured correctly. See the Configuration section for details on configuring the monitor.

If the monitor is configured correctly and the monitor is in error then the database is offline or the database server is inaccessible to the Service Provider Foundation server.

Resolutions

Check the status of the Service Provider Foundation database and the database server.

Element properties:

TargetMicrosoft.SystemCenter.SPF.SpfServer
Parent MonitorSystem.Health.AvailabilityState
CategoryAvailabilityHealth
EnabledTrue
Alert GenerateTrue
Alert SeverityMatchMonitorHealth
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.SystemCenter.ServiceProviderFoundation.PowerShellModule.TwoStateMonitorType.PropertyBag
RemotableTrue
AccessibilityPublic
Alert Message
Cannot Connect To SPF Database
Connection to SPF database was unsuccessful.
RunAsMicrosoft.SystemCenter.SPF.DatabaseAccount

Source Code:

<UnitMonitor ID="Microsoft.SystemCenter.SPF.Monitor.SpfDatabaseScriptMonitor" Accessibility="Public" Enabled="true" Target="Microsoft.SystemCenter.SPF.SpfServer" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="true" Priority="Normal" TypeID="Microsoft.SystemCenter.ServiceProviderFoundation.PowerShellModule.TwoStateMonitorType.PropertyBag" ConfirmDelivery="false" RunAs="Microsoft.SystemCenter.SPF.DatabaseAccount">
<Category>AvailabilityHealth</Category>
<AlertSettings AlertMessage="Microsoft.SystemCenter.SPF.Monitor.SpfDatabaseScriptMonitor.AlertMessage">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>MatchMonitorHealth</AlertSeverity>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Error" MonitorTypeStateID="Error" HealthState="Error"/>
<OperationalState ID="Success" MonitorTypeStateID="Success" HealthState="Success"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>300</IntervalSeconds>
<SyncTime/>
<ScriptName>HealthOfSqlServer.ps1</ScriptName>
<ScriptBody><Script>$oAPI = new-object -comObject "MOM.ScriptAPI"
$propertyBag = $oAPI.CreatePropertyBag()

$errorActionSetting = $ErrorActionPreference
try
{
$ErrorActionPreference = "Stop"
Import-Module "$env:COMMONPROGRAMFILES\Microsoft System Center 2012 R2\Service Provider Foundation\Microsoft.SystemCenter.Foundation.Cmdlet.dll"
$stamps = Get-SCSPFStamp
$propertyBag.AddValue("Result", "Success")
}
catch
{
$propertyBag.AddValue("Result", "Error")
}
finally
{
$ErrorActionPreference = $errorActionSetting
$propertyBag
}
</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
<ErrorExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='Result']</XPathQuery>
</ValueExpression>
<Operator>NotEqual</Operator>
<ValueExpression>
<Value Type="String">Success</Value>
</ValueExpression>
</SimpleExpression>
</ErrorExpression>
<SuccessExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='Result']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Success</Value>
</ValueExpression>
</SimpleExpression>
</SuccessExpression>
</Configuration>
</UnitMonitor>