Hi all,
A while back I wrote a mailbox agent log parser to output the particular lines that relate to a given user as well as message tag numbers that relate to them. It's a VBScript and requires you to copy the log file to the location of the script.
Usage:
cscript bblog.vbs /u:Username /l:logfilename
The output should be username.txt
See what you think. (Hopefully I've posted the script correctly!)
Code:
Option Explicit
'On Error Resume Next
' 08/05/2009
' Parse a BlackBerry server Mailbox Agent log file for a
' particular user.
' Also looks for message tag numbers that relate to the
' user and grabs them as well.
' Usage:
' cscript BBLog.vbs /u:Username /l:LogFileName
'
' The output file is the username plus .txt
Const ForReading = 1
Const ForWriting = 2
Const ForAppending = 8
' Dims stuff
Dim objStdOut, args
Dim objFSO, objLogFile, LogFile, objOutFile
Dim UserName, ucUserName, LogLine, ucLogLine
Dim Tag, sTag, arrTags, ucDispName
' Set Stuff
Set objStdOut = Wscript.stdOut
Set args = Wscript.Arguments.Named
LogFile = trim(args.Item("l"))
UserName = Trim(args.Item("u"))
If LogFile = "" Then
objStdOut.Write "Usage: cscript BBLog.vbs /u:Username /l:LogFileName"
wscript.quit
End If
If UserName = "" Then
objStdOut.Write "Usage: cscript BBLog.vbs /u:Username /l:LogFileName"
wscript.quit
End If
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objLogFile = objFSO.OpenTextFile (LogFile, ForReading)
Set objOutFile = objFSO.CreateTextFile (UserName & ".txt", ForWriting)
' User.Surname
ucUserName=UCase(UserName)
' Surname User
ucDispName=Right(ucUserName,Len(ucUserName)-InStr(ucUserName,".")) & " " & Left(ucUserName,InStr(ucUserName,".")-1)
ReDim arrTags(0)
'For Each ServerName in ServerList
Do Until objLogFile.AtEndOfStream
LogLine = objLogFile.ReadLine
WScript.StdOut.Write "."
ucLogLine=UCase(LogLine)
'If InStr(ucLogLine,ucUserName)>0 Then
If InStr(ucLogLine,ucUserName)>0 Or InStr(ucLogLine,ucDispName)>0 Then
objOutFile.WriteLine LogLine
' SubmitToRelaySendQ, Tag=1882291
If InStr(ucLogLine,"SUBMITTORELAYSENDQ")>0 Then
Tag=Right(ucLogLine,(Len(ucLogLine)-InStr(ucLogLine,"TAG="))+1)
arrTags(UBound(arrTags))=Tag
ReDim Preserve arrTags(UBound(arrTags) + 1)
End If ' Found SubmitToRelaySendQ
End If ' Found UserName
' If we have a reception line, check the tag to see if it's one we want
If InStr(ucLogLine,"[BIPP]")>0 And InStr(ucLogLine,"TAG=")>0 Then
Tag=Right(ucLogLine,(Len(ucLogLine)-InStr(ucLogLine,"TAG="))+1) ' Parse the Tag= bit
For Each sTag In arrTags
If sTag=Tag Then
objOutFile.WriteLine LogLine
End If
Next
End If
Loop ' Do Until...
ReDim arrTags(0)
objLogFile.Close
objOutFile.Close
WScript.quit ' TTFN