Manage Learn to apply best practices and optimize your operations.

Script To Collect Info On Databases And Mail Results

This script collects information on all the databases in the notes\data
directory on a server or on a local workstation and saves a report, while
notifying users specified in the "Recipient" field of the databases in
questions. It can be run from a button on a form, that contains the fields
"Server", "DbSize", and "Recipient". The statistics reported can be expanded
or limited.
Sub Click(Source As Button)
Dim session As New NotesSession
Dim ws As New NotesUIWorkspace
Dim dbArray() As NotesDatabase
Dim myLog As NotesLog
Dim theRecipients As Variant
Dim db As NotesDatabase, this_db As NotesDatabase
Dim new_doc As NotesDocument

Set uidoc = ws.CurrentDocument

theServer$ = uidoc.FieldGetText("Server")
If(Trim$(theServer$) = "") Then
Messagebox "No server has been specified. You must select a server
from the list.", 16, _
"Server Database Analysis"
Exit Sub
If(theServer$ = "Local") Then
theServer$ = ""
End If
End If

theSize$ = uidoc.FieldGetText("DbSize")
If(Trim$(theSize$) = "") Then
Messagebox "No minimum size has been specified. All databases will
be queried.", 48, _
"Server Database Analysis"
iSize% = Cint(theSize$)
End If

Set rec_item = uidoc.Document.GetFirstItem("Recipient")
theRecipients = rec_item.Values
If(Ubound(theRecipients) < 0 ) Then
Messagebox "No recipient has been specified. Please select at least
one recipient from the list.", 16, _
"Server Database Analysis"
Exit Sub
If( theRecipients(0) = "" ) Then
Messagebox "No recipient has been specified. Please select at
least one recipient from the list.", 16, _
"Server Database Analysis"
Exit Sub
End If
End If

Set dbdir = session.GetDbDirectory(theServer$)
Set db = dbdir.GetFirstDatabase(DATABASE)
Dim i%

Set this_db = session.CurrentDatabase
Set new_doc = this_db.CreateDocument
new_doc.Form = "DbReport"
Dim rtitem As New NotesRichTextItem(new_doc, "Body")
rtitem.IsSummary = True

While Not (db Is Nothing)
Call db.Open("", "")
If(db.Size >= iSize%) Then
i% = i% +1
Redim Preserve dbArray(i%)
Set dbArray(i%) = db

'Log various information about each database
Call rtitem.AppendText("-----BEGIN----------" & db.Title &
"--------------------" & Chr(10))
Call rtitem.AppendText("File path: " & db.FilePath & Chr(10))
Call rtitem.AppendText("Size: " & Format$(db.Size,"###,###,##0")
& Chr(10))
Call rtitem.AppendText("Percent Used: " & db.PercentUsed & "%" &
Call rtitem.AppendText("Created: " &
Format$(db.Created,"mm/dd/yy h:mm") & Chr(10))
Call rtitem.AppendText("Last Modified: " &
Format$(db.LastModified,"mm/dd/yy h:mm") & Chr(10))
Call rtitem.AppendText("Full Text Indexed? " & db.IsFTIndexed &
Forall m In db.Managers
Call rtitem.AppendText("Database Managers: " & m & Chr(10))
End Forall
Call rtitem.AppendText("-----END------------" & db.Title &
"--------------------" & Chr(10))
Call rtitem.AppendText(Chr(10) & Chr(10))
Call db.Close
End If
Set db = dbdir.GetNextDatabase
Call new_doc.Save(False, True)
Set mail_doc = this_db.CreateDocument
mail_doc.Form = "Memo"
mail_doc.Subject = "Server Database Analysis Report"
Dim mail_rtitem As New NotesRichTextItem(mail_doc, "Body")
Call mail_rtitem.AppendDocLink(new_doc, "Double click this link to open
the ""Database Analysis""report.")
Call mail_doc.Send(True, theRecipients)
Print "Found " & Cstr(i%) & " databases in the default data directory."
End Sub

Dig Deeper on Domino Resources - Part 7

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...