Code to get all DB stats

Written – July 9 2010
Hello All
Here is a small piece of code to get some quick stats on all your Notes Databases.  It’s nothing fancy and there are probably a 100 different ways to do this, but this does the job well.
You can use it to get
  • an inventory of your DB
  • DB sizes
  • get the last modification date so you can retire unused DBs

All results are exported in a CSV file so they can easily be sorted or do some quick stats.

Remember if you don’t have access to all databases and need the stats, get someone with higher stats to run it or switch to full admin.
 Sub Initialize

On Error Goto ErrorHandler

Dim db As NotesDatabase
Dim filenum As Integer
Dim filename As String
Dim logs As String
Dim servername As String

servername=”myserver”          ‘  <=====  ***server name***
Dim dbdir As New NotesDbDirectory(servername)
filenum% = Freefile()
filename=”c:\NotesDatabaseStats.csv”       ‘ <====== *** file destination ***

Open filename For Output As filenum%

Set db = dbdir.GetFirstDatabase(Database)
While Not (db Is Nothing)
Call db.Open( “”, “” )
If db.IsOpen = False Then
Print( “Unable to open database” )
Set db = dbdir.GetNextDatabase
Else
Print #filenum%, servername & “,” db.Title & “,” & db.FilePath & “,” & db.Size/1048576″,” & Leftbp(db.LastModified,Instr(db.LastModified,” “))
Set db = dbdir.GetNextDatabase
End If
Wend
Close filenum%

If 1 = 2 Then
ErrorHandler:
logs = logs & ” Error” & Str(Err) & “: ” & Error$ & Chr(10)
Resume Next
End If

‘If logs<>””  Then Messagebox logs, MB_OK, “Errors”

End Sub

Enjoy JT
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s