Manage Learn to apply best practices and optimize your operations.

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 &LTstat 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

Dig Deeper on Domino Resources - Part 5

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com'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 ...

SearchDataCenter

SearchContentManagement

Close