Get Logical / physical size and DAOS size with LotusScript

The admin client shows information about logical / physical size as well as DAOS size for a database.

Sizes1

But how to get this information via LotusScript? For the logical size you can use db.size. For the physical size there is no property in the NotesDatabase Class. But C-API to the rescue.

Put the following piece of code into the declaration section of a button or script library

Declare Function NSFDbOpen Lib "nnotes.dll" Alias "NSFDbOpen" (Byval dbName As String, hDb As Long) As Integer
Declare Function NSFDbClose Lib "nnotes.dll" Alias "NSFDbClose" (hDb As Long) As Integer
Declare Function NSFDbSpaceUsage Lib "nnotes.dll" Alias "NSFDbSpaceUsage" (Byval hDB As Long, retAllocatedBytes As Long, retFreeBytes As Long) As Integer

Now you can call the functions to retrieve the data

Sub Click(Source As Button)
Dim dbHandle As Long
Dim usedBytes As Long
Dim freeBytes As Long
Dim ServerName As String
Dim dbName As String
ServerName = "YourServerHere"
dbName = "YourDatabaseHere.nsf"
Dim db As New NotesDatabase ( ServerName, dbName )
Call NSFDbOpen ( ServerName +"!!" + dbName, dbHandle)
If dbHandle <> 0 Then
Call NSFDbSpaceUsage(dbHandle, usedBytes, freeBytes)
Msgbox  "Logical Size: " & Cstr(db.Size) & " Bytes || Physical Size: " & Cstr(usedBytes + freeBytes) & " Bytes" & " || DAOS: " + Cstr(db.Size -(usedBytes + freeBytes))
End If
NSFDbClose dbHandle
End Sub

This code snippet produces the following output.

Sizes

The DAOS size simply calculates as the difference between logical and physical size.

2 thoughts on “Get Logical / physical size and DAOS size with LotusScript

  1. Hallo Ulrich,

    deine Funktion wollte ich verwenden um die Ausnutzung einer Datenbank in % zu erhalten. Die Funktion notesDatabase.PercentUsed liefert ja leider nur bei kleinen Datenbanken richtige Werte. Wo die Grenze liegt habe ich allerdings noch nicht herausbekommen. Jetzt musste ich aber feststellen das die API-Funktion bei grossen Datenbanken ebenfalls falsche Werte liefert.
    Die getestete Datenbank war 27 GB groß und laut Datenbankeeigenschaften zu 96,9% verwendet. Die API-Funktion liefert mir hier aber auch nur die falsche Zahl von 60,4%.
    Hast du das vielleicht schon einmal von anderer Seite gehört?
    Hast du eine Idee woran das liegen kann?
    Muß dass Ergebnis ab einer bestimmten Größe vielleicht anders verrechnet werden? Z.B. eine Konvertierung des Rückgabewertes, wenn er größer als 65536 ist?

    Ich komme nicht weiter und bin für Hinweise dankbar.

    Bernd

  2. Kann ich dir jetzt wirklich nicht beantworten. Lt. API Referenz gibt es da keine anderen Rückgabewerte. Ich weiss auch nicht, wie die Anzeige in den Eigenschaften berechnet wird.
    Aber das bekommen wir schon noch raus.

Comments are closed.