Ten monitor wykrywa potencjalne problemy z operacyjną bazą danych, sprawdzając stan procesów pielęgnacji i partycjonowania, które mogą powodować problemy z wydajnością.
Knowledge Base article:
Podsumowanie
Typ monitora służący do kontroli procesów pielęgnacji i partycjonowania.
Ten przepływ pracy powoduje cykliczne uruchamianie skryptu. Interwał to liczba sekund upływająca pomiędzy kolejnymi wykonaniami skryptu. Można zmienić tę wartość, aby przepływ pracy działał częściej lub rzadziej.
Synctime
string
$Config/Synctime$
Godzina synchronizacji
TimeoutSeconds
int
$Config/TimeoutSeconds$
Limit czasu (w sekundach)
Ten przepływ pracy powoduje cykliczne uruchamianie skryptu. Limit czasu to liczba sekund, przez jaką skrypt może działać, zanim zostanie wymuszone jego zatrzymanie. Uwaga: limit czasu powinien zawsze być krótszy niż interwał, aby uniknąć jednoczesnego uruchamiania wielu wystąpień tego samego skryptu.
Threshold
int
$Config/Threshold$
Maksymalna liczba dni od ostatniego powodzenia
W tym przepływie pracy stan określany jest na podstawie wartości progowej, którą jest maksymalna liczba dni od ostatniego powodzenia. Ustaw ten parametr jako maksymalną liczbę dni, które mogą upłynąć bez pomyślnego zakończenia partycjonowania i pielęgnowania, zanim zostanie to uznane za problem.
TimesBeforeAlert
int
$Config/TimesBeforeAlert$
Liczba próbek przed wywołaniem alertu
Liczba próbek, przy której monitor zmienia stan na ostrzegawczy.
'*************************************************************************
' $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 = &H80000002
Const HKEY_CLASSES_ROOT = &H80000000
Dim strComputer, strDriverPath, strKeyPath, intValue, strValueName,arrSubKeys,oSubkey,strNewKeyPath,intDotIndex, strDriverPathFromHKeyClassRoot
strComputer = "."
strDriverPath="SQLOLEDB"
Set oReg=GetObject("winmgmts:\\" & _
strComputer & "\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
For Each oSubkey In arrSubKeys
intValue = InStr(oSubkey, "SQL Server Native Client")
if intValue <> 0 Then
strValueName = "Driver"
strNewKeyPath = strKeyPath&"\"&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
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=" & strDriverName & ";Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=" & _
strDatabase & ";Data Source=" & strDBServer & ""
ObjError.Save
On Error Goto 0
If ObjError.Number <> 0 Then
strMessageToUse = "Error Number: " & ObjError.number & " Error Details: " & ObjError.Description
call GetState(true, strMessageToUse, "0", "0", strDaysLimitThreshold)
WScript.Quit
End If
strQuery = "SELECT Count(StatusCode) AS TotalCount " & _
"FROM InternalJobHistory " & _
"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 <> 0 Then
strMessageToUse = "Error Number: " & ObjError.number & " Error Details: " & ObjError.Description
call GetState(true, strMessageToUse, "0", "0", strDaysLimitThreshold)
WScript.Quit
End If
strQuery = "SELECT Count(StatusCode) AS CountOfJobsSucceeded " & _
"FROM InternalJobHistory " & _
"WHERE TimeStarted BETWEEN " & _
"DATEADD(day, -" & strDaysLimitThreshold & ", GETUTCDATE()) " & _
"AND GETUTCDATE() " & _
"AND Command = 'Exec dbo.p_GroomPartitionedObjects and dbo.p_Grooming' " & _
"AND StatusCode = 1 "
'Query DB
Set objRS = objCN.Execute(strQuery)
ObjError.Save
On Error Goto 0
If ObjError.Number <> 0 Then
strMessageToUse = "Error Number: " & ObjError.number & " Error Details: " & ObjError.Description
call GetState(true, strMessageToUse, "0", "0", strDaysLimitThreshold)
WScript.Quit
End If
strMessageToUse = "Script executed with Process Succeed Count " & strCountOfJobsSucceeded & " from Total Process Count " & 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
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