Option Public
Option Explicit
Declare Function StatQuery Lib "nnotes" (Byval headerString As String, _
Byval namePrefix As String, Byval valuePrefix As String, Byval lineSuffix As String, _
rethStats As Long, retStatsLength As Long) As Integer
Declare Function StatQueryTime Lib "nnotes" (Byval facility As String, _
Byval statName As Any, Byval headerString As String, Byval namePrefix As String, _
Byval valuePrefix As String, Byval lineSuffix As String, rethStats As Long, _
retStatsLength As Long) As Integer
Const STATPKG_OS = "OS"
Const STATPKG_STATS = "Stats"
Const STATPKG_OSMEM = "Mem"
Const STATPKG_OSSEM = "Sem"
Const STATPKG_OSSPIN = "Spin"
Const STATPKG_OSFILE = "Disk"
Const STATPKG_SERVER = "Server"
Const STATPKG_REPLICA = "Replica"
Const STATPKG_MAIL = "Mail"
Const STATPKG_MAILBYDEST = "MailByDest"
Const STATPKG_COMM = "Comm"
Const STATPKG_NSF = "Database"
Const STATPKG_NIF = "Database"
Const STATPKG_TESTNSF = "Testnsf"
Const STATPKG_OSIO = "IO"
Const STATPKG_NET = "NET"
Const STATPKG_OBJSTORE = "Object"
Const STATPKG_AGENT = "Agent"
Const STATPKG_WEB = "Web"
Const STATPKG_CAL = "Calendar"
Const STATPKG_SMTP = "SMTP"
Const STATPKG_LDAP = "LDAP"
Const STATPKG_NNTP = "NNTP"
Const STATPKG_ICM = "ICM"
Const STATPKG_MONITOR = "Monitor"
Const STATPKG_POP3 = "POP3"
Declare Function OSLockObject Lib "nnotes.dll" (Byval objectHandle As Long) As Long
Declare Function OSUnlockObject Lib "nnotes.dll" (Byval objectHandle As Long) As Integer
Declare Function OSMemFree Lib "nnotes" (Byval handle As Long) As Integer
Declare Sub CopyBufferToString Lib "nnotes.dll" Alias "Cmovmem" _
(Byval lpSrc As Long, Byval lpDest As String, Byval lSize As Long)
Declare Sub CopyBuffer Lib "nnotes.dll" Alias "Cmovmem" _
(Byval lpSrc As Long, lpDest As Any, Byval lSize As Long)
Sub Initialize
Dim newLine As String
Dim fileNum As Integer
Dim fileName As String
Dim nError As Integer
Dim statBuffer As Long
Dim statBufferLen As Long
Dim statArray(0 To 25) As String
statArray(0) = STATPKG_OS
statArray(1) = STATPKG_STATS
statArray(2) = STATPKG_OSMEM
statArray(3) = STATPKG_OSSEM
statArray(4) = STATPKG_OSSPIN
statArray(5) = STATPKG_OSFILE
statArray(6) = STATPKG_SERVER
statArray(7) = STATPKG_REPLICA
statArray(8) = STATPKG_MAIL
statArray(9) = STATPKG_MAILBYDEST
statArray(10) = STATPKG_COMM
statArray(11) = STATPKG_NSF
statArray(12) = STATPKG_NIF
statArray(13) = STATPKG_TESTNSF
statArray(14) = STATPKG_OSIO
statArray(15) = STATPKG_NET
statArray(16) = STATPKG_OBJSTORE
statArray(17) = STATPKG_AGENT
statArray(18) = STATPKG_WEB
statArray(19) = STATPKG_CAL
statArray(20) = STATPKG_SMTP
statArray(21) = STATPKG_LDAP
statArray(22) = STATPKG_NNTP
statArray(23) = STATPKG_ICM
statArray(24) = STATPKG_MONITOR
statArray(25) = STATPKG_POP3
newLine = Chr(13) & Chr(10)
fileNum = Freefile()
fileName = "C:\TestStats.txt"
Open fileName For Output As fileNum
nError = StatQueryTime (STATPKG_STATS, "Time.Start", "Start Time:" & newline, _
" ", Chr(9), newLine, statBuffer, statBufferLen)
Print #fileNum, "GETTING SINGLE STAT USING StatQueryTime"
If (nError = 0) Then
Print #fileNum, GetBufferAsString(statBuffer, Cint(statBufferLen), 0, True)
Else
Print #fileNum, "API Error " & nError & " calling StatQueryTime"
End If
Print #fileNum, "GETTING ALL STATS USING StatQueryTime"
Forall stat In statArray
nError = StatQueryTime (stat, 0&, "Statistics for " & stat & ":" & newLine, _
" ", Chr(9), newLine, statBuffer, statBufferLen)
If (nError = 0) Then
Print #fileNum, GetBufferAsString(statBuffer, Cint(statBufferLen), 0, True)
Else
Print #fileNum, "API Error " & nError & " calling StatQueryTime"
End If
End Forall
nError = StatQuery ("From Stat Query:" & newLine, " ", Chr(9), newLine, _
statBuffer, statBufferLen)
Print #fileNum, "GETTING ALL STATS USING StatQuery (" & statBufferLen & " bytes)"
If (nError = 0) Then
Dim chunkSize As Integer
Dim offset As Long
Dim freeMem As Integer
While statBufferLen > 0
If (statBufferLen > 32767) Then
chunkSize = 32767
freeMem = False
Else
chunkSize = statBufferLen
freeMem = True
End If
Print #fileNum, GetBufferAsString(statBuffer, chunkSize, offset, freeMem);
offset = offset + chunkSize
statBufferLen = statBufferLen - chunkSize
Wend
Else
Print #fileNum, "API Error " & nError & " calling StatQuery"
End If
Close fileNum
Print "Finished writing to " & fileName
End Sub
Function GetBufferAsString (buffer As Long, bufferLen As Integer, _
offset As Long, freeMem As Integer) As String
Dim pointer As Long
Dim bufferText As String
bufferText = Space(bufferLen)
pointer = OSLockObject(buffer)
Call CopyBufferToString(pointer + offset, bufferText, Clng(bufferLen))
Call OSUnlockObject(buffer)
If freeMem Then
Call OSMemFree(buffer)
End If
GetBufferAsString = bufferText
End Function
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.