2008. 12. 19. 15:02
SCOM 2007 - 특정 디렉토리의 파일 수 모니터 SystemCenter2008. 12. 19. 15:02
특정 폴더(Parameter 1)의 파일 수가 일정 수(Parameter 2)를 넘지 않는지에 대한 모니터
Monitor -> New -> Scripting -> Timed Script Two State Monitor
Parameter
"<Folder Name>" <Number Of Files>
State Expression
For Unhealthy Expression Property[@Name='State'] Equals BAD
For Healthy Expresion Property[@Name='State'] Equals GOOD
------------------------------------------------------------
Check.Folder.vbs
On Error Resume Next
Dim oAPI, oBag, objFSO, objFldr
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreateTypedPropertyBag(StateDataType)
Set oArgs = WScript.Arguments
MessageText = ""
If oArgs.Count < 1 Then
Call oAPI.LogScriptEvent("Check.Folder.vbs", 500, 0, "Script aborted. Not enough parameters provided.")
WScript.Quit -1
End If
strFldr = oArgs(0)
NumberOfFiles = int(oArgs(1))
Set objFSO=CreateObject("Scripting.FileSystemObject")
Set objFldr=objFSO.GetFolder(strFldr)
If objFldr.Files.Count > NumberOfFiles Then
strReturn = "Number of Files in " & strFldr& " is greater than " & NumberOfFiles
Call oBag.AddValue("State","BAD")
Call oBag.AddValue("ret",strReturn)
Else
Call oBag.AddValue("State","GOOD")
End If
Call oAPI.Return(oBag)