2013. 10. 12. 18:39
SCOM 스크립트 모니터 - 실패한 클러스터 리소스 SystemCenter2013. 10. 12. 18:39
VBS VB 스크립트 기반 SCOM 모니터 - 장애 조치 클러스터의 실패한 클러스터 리소스 그룹 모니터링
'==========================================================
'==========================================================
'Normal State: Property[@Name='State'] equals Normal
'Error State: Property[@Name='State'] equals Critical
'Alert Message: $Data/Context/Property[@Name='Message']$
'==========================================================
On Error Resume Next
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
Set wshShell = WScript.CreateObject( "WScript.Shell" )
strHostName = wshShell.ExpandEnvironmentStrings( "%COMPUTERNAME%" )
Set wshShell = Nothing
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\mscluster")
Set colItems = objWMIService.ExecQuery("Select * from MSCluster_ResourceGroup Where OwnerNode = '"&strHostName&"' And State = 2")
strFailedRes = ""
If colItems.Count <> 0 Then
For each Item in colItems
strFailedRes = strFailedRes & Item.Name & ", "
Call oBag.AddValue("Failed Resource", Item.Name)
Next
Call oBag.AddValue("State", "Critical")
If colItems.Count = 1 Then
Call oBag.AddValue("Message", "There is a Failed Cluster Resource. '"&Left(strFailedRes,Len(strFailedRes)-2)&"'")
Else
Call oBag.AddValue("Message", "There are Failed Cluster Resources. '"&Left(strFailedRes,Len(strFailedRes)-2)&"'")
End If
Else
Call oBag.AddValue("State", "Normal")
Call oBag.AddValue("Message", "There is no Failed Cluster Resource.")
End If
Set colItems = Nothing
Set objWMIService = Nothing
Call oAPI.Return(oBag)
Set oBag = Nothing
Set oBag = Nothing
Set oAPI = Nothing