我遇到了SCOM的一个问题。我已创建下面的脚本来监视应用程序。它在脚本运行时在事件日志中创建一个条目,并且我已为运行监视器的特定组配置了警报。
我是不是正确创建脚本是我的问题?
我将oAPI.Return(oBag)
更改为oAPI.ReturnItems
在下午2:24:23开始的过程无法创建 System.PropertyBagData。输出中发现的错误:
C:\ Program Files \ System Center Operations Manager \ Agent \ Health Service State \ Monitoring Host Temporary Files 84 \ 29451 \ voxwareMonitor.vbs(33, 2)Microsoft VBScript运行时错误:无效的过程调用或 参数
Dim proc, serv, oArgs, oAPI, oBag
sComputerName = "."
Set objWMIService = GetObject("winmgmts:\\" & sComputerName & "\root\cimv2")
sQueryPro = "SELECT * FROM Win32_Process"
sQuerySer = "SELECT * FROM Win32_Service"
Set objProcs = objWMIService.ExecQuery(sQueryPro)
Set objServ = objWMIService.ExecQuery(sQuerySer)
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()
For Each objItem In objProcs
If objItem.Name = "javaw.exe" Then
proc = True
End If
Next
For Each objS In objServ
If objS.Name = "vlsoperatorconsole_voxwarevls" Then
serv = True
End If
Next
If proc = True And serv = True Then
Call oBag.AddValue("Service", "Running")
Call oBag.AddValue("Process", "Running")
oAPI.LogScriptEvent "Voxware Monitor", 411, 0, "Application and Services are running"
Call oAPI.Return(oBag)
Else
If proc = False Then
Call oBag.AddValue("Process", "Stopped")
oAPI.LogScriptEvent "Voxware Monitor", 911, 1, "Process has stopped"
Call oAPI.Return(oBag)
End If
If serv = False Then
Call oBag.AddValue("Service", "Stopped")
oAPI.LogScriptEvent "Voxware Monitor", 911, 1, "Service has stopped"
Call oAPI.Return(oBag)
End If
End If
答案 0 :(得分:3)
根据MOMScriptAPI.ReturnItems Method:
ReturnItems
方法将对象提交给Operations Manager。对于 要成功此方法,必须先添加对象 使用MOMScriptAPI.AddItem
到内存数组。
示例:
Call oBag.AddValue("Service", "Running")
Call oBag.AddValue("Process", "Running")
oAPI.LogScriptEvent "Voxware Monitor", 411, 0, "Application and Services are running"
'''Call oAPI.Return(oBag)
oAPI.AddItem oBag
Call oAPI.ReturnItems