LiebermanSoftware.ERPMMP.AppPerformanceDataSourceModuleType

LiebermanSoftware.ERPMMP.AppPerformanceDataSourceModuleType (DataSourceModuleType)

Detect ERPM application's performance.

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Performance.Data

Member Modules:

ID Module Type TypeId RunAs 
DataSource DataSource Microsoft.Windows.TimedScript.PropertyBagProvider Default
perfMapper ConditionDetection System.Performance.DataGenericMapper Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
TimeoutSecondsint$Config/TimeoutSeconds$TimeoutSeconds
IntervalSecondsint$Config/IntervalSeconds$IntervalSeconds

Source Code:

<DataSourceModuleType ID="LiebermanSoftware.ERPMMP.AppPerformanceDataSourceModuleType" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element minOccurs="1" name="ComputerName" type="xsd:string"/>
<xsd:element minOccurs="1" default="300" name="IntervalSeconds" type="xsd:integer"/>
<xsd:element minOccurs="1" default="300" name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DataSource" TypeID="Windows!Microsoft.Windows.TimedScript.PropertyBagProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime/>
<ScriptName>ExePerformance.vbs</ScriptName>
<Arguments>"$Config/ComputerName$"</Arguments>
<ScriptBody><Script><![CDATA[
SetLocale("en-us")
sub AddField (objAPI, counter, StatusValue)
Set oBag = objAPI.CreateTypedPropertyBag(2)
oBag.AddValue "StatusCounter" , counter
oBag.AddValue "StatusInstance" , "ERPM"
oBag.AddValue "StatusValue", StatusValue
objAPI.AddItem oBag
End sub

time1 = now()

'Instantiate Opsmgr runtime scripting
Set oAPI = CreateObject("MOM.ScriptAPI")

'Instantiate object for collecting values passed to the script
Set objParameters = WScript.Arguments
'Assign target FileName from arguments.
'The 0 indicates FileName is the first argument
FileName = "ROULETTE.EXE"
strComputer = objParameters(0)

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcess = objWMIService.ExecQuery("Select * from Win32_Process")

'Set objRefresher = CreateObject("WbemScripting.SWbemRefresher")
'Set colItems = objRefresher.AddEnum(objWMIService, "Win32_PerfFormattedData_PerfProc_Process").objectSet

'objRefresher.Refresh
'Wscript.Sleep 5000
'objRefresher.Refresh
found = false
For Each objItem in colProcess
if Ucase(objItem.Name) = Ucase(FileName) then
AddField oAPI, "HandleCount", objItem.HandleCount
AddField oAPI, "ThreadCount", objItem.ThreadCount
AddField oAPI, "PeakPageFileUsage", objItem.PeakPageFileUsage
AddField oAPI, "PeakVirtualSize (KB)", cdbl(objItem.PeakVirtualSize) / 1024
AddField oAPI, "PeakWorkingSetSize", objItem.PeakWorkingSetSize
AddField oAPI, "VirtualSize (KB)", cdbl(objItem.VirtualSize) / 1024
found = true
exit for
end if
Next
if found = false then
AddField oAPI, "HandleCount", -1
AddField oAPI, "ThreadCount", -1
AddField oAPI, "PeakPageFileUsage", -1
AddField oAPI, "PeakVirtualSize (KB)", -1
AddField oAPI, "PeakWorkingSetSize", -1
AddField oAPI, "VirtualSize (KB)", -1
end if
oAPI.ReturnItems
oAPI.logscriptevent "ERPM - ExePerformance", 200, 4, "total = " + cstr(DateDiff("s", time1, now)) + " seconds"
]]></Script></ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</DataSource>
<ConditionDetection ID="perfMapper" TypeID="SystemPerf!System.Performance.DataGenericMapper">
<ObjectName>Enterprise Random Password Manager</ObjectName>
<CounterName>$Data/Property[@Name='StatusCounter']$</CounterName>
<InstanceName>$Data/Property[@Name='StatusInstance']$</InstanceName>
<Value>$Data/Property[@Name='StatusValue']$</Value>
</ConditionDetection>
</MemberModules>
<Composition>
<Node ID="perfMapper">
<Node ID="DataSource"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>SystemPerf!System.Performance.Data</OutputType>
</DataSourceModuleType>