How to parse the user activity of a Lotus Notes database
来源:互联网 发布:图片相似度对比算法 编辑:程序博客网 时间:2024/06/05 11:54
How to parse the user activity of a Lotus Notes database
- A
- AA
- AAA
- Reprints
Is it possible to parse the user activity of a Lotus Notes database? I want to remove automatic access to the Lotus Notes database (by agents or servers), using LotusScript.
VIEW MEMBER FEEDBACK TO THIS ASK THE EXPERT Q&A.
Absolutely. First you will need to visit http://www-10.lotus.com/ldd/sandbox.nsf and search for "UserActivity". Download the "NotesUserActivity Class" file. This is a sample Lotus Notes database containing a script library called "CLASSUserActivity."
When you look at this library, you will see only one subroutine. That's because in Lotus Notes, classes are defined in the "Declarations" section, so this library is basically one giant declaration (thus explaining why no one uses OOP or classes in LotusScript!).
I'm going to give you the LotusScript code you need to use this beastie, thus you'll have to find something else to spend the next two weeks figuring out.
I'll warn you -- pulling the usage history from each Lotus Notes database is fairly time consuming. In this code, lifted directly from my production application inventory crawler, Names2exclude lists the Lotus Domino servers, developers and administrators to ignore.
The usage counters here are declared globally, because the routine must be called once on each Lotus Domino server where a replica of the Lotus Notes database resides. Since each replica copy of a database has its own independent history, in this way the usage from all Lotus Domino server replica copies can be aggregate.
Const Names2exclude="CORPAGENTSIGNER~APPS001~CREGG S HARDWICK"Dim WeekUses As Long,WeekReads As Long,WeekWrites As LongDim MonthUses As Long,MonthReads As Long,MonthWrites As LongDim totaluses As Long,totalreads As Long,totalwrites As LongSub GetUserActivity(db As NotesDatabase) Dim ua As New NotesUserActivity(db)Dim uae As notesuseractivityentryIf ua.HasUserActivity ThenweekUses=ua.PrevWeekUsesweekReads=ua.PrevWeekReadsweekWrites=ua.PrevWeekWritesmonthUses=ua.PrevmonthUsesmonthReads=ua.PrevmonthReadsmonthWrites=ua.PrevmonthWritestotalUses=ua.UsestotalReads=ua.ReadstotalWrites=ua.WritesDim ActivityEntries As LongActivityEntries=ua.UserActivityCountIf ActivityEntries>0 ThenPrint " -- Reading "+Format(ActivityEntries,"###,##0")+_" history records..."End If Dim index As Variant,result As VariantDim AIndex As LongFor AIndex = 1 To ActivityEntriesSet uae = ua.GetNthUserActivityEntry(AIndex)result=Evaluate({@Name([Abbreviate];"}+_uae.UserName+{"):@Name([cn];"}+_uae.UserName+{")})If Instr(names2exclude,Ucase(result(1)))=0 Thenindex=Arraygetindex(UserList,result(0))If Isnull(index) ThenIf users<=maxusers Then Redim Preserve UserList(Users) As StringRedim Preserve readsList(Users) As LongRedim Preserve writesList(Users) As LongRedim Preserve sessionList(Users) As LongRedim Preserve timeList(Users) As StringUserList(Users)=result(0)timelist(users)=uae.timesessionList(Users)=1readsList(Users)=uae.readswriteslist(users)=uae.writesUsers=Users+1End IfElsesessionList(Index)=sessionList(Index)+1readsList(Index)=readsList(Index)+uae.readswriteslist(Index)=writeslist(Index)+uae.writesEnd IfEnd IfNext AIndex End IfEnd Sub
MEMBER FEEDBACK TO THIS ASK THE EXPERT Q&A:
I still have a problem with this code. When I try to save the agent I get the following error: "Reference occurs before declaration:UserList"
Allow me to point out that the variable is only declared three lines later.
If Instr(names2exclude,Ucase(result(1)))=0 Thenindex=Arraygetindex(UserList,result(0))If Isnull(index) ThenIf users<=maxusers Then Redim Preserve UserList(Users) As StringRedim Preserve readsList(Users) As LongRedim Preserve writesList(Users) As LongRedim Preserve sessionList(Users) As LongRedim Preserve timeList(Users) As StringUserList(Users)=result(0)timelist(users)=uae.timesessionList(Users)=1readsList(Users)=uae.readswriteslist(users)=uae.writesUsers=Users+1End IfElsesessionList(Index)=sessionList(Index)+1readsList(Index)=readsList(Index)+uae.readswriteslist(Index)=writeslist(Index)+uae.writesEnd IfEnd IfNext AIndex
—Wannes R.
******************************************
My apologies, I left out part of the Global Declarations section needed to support the GetUserActivity subroutine. Of course if -- in my production application, I had taken the time to compartmentalize this code in its own script library, then such a mistake would have been much harder to make!
To fix it, add the following to the Declarations section of your agent:
Dim users As LongDim UserList() As StringDim readsList() As LongDim writesList() As LongDim timelist() As StringDim sessionList() As Long
Once more, the agent or script library should be set up as follows:
In the Options section:
'Option PublicUse "CLASSUserActivity"Const Names2exclude="CORPAGENTSIGNER~APPS001~CREGG S HARDWICK"The Declarations section:
Dim totaluses As Long,totalreads Dim WeekUses As Long,WeekReads As Long,WeekWrites As LongDim MonthUses As Long, MonthReads As Long, MonthWrites As Long , totalwrites As LongDim users As LongDim UserList() As StringDim readsList() As LongDim writesList() As LongDim timelist() As StringDim sessionList() As LongThe initialize event for a test agent that will call it:Sub InitializeDim db As New notesdatabase("","")Call db.OpenByReplicaID(YOURSERVER,YOURDBREPLICAID)Call GetUserActivity(db)' Access the global variables above to get results…End SubThe subroutine that does the work:
Sub GetUserActivity(db As NotesDatabase) Dim ua As New NotesUserActivity(db) Dim uae As notesuseractivityentry If ua.HasUserActivity ThenweekUses=ua.PrevWeekUsesweekReads=ua.PrevWeekReadsweekWrites=ua.PrevWeekWritesmonthUses=ua.PrevmonthUsesmonthReads=ua.PrevmonthReadsmonthWrites=ua.PrevmonthWritestotalUses=ua.UsestotalReads=ua.ReadstotalWrites=ua.Writes Dim ActivityEntries As LongActivityEntries=ua.UserActivityCount If ActivityEntries>0 ThenPrint " -- Reading "+Format(ActivityEntries,"###,##0")+" history records..."End If Dim index As Variant,result As VariantDim AIndex As LongFor AIndex = 1 To ActivityEntriesSet uae = ua.GetNthUserActivityEntry(AIndex)result=Evaluate({@Name([Abbreviate];"}+uae.UserName+{"):@Name([cn];"}+uae.UserName+{")})If Instr(names2exclude,Ucase(result(1)))=0 Thenindex=Arraygetindex(UserList,result(0))If Isnull(index) Then If users<=maxusers Then Redim Preserve UserList(Users) As StringRedim Preserve readsList(Users) As LongRedim Preserve writesList(Users) As LongRedim Preserve sessionList(Users) As LongRedim Preserve timeList(Users) As StringUserList(Users)=result(0)timelist(users)=uae.timesessionList(Users)=1readsList(Users)=uae.readswriteslist(users)=uae.writesUsers=Users+1End IfElsesessionList(Index)=sessionList(Index)+1readsList(Index)=readsList(Index)+uae.readswriteslist(Index)=writeslist(Index)+uae.writesEnd IfEnd If Next AIndex End IfEnd Sub
—Cregg Hardwick, LotusScript expert
Do you have comments on this Ask the Expert Q&A? Let us know.
- How to parse the user activity of a Lotus Notes database
- How to delete the full-text index of a notes database
- Notes of “Quotient Cube: How to Summarize the Semantics of a Data Cube”
- How to Calculate the Number of IOPS and Throughput of a Database (文档 ID 2206831.1)
- How to grant access to SQL logins on a standby database when the guest user is disabled in SQL Serve
- How to set the Collation properties of the database
- How to add a user to the sudoers list
- How-To create a MySQL database and set privileges to a user
- 如何窥探PDB的秘密?(How to Inspect the Content of a Program Database (PDB) File)
- Lotus Notes survives the ending date of the world!
- How to manage Oracle Database User profile
- How to Quiesce a Database
- How to Setup A Database
- How to store raw MIME message to notes database
- [Decrypting User Password]How to find password of a User in Oracle Apps R12?
- After logging in to the Lotus Notes Client, you are prompted for a password in DOS-like window (Viru
- How to add a user and set environments for the user?
- How to Tell if the I/O of the Database is Slow - 1
- 虚拟机 挂载windows 共享目录
- asp.net ajax实现类似交替项模板 和 光棒效果。
- Methods, Not Methodology (3): Knowing Everything at the Beginning?
- MapABC API for iOS 文档
- 2012年蓝桥杯决赛最后一题
- How to parse the user activity of a Lotus Notes database
- 揭示C++中全局类变量的构造与析构顺序
- 盘点:崛起中的九大HTML5开发工具
- 常见内网设置
- 图像膨胀腐蚀开闭运算
- git revert和git reset的区别
- 2013寒假练习 1016:滑雪
- Linux从用户层到内核层系列 - TCP/IP协议栈部分系列1: linux内核协议栈协议的注册
- android Viewpager 动态添加载滑动