SCOM 定时监控双态脚本不起作用

SCOM 定时监控双态脚本不起作用

我有一个已添加到监控中的双状态脚本,用于检查两台服务器上服务的状态,并报告该服务是否在两台服务器上运行或都不运行(应该只在一台服务器上运行)。它在交互模式下运行良好,但在 SCOM 2007 中无法正常工作。有人知道我遗漏了什么吗?

我已经根据 propertybag 值添加了健康和不健康检查。

脚本如下:

Dim oAPI
Dim oBag
Dim strService
Dim strComputer1
Dim strComputer2
Dim isService1Running 
Dim isService2Running 
Dim isProblem

Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()

strService = "My Service Name"
strComputer1 = "myServer1"
strComputer2 = "myServer2"

isService1Running = IsServiceRunning(strComputer1, strService)
isService2Running = IsServiceRunning(strComputer2, strService)

isProblem = (isService1Running And isService2Running) Or (Not isService1Running And Not isService2Running)

If isProblem Then
Call oBag.AddValue("State", "BAD")
Else
Call oBag.AddValue("State", "GOOD")
End If

Call oAPI.Return(oBag)


Function IsServiceRunning(strComputer, strService)

Dim objWMIService, colItems, objItem

Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery("Select * from Win32_Service where DisplayName = '" & strService & "'")

IsServiceRunning = false
For Each objItem in colItems
    If objItem.status <> "OK" or objItem.state <> "Running" then
      Else
        IsServiceRunning = true
    End If
Next

End Function

答案1

SCOM 操作帐户是否有权访问远程服务器上的 WMI。您可能必须创建一个 Run-As 配置文件来与监视器关联,并创建一个与之关联的帐户,该帐户有权访问远程服务器上的 WMI。

相关内容