Monitortype voor controleren van opschonings- en partitioneringsproces

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

Dit monitortype detecteert mogelijke problemen met de operationele database door de status te controleren van de opschonings- en partitioneringsprocessen die prestatieproblemen kunnen veroorzaken.

Knowledge Base article:

Samenvatting

Een monitortype voor het controleren van het proces voor opschoning en partitionering.

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
CD1 ConditionDetection System.Performance.ConsecutiveSamplesCondition Default
CDInSufficientSamples ConditionDetection System.ExpressionFilter Default
CDSufficientSamples ConditionDetection System.ExpressionFilter Default
CDUnderThreshold ConditionDetection System.ExpressionFilter Default
CDWarningThreshold ConditionDetection System.ExpressionFilter Default
Mapper ConditionDetection System.Performance.DataGenericMapper Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Interval (seconden)Met deze werkstroom wordt een script op basis van een terugkerend schema uitgevoerd. Het interval is het aantal seconden dat de werkstroom tussen uitvoeringen moet wachten. Wijzig deze waarde als u de werkstroom vaker of minder vaak wilt uitvoeren.
Synctimestring$Config/Synctime$Synchronisatietijd
TimeoutSecondsint$Config/TimeoutSeconds$Time-out (seconden)Met deze werkstroom wordt een script op basis van een terugkerend schema uitgevoerd. De time-out is het aantal seconden dat het script kan worden uitgevoerd voordat het gedwongen wordt beëindigd. Opmerking: de time-outwaarde moet altijd kleiner zijn dan de intervalwaarde om er zeker van te zijn dat er niet tegelijkertijd meerdere exemplaren van het script worden uitgevoerd.
Thresholdint$Config/Threshold$Maximum aantal dagen sinds laatste geslaagde pogingDeze werkstroom gebruikt de waarde voor 'maximum aantal dagen sinds laatste geslaagde poging' als drempelwaarde om de status te bepalen. Stel in hoeveel dagen zonder voltooide partitionerings- en opschoonbewerking mogen verstrijken voordat dit als een probleem wordt beschouwd.
TimesBeforeAlertint$Config/TimesBeforeAlert$Aantal steekproeven vóór waarschuwingHet aantal steekproeven dat moet worden gewacht voordat de status van de monitor wordt gewijzigd in Waarschuwing.

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:integer"/>
<xsd:element name="DatabaseServerName" type="xsd:string"/>
<xsd:element name="DatabaseName" type="xsd:string"/>
<xsd:element name="Threshold" type="xsd:int"/>
<xsd:element name="TimesBeforeAlert" type="xsd:integer"/>
</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="int"/>
<OverrideableParameter ID="TimesBeforeAlert" Selector="$Config/TimesBeforeAlert$" ParameterType="int"/>
</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: "GetSqlNativeClientComman" $
'
' Purpose: This script is used to get SQL native client Driver name.
'
' $File: GetSqlNativeClientComman.vbs $
'*************************************************************************


Option Explicit

Function GetSqlDriverName
Dim oReg
Const HKEY_LOCAL_MACHINE = &amp;H80000002
Const HKEY_CLASSES_ROOT = &amp;H80000000
Dim strComputer, strDriverPath, strKeyPath, intValue, strValueName,arrSubKeys,oSubkey,strNewKeyPath,intDotIndex, strDriverPathFromHKeyClassRoot
strComputer = "."
strDriverPath="SQLOLEDB"
Set oReg=GetObject("winmgmts:\\" &amp; _
strComputer &amp; "\root\default:StdRegProv")

strKeyPath = "CLSID\{5A23DE84-1D7B-4A16-8DED-B29C09CB648D}"
'strDriverPathFromHKeyClassRoot is used to check driver MSOLEDBSQL is installed or not. If found MSOLEDBSQL will be returned from function else strDriverPath="SQLOLEDB" will be used for further checking.
oReg.GetStringValue HKEY_CLASSES_ROOT, strKeyPath, "", strDriverPathFromHKeyClassRoot
If strDriverPathFromHKeyClassRoot = "MSOLEDBSQL" Then
GetSqlDriverName = strDriverPathFromHKeyClassRoot
Exit Function
End If

strKeyPath = "SOFTWARE\ODBC\ODBCINST.INI"
oReg.EnumKey HKEY_LOCAL_MACHINE, strKeyPath, arrSubKeys

