달력

4

« 2024/4 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
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 oAPI = Nothing


 
:
Posted by 커널64