Tip

Retrieve Server Statistics Individually

This LotusScript function takes a Domino server name and statistic name (e.g.,
Server.Version.OS) and returns the stat's value (access permitting). It is
similar to the "show stat <stat name>" console command, except that it does not
echo the stat name (only it's value).

For example, the following button code returns the string "Windows NT 4.0" on a
Domino server with NT 4.0 running on it:

Sub Click(Source As Button)
Dim ret$, stat$

stat$="Server.Version.OS"
ret$=GetServerStat("MyServer", stat$)
Msgbox stat$ & " = " & ret$, 0, "Server Stats Demo"
End Sub

As it calls a Win32 API function, it will only run on the Win32 platform.
'(Declarations)
Declare Function NSFGetServerStats% Lib "nnotes" (Byval ServerName$, Byval
Facility$, Byval StatName$, rethTable%, retTableSize&)
Declare Function OSMemFree% Lib "nnotes" (Byval Handle%)
Declare Function OSLockObject& Lib "nnotes" (Byval nHandle%)
Declare Function OSUnlockObject% Lib "nnotes" (Byval nHandle%)

' Win32 API
Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Byval pDest$,
Byval pSource&, Byval dwLength&)

Function GetServerStat(sServer$, sArg$) As String
Dim nOffset%, hTable% , nPos%
Dim cbSize&, hLock&
Dim sHold$, sReturn$, sFacility$, sStat$
Dim vLoop

' parse out facility and stat
sFacility$=Left(sArg$, Instr(1, sArg$, ".") - 1)
sStat$=Right(sArg$, Len(sArg$) - Len(sFacility) - 1)

' retrieve the stat
NSFGetServerStats sServer$, sFacility$, sStat$, hTable%, cbSize&

If cbSize& > 0 Then
' lock down the handle to the stat
hLock&=OSLockObject(hTable%)

' locate offset where the stat begins
hOffset%=Len(sFacility$ & "." & sStat$) + 1

' advance to offset and init some vars
hLock&=hLock& + hOffset%
sHold$=String(1, 0)
sReturn$=""
vLoop=True

Do While vLoop
' copy the stat one char at a time
CopyMemory sHold$, hLock&, 1

' loop 'til we find the end of the stat value
If sHold$=Chr$(10) Then
vLoop=False
Else
sReturn$ = sReturn$ & sHold$
hLock& = hLock& + 1
End If
Loop

' unlock and free the handle
OSUnlockObject hTable%
OSMemFree hTable%

' return the stat
GetServerStat=sReturn$
Else
GetServerStat="Not found"
End If
End Function

This was first published in November 2000

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

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.