Search code examples
vbscriptwindows-server-2012scom

SCOM Monitor not reporting


I am running into a bit of an issue with SCOM. I have create the script below to monitor an application. It creates an entry in the Event log when the script runs and I have configured the alerts for a specific group in which the monitor is running on.

Am I not creating the script right is my question?

Here is an error that I got when I changed oAPI.Return(oBag) to oAPI.ReturnItems

The process started at 2:24:23 PM failed to create System.PropertyBagData. Errors found in output:

C:\Program Files\System Center Operations Manager\Agent\Health Service State\Monitoring Host Temporary Files 84\29451\voxwareMonitor.vbs(33, 2) Microsoft VBScript runtime error: Invalid procedure call or argument

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

Solution

  • As per MOMScriptAPI.ReturnItems Method:

    The ReturnItems method submits objects to Operations Manager. For this method to be successful, objects must have been previously added to the in-memory array with MOMScriptAPI.AddItem.

    Example:

    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