Share via


MSFT_Computer.InsertStatisticsIntoWorkflow Method

Inserts performance data into the workflow on the server running MOM.

 MSFT_Computer.InsertStatisticsIntoWorkflow(Statistics, Index)

Parameters

  • Statistics
    An array of MSFT_ParameterStatistic objects.

  • Index
    If all of the objects in the array are added successfully, the value is null. If an error occurs, this value is set to an unsigned 32-bit integer with the zero-based array index of the last performance data object successfully added to the workflow.

Return Value

This method returns an unsigned 32-bit integer. If all objects in the array are added successfully, the method returns 0. If errors occurred, a nonzero value is returned and you should check the value of the Index parameter. If this method is called on a computer with a Type property that is not equal to 8192 (non-Windows), both the method return value and the value of the Index parameter are null.

Remarks

This method works only for computers that have been created and added through MOM APIs.

When creating performance rules to monitor data created by the InsertStatisticsIntoWorkflow method, your rule must use the Script-Generated Data provider.

Examples

The following example shows the use of the InsertStatisticsIntoWorkflow method.

'*********************************************************************
' Routine: Function SendPerfDataForNonWindowsComputer
' Purpose: Generates performance statistics for a non-Windows computer.
' Arguments: The server running MOM, computer GUID, perf counter name,
'            instance name, object name, value.
' Returns: The result from calling InsertStatisticsIntoWorkflow.
'
'**********************************************************************
Const TYPE_NONWINDOWS = 8192

Function SendPerfDataForNonWindowsComputer(strMOMServer, strComputerGUID, strCounter, strInstance, strObject, fValue)
    Dim objComputer, objStatClass, objGeneratedStat
    Dim arrStats(0)
    Dim dtmCurrentTime
    Dim lngResult, lngLastStatAdded

    lngResult = -1
    lngLastStatAdded = -1

    Set objComputer = GetObject("WinMgmts://" & strMOMServer & "\root\MOM:MSFT_Computer='" & strComputerGUID & "'")

    If Not(objComputer Is Nothing) Then
        If (objComputer.Type = TYPE_NONWINDOWS) Then

            ' create a new stat and set its property values
            Set objStatClass = GetObject("WinMgmts://" & strMOMServer & "\root\MOM:MSFT_ParameterStatistic")

            Set objGeneratedStat = objStatClass.SpawnInstance_()

            ' Format: \\Computer\Object(Instance)\Counter
            objGeneratedStat.ObjectName = strObject
            objGeneratedStat.InstanceName = strInstance ' optional
            objGeneratedStat.CounterName = strCounter
            objGeneratedStat.Value = fValue

            ' add the stat to an array
            Set arrStats(0) = objGeneratedStat

            ' submit the array for the non-Windows computer
            lngResult = objComputer.InsertStatisticsIntoWorkflow(arrStats, lngLastStatAdded)

        End If
    End If

    Set objComputer = Nothing
    Set objStatClass = Nothing
    Set objGeneratedStat = Nothing

    SendPerfDataForNonWindowsComputer = lngResult
End Function
  

Requirements

Platforms: Requires Windows 2000 Server or later

Version: Requires MOM 2000 SP1 or later

See Also

MSFT_Computer Class | MSFT_Computer.Type Property | MSFT_ParameterStatistic Class