As a result of 'stuck' MAPI probe prcosses in APM 3.1 I am trying to develop a template to monitor the number of MAPI probe processes running. The thought here is that if there is more than one of a MAPI probe process than I might want to kill it in order to avoid the probe failing.
In any event I have this great VBscript which shows the User name of the probe and counts the number of current running processes. Now I am trying to figure out how to incorporate this into APM so I can work up an alert and possible action.
Here is the current script. Note that our MAPI probes contain the lettering "cvs" hence the wildcard in the query.
I will also include a sample output.
Any help would be GREATLY appreciated!
Script:
'On Error Resume Next
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
arrComputers = Array("127.0.0.1")
Set oDict = CreateObject("Scripting.Dictionary")
oDict.CompareMode = vbBTextCompare
For Each strComputer In arrComputers
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Process where commandline like '%cvs%'", "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly )
For Each objItem In colItems
AddResult "" & mid(objitem.commandline,instr(objItem.CommandLine, "-u")+3,(instr(objItem.CommandLine, "-serv")-7)-instr(objItem.CommandLine, "-u")+3)
Next
Next
'Show Results
for each blah in oDict.Keys
wscript.echo blah & vbTab & oDict(blah)
Next
Function WMIDateStringToDate(dtmDate)
WScript.Echo dtm:
WMIDateStringToDate = CDate(Mid(dtmDate, 5, 2) & "/" & _
Mid(dtmDate, 7, 2) & "/" & Left(dtmDate, 4) _
& " " & Mid (dtmDate, 9, 2) & ":" & Mid(dtmDate, 11, 2) & ":" & Mid(dtmDate,13, 2))
End Function
Sub AddResult(myVal)
If oDict.Exists(myVal) Then
oDict.Item(myVal)=oDict.Item(myVal)+1
Else
oDict.Add myVal,1
End If
End Sub
-----------------
RESULTS:
CVS-2.AB1.SG1 1
CVS-1.AB1.SG1 3
------------------
The above results means that at the time the script ran it found 3 duplicate processes for CVS-1.AB1.SG1.
Ideally I would then trigger an alert since there theoretically be only one running unique MAPI probe process at a time.