I did some work in this area
A few years ago, I worked with a company
to parse the docs in stlog.nsf and dump them to a view so that you don't
end up with many entries per user. I don't remember all of the details,
but here was the code that handled that part. You could use that as a starting
point for something similar.
%REM
Agent User Versions
Created Jun 27, 2012 by Chad Scott/Austin/IBM
Description: Pulls information from the user logins view
and stores it as
a static, per-user document in a new view of stlog.nsf.
%END REM
Option
Public
Option
Declare
Private
Const
AGENT_VERSION = "User
Versions 0.1"
Private
Const
ST_USER_LOGINS_VIEW = "Notes
Community Server Login and Logout Events by User"
Private
Const
ST_USER_VERSION_VIEW = "User
Client Versions"
Private
Const
ST_USER_VERSION_FORM = "ClientVersions"
Private
Const
ST_USER_ID = "UserID"
Private
Const
ST_APP_NAME = "ApplicationName"
Private
Const
ST_IP_ADDRESS = "NetworkAddress"
Sub
Initialize
Dim
s As
New
NotesSession
Dim
stLogDb As
NotesDatabase
Dim
userLoginView As
NotesView
Dim
userLoginViewDC As
NotesDocumentCollection
Dim
userLoginViewDoc As
NotesDocument
Dim
userLoginViewUserID As
Variant
Dim
userVersionView As
NotesView
Dim
userVersionViewDoc As
NotesDocument
Dim
userVersionViewUserID As
String
Dim
counter As
Long
Set
stLogDb = s.CurrentDatabase
counter
= 0
'
See if our target view exists. If not, log a message that it needs to be
created and
'
exit. This view is required because we need to correlate entries in it
with entries in
'
the user login view."
Set
userVersionView = stLogDb.GetView(ST_USER_VERSION_VIEW)
If
(userVersionView Is
Nothing)
Then
Print
"The User
Client Versions view does not exist. Please create it and re-run the agent."
Exit
Sub
End
If
'
Get the unprocessed documents from our source view
Set
userLoginViewDC = stLogDb.UnprocessedDocuments
'
Print stLoginViewDC.Count
'
Loop through the unprocessed documents
Set
userLoginViewDoc = userLoginViewDC.GetFirstDocument
While
(Not
userLoginViewDoc Is
Nothing)
counter = counter + 1
'
Look for a document in the User Client Versions view for this same user
userLoginViewUserID = userLoginViewDoc.GetItemValue(ST_USER_ID)
If
(userLoginViewUserID(0)
= "")
Then
Goto
NextDoc
Else
userVersionViewUserID
= userLoginViewUserID(0)
Set
userVersionViewDoc = userVersionView.GetDocumentByKey(userVersionViewUserID)
If
(Not
userVersionViewDoc Is
Nothing)
Then
'
We found a match, so update it
Call
UpdateClientInfo(userLoginViewDoc, UserVersionViewDoc, False)
Else
'
We didn't find a match. Create a new doc and update it
Set
userVersionViewDoc = stLogDb.CreateDocument
If
(userVersionViewDoc Is
Nothing)
Then
Print
"Error creating
a new document for ", userID
Goto
NextDoc
End
If
Call
UpdateClientInfo(userLoginViewDoc, UserVersionViewDoc, True)
End
If
'
Add $NoPurge so the docs won't age out of the log
Call
userVersionViewDoc.AppendItemValue("$NoPurge",
"1")
Call
userVersionViewDoc.Save(False,
False)
End
If
NextDoc:
Call
s.UpdateProcessedDoc(userLoginViewDoc)
Set
userLoginViewDoc = userLoginViewDC.GetNextDocument(userLoginViewDoc)
Wend
Print
AGENT_VERSION ":
Documents processed: ",
counter
End
Sub
Sub
UpdateClientInfo(userLoginViewDoc As
NotesDocument, userVersionViewDoc As
NotesDocument, isNewlyTrackedUser As
Boolean)
Dim
userID As
Variant
Dim
currentClientVersion As
Variant
Dim
existingClientVersion As
Variant
Dim
currentIPAddress As
Variant
Dim
existingIPAddress As
Variant
userID
= userLoginViewDoc.GetItemValue(ST_USER_ID)
currentClientVersion
= userLoginViewDoc.GetItemValue(ST_APP_NAME)
currentIPAddress
= userLoginViewDoc.GetItemValue(ST_IP_ADDRESS)
If
( userID(0)
<> ""
And
currentClientVersion(0)
<> ""
) Then
If
(isNewlyTrackedUser = True)
Then
'
If this is a user who does not already exist in our User Client Versions
view, we can just update the doc with no further ado
Call
userVersionViewDoc.AppendItemValue(ST_USER_ID, userID(0))
Call
userVersionViewDoc.AppendItemValue(ST_APP_NAME, currentClientVersion(0))
Call
userVersionViewDoc.AppendItemValue(ST_IP_ADDRESS, currentIPAddress(0))
Call
userVersionViewDoc.AppendItemValue("Form",
ST_USER_VERSION_FORM)
Else
'
If this user already exists in the User Client Versions view, see if the
ST client version
'
and IP address info remain the same. If either one is different, update
it
existingClientVersion
= userVersionViewDoc.GetItemValue(ST_APP_NAME)
existingIPAddress
= userVersionViewDoc.GetItemValue(ST_IP_ADDRESS)
If
(currentClientVersion(0)
<> existingClientVersion(0))
Then
Call
userVersionViewDoc.ReplaceItemValue(ST_APP_NAME, currentClientVersion(0))
End
If
If
(currentIPAddress(0)
<> existingIPAddress(0))
Then
Call
userVersionViewDoc.ReplaceItemValue(ST_IP_ADDRESS, currentIPAddress(0))
End
If
End
If
End
If
End
Sub