OpenNTF.org - Retrieve Server Statistics Ind
My Links (Not logged in)
Code Bin Search
 
Hosted by Prominic.NET
Rate This Code
5 - brilliant stuff
4 - very nice
3 - average
2 - needs work
1 - bad
   OpenNTF Code Bin
About This Code
Brief Description:
Retrieve Server Statistics Individually 
Rating:
Rating: 5 , Number of votes: 1 
Contributor:
Andrew Jones 
Category:
Lotusscript 
Type:
 
Last Modified:
17 Jun 2002 
OpenNTF Disclaimer

All of the program code and information presented in the OpenNTF.org Code Bin are provided "as-is", and should be used at your own risk. OpenNTF.org make no express or implied warranty about anything in the Code Bin, and OpenNTF.org will not be responsible or liable for any damage caused by the use or misuse of anything from this site. OpenNTF.org makes no guarantees about anything. Please thoroughly test all of the knowledge and code you find here before you attempt to use them in your production environment.

Code / Description
Usage / Example
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.

Code


'(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
 Comments

No documents found

 Add your comment!