For Each oSubkey In arrSubKeys
intValue = InStr(oSubkey, "SQL Server Native Client")
if intValue &lt;&gt; 0 Then
strValueName = "Driver"
strNewKeyPath = strKeyPath&amp;"\"&amp;oSubkey
oReg.GetStringValue HKEY_LOCAL_MACHINE, strNewKeyPath, strValueName , strDriverPath
strDriverPath = Mid (strDriverPath, InStrRev(strDriverPath, "\")+1)
intDotIndex = InStr(strDriverPath, ".")
strDriverPath = Left(strDriverPath , intDotIndex-1)
end if
Next
GetSqlDriverName = strDriverPath
End Function

'Copyright (c) Microsoft Corporation. All rights reserved.

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



'Declarations
Dim objCN,objRS,strQuery, strCountOfJobsSucceeded, strCountOfJobs
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, strMessageToUse, strDriverName
Set ObjError = New Error

On Error Resume Next

'Set DB connection
Set objCN = CreateObject("ADODB.Connection")
strDriverName = GetSqlDriverName
objCN.Open "Provider=" &amp; strDriverName &amp; ";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
strMessageToUse = "Error Number: " &amp; ObjError.number &amp; " Error Details: " &amp; ObjError.Description
call GetState(true, strMessageToUse, "0", "0", strDaysLimitThreshold)
WScript.Quit
End If

strQuery = "SELECT Count(StatusCode) AS TotalCount " &amp; _
"FROM InternalJobHistory " &amp; _
"WHERE Command = 'Exec dbo.p_GroomPartitionedObjects and dbo.p_Grooming' "

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

ObjError.Save
On Error Goto 0

If ObjError.Number &lt;&gt; 0 Then
strMessageToUse = "Error Number: " &amp; ObjError.number &amp; " Error Details: " &amp; ObjError.Description
call GetState(true, strMessageToUse, "0", "0", strDaysLimitThreshold)
WScript.Quit
End If

'Set variables
strCountOfJobs = objRS("TotalCount")

strQuery = "SELECT Count(StatusCode) AS CountOfJobsSucceeded " &amp; _
"FROM InternalJobHistory " &amp; _
"WHERE TimeStarted BETWEEN " &amp; _
"DATEADD(day, -" &amp; strDaysLimitThreshold &amp; ", GETUTCDATE()) " &amp; _
"AND GETUTCDATE() " &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
strMessageToUse = "Error Number: " &amp; ObjError.number &amp; " Error Details: " &amp; ObjError.Description
call GetState(true, strMessageToUse, "0", "0", strDaysLimitThreshold)
WScript.Quit
End If

'Set variables
strCountOfJobsSucceeded = objRS("CountOfJobsSucceeded")

strMessageToUse = "Script executed with Process Succeed Count " &amp; strCountOfJobsSucceeded &amp; " from Total Process Count " &amp; strCountOfJobs
call GetState(false, strMessageToUse, strCountOfJobs, strCountOfJobsSucceeded, strDaysLimitThreshold)
WScript.Quit

Sub GetState(strErrorFlag, strMessage, strCountOfJobs, strCountOfJobsSucceeded, strDaysLimitThreshold)
Set oBag = oAPI.CreatePropertyBag()

If strErrorFlag = true Then
Call oBag.AddValue("Error", strMessage)
End If

Call oBag.AddValue("DatabaseMonitor", "DatabaseMonitor")
Call oBag.AddValue("PartitioningAndGrooming", "PartitioningAndGrooming")
Call oBag.AddValue("ALL", "ALL")
Call oBag.AddValue("Value", "1")
Call oBag.AddValue("CountOfJobs", strCountOfJobs)
Call oBag.AddValue("CountOfJobsSucceeded", strCountOfJobsSucceeded)
Call oBag.AddValue("DaysLimitThreshold", strDaysLimitThreshold)
oAPI.LogScriptEvent "PartitioningAndGroomingMonitor.vbs",100,EVENT_TYPE_INFORMATION, strMessage
Call oAPI.Return(oBag)
End Sub

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>
<And>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Double">
Property[@Name='CountOfJobs']
</XPathQuery>
</ValueExpression>
<Operator>GreaterEqual</Operator>
<ValueExpression>
<Value Type="Double">1</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Double">
Property[@Name='CountOfJobsSucceeded']
</XPathQuery>
</ValueExpression>
<Operator>GreaterEqual</Operator>
<ValueExpression>
<Value Type="Double">1</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</And>
</Expression>
</ConditionDetection>
<ConditionDetection ID="CDWarningThreshold" TypeID="System!System.ExpressionFilter">
<Expression>
<And>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Double">
Property[@Name='CountOfJobs']
</XPathQuery>
</ValueExpression>
<Operator>GreaterEqual</Operator>
<ValueExpression>
<Value Type="Double">1</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Double">
Property[@Name='CountOfJobsSucceeded']
</XPathQuery>
</ValueExpression>
<Operator>Less</Operator>
<ValueExpression>
<Value Type="Double">1</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</And>
</Expression>
</ConditionDetection>
<ConditionDetection ID="Mapper" TypeID="Performance!System.Performance.DataGenericMapper">
<ObjectName>DatabaseMonitor</ObjectName>
<CounterName>PartitioningAndGrooming</CounterName>
<InstanceName>ALL</InstanceName>
<Value>1</Value>
</ConditionDetection>
<ConditionDetection ID="CD1" TypeID="Performance!System.Performance.ConsecutiveSamplesCondition">
<Threshold>1</Threshold>
<Direction>greaterequal</Direction>
</ConditionDetection>
<ConditionDetection ID="CDSufficientSamples" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Double">Value</XPathQuery>
</ValueExpression>
<Operator>GreaterEqual</Operator>
<ValueExpression>
<Value Type="Double">$Config/TimesBeforeAlert$</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
<ConditionDetection ID="CDInSufficientSamples" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="Double">Value</XPathQuery>
</ValueExpression>
<Operator>Less</Operator>
<ValueExpression>
<Value Type="Double">$Config/TimesBeforeAlert$</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
</MemberModules>
<RegularDetections>
<RegularDetection MonitorTypeStateID="UnderThreshold">
<Node ID="CDInSufficientSamples">
<Node ID="CD1">
<Node ID="Mapper">
<Node ID="CDUnderThreshold">
<Node ID="Probe">
<Node ID="DS"/>
</Node>
</Node>
</Node>
</Node>
</Node>
</RegularDetection>
<RegularDetection MonitorTypeStateID="WarningThreshold">
<Node ID="CDSufficientSamples">
<Node ID="CD1">
<Node ID="Mapper">
<Node ID="CDWarningThreshold">
<Node ID="Probe">
<Node ID="DS"/>
</Node>
</Node>
</Node>
</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>