Welcome to Port3101.org : Your BES Connection Mark forums read | View Forum Leaders
Port3101.org : Your BES Connection



Reply
LinkBack Thread Tools Display Modes
Mailbox Agent Log Parser
 
  #1 (permalink)  
Old 03-25-2010, 08:04 AM
0xdeadbeef's Avatar
BES Admin
 
Join Date: Mar 2010
Posts: 2
Default Mailbox Agent Log Parser

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
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-26-2010, 05:08 AM
BES Administrator
 
Join Date: Feb 2009
Posts: 21
Default

Thank you ! I always like when people are trying to deliver useful scripts and tools. But what´s it doing different to the Messageflow Tool from the BlackBerry Resource Kit ? Why would I use this over the Messageflow ?
Reply With Quote
  #3 (permalink)  
Old 03-26-2010, 09:43 AM
0xdeadbeef's Avatar
BES Admin
 
Join Date: Mar 2010
Posts: 2
Default

Quote:
Originally Posted by magikweis View Post
Thank you ! I always like when people are trying to deliver useful scripts and tools. But what´s it doing different to the Messageflow Tool from the BlackBerry Resource Kit ? Why would I use this over the Messageflow ?
I originally wrote this some time back, probably before I was aware of the resource kit... which I'm now in the process of downloading! Had forgotten about that. Thanks for jogging my memory.
Reply With Quote
Reply

Bookmarks

Tags
scripts;log files

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Mailbox Agent not functioning properly AUTiger92 Port 3101: The BES Admin Bar & Grill 4 10-28-2009 02:08 PM
KB12766 - Assign BlackBerry smartphone users to a static mailbox agent hdawg Featured BlackBerry KB Articles 3 09-16-2009 09:20 PM
KB04772 - Mailbox move repeatedly detected in the BlackBerry Messaging Agent log hdawg Featured BlackBerry KB Articles 0 08-23-2009 09:05 PM
KB04474 - Handheldcleanup.exe does not detect mailbox moves between mailbox stores hdawg Featured BlackBerry KB Articles 1 04-14-2009 07:17 PM
sync ALL messages from mailbox to BB gpalmer Port 3101: The BES Admin Bar & Grill 2 02-06-2009 04:24 PM


All times are GMT -4. The time now is 05:00 AM.
Powered by vBulletin® Version 3.8.9
Copyright ©2000 - 2018, vBulletin Solutions, Inc.


 

SEO by vBSEO 3.3.2 PL2