Home > Domino Tips > Administrator > Database > Record live view index size information
Domino Tips:
EMAIL THIS
 TIPS & NEWSLETTERS TOPICS 

DATABASE

Record live view index size information


Dallas Gimpel
10.14.2004
Rating: --- (out of 5)


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   


This tip records the index size of all views in a given database by issuing a console command and parsing the response. The same information is available in the Notes log, but it is not "live."

There may be easier/better ways to do it, but this works. Paste the code into an agent/button, then add the call to the main sub in the initialize event of the agent or the click event of the button. Note that the signer/user should have access to issue the "show database" console command on the server where the target database resides. The results are written to a file in the temporary directory of the current workstation.

dgg 
  
  Sub main()
 On Error Goto errorHandler
 
 Dim nsess As NotesSession
 Dim ndbTarget As NotesDatabase
 Dim intHdrLocation As Integer
 Dim strServerName As String
 Dim strReplicaID As String
 Dim varResults As Variant
 
 Set nsess = New NotesSession
 Set ndbTarget = New NotesDatabase("", "")
 
'// Get the server name on which the 
target database resides.
 strServerName$ = Trim$(Inputbox
("Please enter the server name.", "Enter 
server name . . .", 
nsess.CurrentDatabase.Server))
 If Len(strServerName$) = 0 Then
  Print "Action cancelled . . ."
  Goto subExit
 End If
 
