Checking Grooming and Partitioning Process Monitor Type

Microsoft.SystemCenter.2007.OpsMgrDB.PartitioningAndGroomingMonitorType (UnitMonitorType)

This monitor type detects potential problems with the operational database by checking the state of grooming and partitioning processes that could cause performance issues.

Knowledge Base article:

Summary

Monitor type for checking the grooming and partitioning process.

Element properties:

RunAsDefault
AccessibilityInternal
Support Monitor RecalculateTrue

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource System.Scheduler Default
Probe ProbeAction Microsoft.SystemCenter.2007.OpsMgrDB.Generic.DS Default
CDUnderThreshold ConditionDetection System.ExpressionFilter Default
CDWarningThreshold ConditionDetection System.ExpressionFilter Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Interval (seconds)This workflow runs a script on a recurring schedule. The interval is the number of seconds that the workflow should wait from one run to the next. Change this value if you want the workflow to run more or less frequently.
Synctimestring$Config/Synctime$Sync time
TimeoutSecondsint$Config/TimeoutSeconds$Timeout (seconds)This workflow runs on script on a recurring schedule. The timeout is the number of seconds that the script is allowed to run before it will be forced to stop. Note: the timeout should always be less than the interval to ensure that multiple instances of the script do not run at the same time.
Thresholddouble$Config/Threshold$Maximum days since last successThis workflow uses the "maximum days since last success" value as a threshold to determine state. Set this to the maximum number of days that can pass without partitioning and grooming completing successfully, before it is considered a problem.

Source Code:

<UnitMonitorType ID="Microsoft.SystemCenter.2007.OpsMgrDB.PartitioningAndGroomingMonitorType" Accessibility="Internal">
<MonitorTypeStates>
<MonitorTypeState ID="UnderThreshold" NoDetection="false"/>
<MonitorTypeState ID="WarningThreshold" NoDetection="false"/>
</MonitorTypeStates>
<Configuration>
<xsd:element name="IntervalSeconds" type="xsd:integer"/>
<xsd:element name="Synctime" type="xsd:string"/>
<xsd:element name="TimeoutSeconds" type="xsd:int"/>
<xsd:element name="DatabaseServerName" type="xsd:string"/>
<xsd:element name="DatabaseName" type="xsd:string"/>
<xsd:element name="Threshold" type="xsd:double"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="Synctime" Selector="$Config/Synctime$" ParameterType="string"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
<OverrideableParameter ID="Threshold" Selector="$Config/Threshold$" ParameterType="double"/>
</OverrideableParameters>
<MonitorImplementation>
<MemberModules>
<DataSource ID="DS" TypeID="System!System.Scheduler">
<Scheduler>
<SimpleReccuringSchedule>
<Interval>$Config/IntervalSeconds$</Interval>
<SyncTime>$Config/Synctime$</SyncTime>
</SimpleReccuringSchedule>
<ExcludeDates/>
</Scheduler>
</DataSource>
<ProbeAction ID="Probe" TypeID="Microsoft.SystemCenter.2007.OpsMgrDB.Generic.DS">
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<ScriptName>PartitioningAndGroomingMonitor.vbs</ScriptName>
<ScriptBody><Script>'Copyright (c) Microsoft Corporation. All rights reserved.

'*************************************************************************
' $ScriptName: "PartitioningAndGroomingMonitor" $
'
' Purpose: This script checks for grooming and partiting processes.
'
' $File: PartitioningAndGroomingMonitor.vbs $
'*************************************************************************


Option Explicit
'Declarations
Dim objCN,objRS,strQuery, strCountOfJobsSucceeded
Dim oArgs,oAPI,oBag
Dim strDBServer,strDatabase
Dim strDaysLimitThreshold

'Define local event constants
Const EVENT_TYPE_ERROR = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4

SetLocale("en-us")

'Create objects
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oArgs = WScript.Arguments
Set oBag = oAPI.CreatePropertyBag()

'Define parameters
strDBServer = oArgs(0)
strDatabase = oArgs(1)
strDaysLimitThreshold = oArgs(2)

Dim ObjError
Set ObjError = New Error

On Error Resume Next

'Set DB connection
Set objCN = CreateObject("ADODB.Connection")
objCN.Open "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=" &amp; _
strDatabase &amp; ";Data Source=" &amp; strDBServer &amp; ""

ObjError.Save
On Error Goto 0

If ObjError.Number &lt;&gt; 0 Then
Set oBag = oAPI.CreatePropertyBag()
Call oBag.AddValue("Error", "Error Number: " &amp; ObjError.number &amp; " Error Details: " &amp; ObjError.Description)
Call oBag.AddValue("CountOfJobsSucceeded", "0")
Call oAPI.Return(oBag)
oAPI.LogScriptEvent "PartitioningAndGroomingMonitor.vbs",100,EVENT_TYPE_ERROR,"Script executed with Error Number: " &amp; ObjError.number &amp; " Error Details: " &amp; ObjError.Description
WScript.Quit
End If

strQuery = "SELECT Count(StatusCode) AS CountOfJobsSucceeded " &amp; _
"FROM InternalJobHistory " &amp; _
"WHERE CONVERT(varchar, TimeStarted, 101) BETWEEN " &amp; _
"CONVERT(varchar, DATEADD(day, -" &amp; strDaysLimitThreshold &amp; ", GETUTCDATE()), 101) " &amp; _
"AND CONVERT(varchar, GETUTCDATE(), 101) " &amp; _
"AND Command = 'Exec dbo.p_GroomPartitionedObjects and dbo.p_Grooming' " &amp; _
"AND StatusCode = 1 "

'Query DB
Set objRS = objCN.Execute(strQuery)

ObjError.Save
On Error Goto 0

If ObjError.Number &lt;&gt; 0 Then
Set oBag = oAPI.CreatePropertyBag()
Call oBag.AddValue("Error", "Error Number: " &amp; ObjError.number &amp; " Error Details: " &amp; ObjError.Description)
Call oBag.AddValue("CountOfJobsSucceeded", "0")
Call oBag.AddValue("DaysLimitThreshold", strDaysLimitThreshold)

Call oAPI.Return(oBag)
oAPI.LogScriptEvent "PartitioningAndGroomingMonitor.vbs",100,EVENT_TYPE_ERROR,"Script executed with Error Number: " &amp; ObjError.number &amp; " Error Details: " &amp; ObjError.Description
WScript.Quit
End If

'Set variables
strCountOfJobsSucceeded = objRS("CountOfJobsSucceeded")

Call oBag.AddValue("CountOfJobsSucceeded", strCountOfJobsSucceeded)
Call oBag.AddValue("DaysLimitThreshold", strDaysLimitThreshold)
oAPI.LogScriptEvent "PartitioningAndGroomingMonitor.vbs",100,EVENT_TYPE_INFORMATION,"Script executed with Process Succeed Count " &amp; strCountOfJobsSucceeded

'Return property values
Call oAPI.Return(oBag)

Class Error
Private m_lNumber
Private m_sSource
Private m_sDescription
Private m_sHelpContext
Private m_sHelpFile

Public Sub Save()
m_lNumber = Err.number
m_sSource = Err.Source
m_sDescription = Err.Description
m_sHelpContext = Err.HelpContext
m_sHelpFile = Err.helpfile
End Sub

Public Sub Raise()
Err.Raise m_lNumber, m_sSource, m_sDescription, m_sHelpFile, m_sHelpContext
End Sub

Public Sub Clear()
m_lNumber = 0
m_sSource = ""
m_sDescription = ""
m_sHelpContext = ""
m_sHelpFile = ""
End Sub

Public Default Property Get Number()
Number = m_lNumber
End Property

Public Property Get Source()
Source = m_sSource
End Property

Public Property Get Description()
Description = m_sDescription
End Property

Public Property Get HelpContext()
HelpContext = m_sHelpContext
End Property

Public Property Get HelpFile()
HelpFile = m_sHelpFile
End Property
End Class</Script></ScriptBody>
<DatabaseServerName>$Config/DatabaseServerName$</DatabaseServerName>
<DatabaseName>$Config/DatabaseName$</DatabaseName>
<Threshold>$Config/Threshold$</Threshold>
</ProbeAction>
<ConditionDetection ID="CDUnderThreshold" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Double">
Property[@Name='CountOfJobsSucceeded']
</XPathQuery>
</ValueExpression>
<Operator>GreaterEqual</Operator>
<ValueExpression>
<Value Type="Double">1</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
<ConditionDetection ID="CDWarningThreshold" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Double">
Property[@Name='CountOfJobsSucceeded']
</XPathQuery>
</ValueExpression>
<Operator>Less</Operator>
<ValueExpression>
<Value Type="Double">1</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
</MemberModules>
<RegularDetections>
<RegularDetection MonitorTypeStateID="UnderThreshold">
<Node ID="CDUnderThreshold">
<Node ID="Probe">
<Node ID="DS"/>
</Node>
</Node>
</RegularDetection>
<RegularDetection MonitorTypeStateID="WarningThreshold">
<Node ID="CDWarningThreshold">
<Node ID="Probe">
<Node ID="DS"/>
</Node>
</Node>
</RegularDetection>
</RegularDetections>
<OnDemandDetections>
<OnDemandDetection MonitorTypeStateID="UnderThreshold">
<Node ID="CDUnderThreshold">
<Node ID="Probe"/>
</Node>
</OnDemandDetection>
<OnDemandDetection MonitorTypeStateID="WarningThreshold">
<Node ID="CDWarningThreshold">
<Node ID="Probe"/>
</Node>
</OnDemandDetection>
</OnDemandDetections>
</MonitorImplementation>
</UnitMonitorType>