LiebermanSoftware.ERPMMP.ZoneProbeActionModuleType

LiebermanSoftware.ERPMMP.ZoneProbeActionModuleType (ProbeActionModuleType)

Element properties:

TypeProbeActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
PassThrough ProbeAction System.PassThroughProbe Default
Script ProbeAction Microsoft.Windows.ScriptPropertyBagProbe Default

Source Code:

<ProbeActionModuleType ID="LiebermanSoftware.ERPMMP.ZoneProbeActionModuleType" Accessibility="Internal" Batching="false" PassThrough="false">
<Configuration>
<xsd:element minOccurs="1" default="300" name="TimeoutSeconds" type="xsd:integer"/>
<xsd:element minOccurs="1" name="ServiceName" type="xsd:string"/>
<xsd:element minOccurs="1" name="ZoneName" type="xsd:string"/>
</Configuration>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="PassThrough" TypeID="System!System.PassThroughProbe"/>
<ProbeAction ID="Script" TypeID="Windows!Microsoft.Windows.ScriptPropertyBagProbe">
<ScriptName>ZoneProbeAction.vbs</ScriptName>
<Arguments>"$Config/ZoneName$" "$Config/ServiceName$" RouletteProc.exe</Arguments>
<ScriptBody><Script><![CDATA[
SetLocale("en-us")
Function WMIDateStringToDate(dtmInstallDate)
WMIDateStringToDate = CDate(Mid(dtmInstallDate, 5, 2) +"/" + Mid(dtmInstallDate, 7, 2) +"/" +Left(dtmInstallDate, 4) +" " +Mid (dtmInstallDate, 9, 2) +":" +Mid(dtmInstallDate, 11, 2) +":" +Mid(dtmInstallDate, 13, 2))
End Function

time1 = now()

Set objParameters = WScript.Arguments
computername = objParameters(0)
servicename = objParameters(1)
instancename = objParameters(2)

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

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" +computername +"\root\cimv2")
Set colProcesses = objWMIService.ExecQuery("select * from win32_process where Caption = '" +InstanceName +"'")

total = 0
For Each objProcess in colProcesses
total = total + 1
Next

i = 1
if total >1 then
alertonproc = 1
Call oBag.AddValue("Deferred Process Error", "Multiple instances on the same computer")
Call oBag.AddValue("Computer ",computername)
for Each objProcess in colProcesses
Call oBag.AddValue("ProcessID" + CStr(i), objProcess.ProcessID)
Call oBag.AddValue("CreationDate" + CStr(i), CDate(WMIDateStringToDate(objProcess.CreationDate)))
i = i + 1
Next
end if


set servinfo=objWMIService.ExecQuery("select * from win32_service where name =" & """" & servicename & """")
if servinfo.Count = 0 then
Call oBag.AddValue("Service Error", "Not Installed")
Call oBag.AddValue("Report Computer " + cstr(i),computername)
Call oBag.AddValue("Service Name " + cstr(i),servicename)
Call oBag.AddValue("Service State " + cstr(i),"Not Installed")
alertonservice = 1
else
for each objservice in servinfo
if objservice.State <> "Running" or objservice.StartMode <> "Auto" then
Call oBag.AddValue("Reason", "Configuration Error")
Call oBag.AddValue("Report Computer " + cstr(i),computername)
Call oBag.AddValue("Service Name " + cstr(i),servicename)
Call oBag.AddValue("Service State "+ cstr(i),objservice.State)
Call oBag.AddValue("Service StartMode " + cstr(i),objservice.StartMode)
alertonservice = 1
end if
Next
end if

if alertonservice=1 or alertonproc=1 then
Call oBag.AddValue("State", "BAD")
else
Call oBag.AddValue("State", "GOOD")
end if

Call oAPI.Return(oBag)

oAPI.logscriptevent "ERPM - ZoneProbe", 206, 4, "total = " + cstr(DateDiff("s", time1, now)) + " seconds"

]]></Script></ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="Script">
<Node ID="PassThrough"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
<TriggerOnly>true</TriggerOnly>
</ProbeActionModuleType>