'// Get the replica ID of the target database.
 strReplicaID$ = Trim$(Inputbox
("Please enter the replica ID of the target 
database.", "Enter the replica ID . . .", ""))
 strReplicaID$ = Replace(strReplicaID$, ":", "")
 If Len(strReplicaID$) = 0 Then
  Print "Action cancelled . . ."
  Goto subExit
 End If
 
'// Attempt to open the database using the 
information provided.
 If Not(ndbTarget.OpenByReplicaID
(strServerName$, strReplicaID$)) Then
  Msgbox "Failed to open a database on "
 & strServerName$ & " using replica 
id " & strReplicaID$ & " - unable to proceed.", , 
"Failed to open a 
database . . ."
  Goto subExit
 End If
 
'// Issue the command to the server.
 varResults = 
nSess.SendConsoleCommand(ndbTarget.Server,
 "show database " & 
ndbTarget.FilePath)
 varResults = Replace(varResults, Chr(10), "") 
'// remove line feeds
 
'// Write results to an array for processing.
 varResults = Split(varResults, Chr(13))
 If Not(trimConsoleResponse(varResults)) Then
  Goto subExit
 End If
 
'// Get the location of the "header" for the
 view information.
 If Not(locateViewHeader(intHdrLocation%, 
varResults)) Then
  Goto subExit
 End If
 
'// Now record the results.
 Call recordData(nsess, ndbTarget,
 intHdrLocation%, varResults)
 
subExit:
 Exit Sub
 
errorHandler:
 Msgbox "Error " & Err & ": " & Error$ & 
" encountered at line " & Erl & " 
of " & Getthreadinfo(1) & ".", , 
"Error encountered . . ."
 Print "Error " & Err & ": " & Error$ & 
" encountered at line " & Erl & " of " 
& Getthreadinfo(1) & " . . ."
 Resume subExit
End Sub

Function trimConsoleResponse
(pvarResults As Variant) As Boolean
 On Error Goto errorHandler
 
 trimConsoleResponse = False
 If Isarray(pvarResults) Then
  Forall rez In pvarResults
   rez = Ltrim$(Rtrim$(rez))
  End Forall
  trimConsoleResponse = True
 End If
 
functionExit:
 Exit Function
 
errorHandler:
 Msgbox "Error " & Err & ": " & Error$ 
& " encountered at line " & Erl & " 
of " & Getthreadinfo(1) & ".", , 
"Error encountered . . ."
 Print "Error " & Err & ": " & Error$ 
& " encountered at line " & Erl & " of " 
& Getthreadinfo(1) & " . . ."
 Resume functionExit
End Function

Function locateViewHeader
(pintPositionOut As Integer, pvarResults 
As Variant) 
As Boolean
 On Error Goto errorHandler
 
 Const VIEW_HEADER = "VIEW SIZES"
 Dim i As Integer
 
 locateViewHeader = False
 i = - 1
 Forall rez In pvarResults
  i = i + 1
  If Instr(1, rez, VIEW_HEADER, 5) > 0 
Then
   pintPositionOut% = i
   locateViewHeader = True
   Goto functionExit
  End If
 End Forall
 
functionExit:
 Exit Function
 
errorHandler:
 Msgbox "Error " & Err & ": " & Error$ 
& " encountered at line " & Erl & " 
of " & Getthreadinfo(1) & ".", , 
"Error encountered . . ."
 Print "Error " & Err & ": " & Error$ & 
" encountered at line " & Erl & " of " 
& Getthreadinfo(1) & " . . ."
 Resume functionExit
End Function

Sub recordData(pnsess As NotesSession, 
pndbTarget As NotesDatabase, 
pintHdrLocation As Integer, 
pvarResults As Variant)
 On Error Goto errorHandler
 
 Const EOL_PLATFORM = 3
 Dim streamOut As NotesStream
 Dim i As Integer
 Dim j As Integer
 Dim strFilePath As String
 Dim strThisValue As String
 Dim strThisChar As String
 Dim strViewSize As String
 Dim strViewName As String * 64
 Dim strBuff As String * 32
 
 Set streamOut = pnsess.
CreateStream()
 strFilePath$ = Environ$("Temp") 
& "view_detail.txt"
 If Not(streamOut.Open(strFilePath$, 
"UTF-8")) Then
  Msgbox "Unable to open file (" & 
strFilePath$ & ") for recording 
results.", , "Unable to open file . . ."
  Goto subExit
 End If
 
 Call streamOut.WriteText
("Date recorded:   " & Format(Now ,"mm/dd/yyyy 
hh:nn:ss"), EOL_PLATFORM)
 Call streamOut.WriteText("Database title: 
 " & pndbTarget.Title, EOL_PLATFORM)
 Call streamOut.WriteText("Database server:
 " & pndbTarget.Server, 
EOL_PLATFORM)
 Call streamOut.WriteText("Database path: 
  " & pndbTarget.FilePath, 
EOL_PLATFORM)
 Call streamOut.WriteText("", EOL_PLATFORM)
 
'// Add the header for each "column" in the file.
 strViewName$ = "View name:"
 Call streamOut.WriteText(strViewName$)
 
 Rset strBuff$ = "Size in bytes:"
 Call streamOut.WriteText(strBuff$,
 EOL_PLATFORM)
 
'// Start at the next value following the 
offset (ie, the location of the 
header).
 For i = (pintHdrLocation% + 1) To 
Ubound(pvarResults)
  strThisValue$ = pvarResults(i)
  If Len(Trim$(strThisValue$)) > 0 Then
   strViewSize$ = ""
   For j = Len(strThisValue$) To 1 Step -1
    strThisChar$ = Right(Left
(strThisValue$, j), 1)
    If Isnumeric(strThisChar$) Then
     strViewSize$ = strThisChar$ & 
strViewSize$
    Elseif strThisChar$ = "," Then
     strViewSize$ = strThisChar$ & 
strViewSize$
    Else
     Exit For
    End If
   Next j
   
   strViewName$ = Rtrim(Strleft
(strThisValue$, strViewSize$))
   Rset strBuff$ = strViewSize$
   Call streamOut.WriteText(strViewName$ 
& strBuff$, EOL_PLATFORM)
  End If
 Next i
 
 Call streamOut.WriteText("----", 
EOL_PLATFORM)
 Print "Results saved to " 
& strFilePath$ & " . . ."
 
subExit:
 If Not(streamOut Is Nothing) Then
  Call streamOut.Close()
  Set streamOut = Nothing
 End If
 Exit Sub
 
errorHandler:
 Msgbox "Error " & Err & ": " 
& Error$ & " encountered at line " & Erl & " 
of " & Getthreadinfo(1) & ".", ,
 "Error encountered . . ."
 Print "Error " & Err & ": " & Error$ 
& " encountered at line " & Erl & " of " 
& Getthreadinfo(1) & " . . ."
 Resume subExit 
End Sub

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip exchange by member Dallas Gimpel. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

Rate this Tip
To rate tips, you must be a member of SearchDomino.com.
Register now to start rating these tips. Log in if you are already a member.




Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us   



RELATED CONTENT
Database
LotusScript code rebuilds corrupted busytime.nsf file
How to move Notes databases off Domino 8 servers and save disk space
Top 10 Lotus Notes/Domino administration tips of 2008
Batch file runs scheduled Lotus Notes database maintenance tasks
Fix and update Lotus Notes documents with limited access
Programmatically replace the design of Lotus Notes databases
Add a program doc to compact Lotus Notes databases automatically
More efficient local Lotus Notes database replication
Remove orphaned Lotus Notes documents on Domino databases with a 'virtual delete'
Detect and fix 'Manager' access control list settings in Lotus Notes Domino

LotusScript
LotusScript finds the first occurrence of a string from the right
Clear Recent Contacts view and prevent repopulation in Lotus Notes 8.x
Search Microsoft Active Directory with LotusScript
Three steps to trap and handle save conflicts with LotusScript
Troubleshoot agents by displaying LotusScript variables online
LotusScript sorts lists alphabetically
Run or restart Notes/Domino agents via text messages
LotusScript code rebuilds corrupted busytime.nsf file
Soft-code item names to facilitate LotusScript management
LotusScript agent automates selective mail file replication

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary

DISCLAIMER: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.



Domino & Lotus Notes Security Solutions: Authentication, Antispam, Encryption and Antivirus
HomeTopicsITKnowledge ExchangeTipsAsk the ExpertsMultimediaWhite PapersDomino IT Downloads
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Site Map




All Rights Reserved, Copyright 1999 - 2009, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts