I checked the forum on this, and the way this person did it was to open a database on the server. I would think that this would be an expensive operation. While I have to check that the below code would work (it will take a while since many groups are using the developement server). I was hoping if any body knows a better way or even if this would work.
Note: dbServer is a glogal variable set to the current database the user is working with.
Public function isServerUp() As Boolean
Dim dirEntry As NotesDbDirectory
Dim dbTemp As NotesDatabase
Set dirEntry = sess.GetDbDirectory( dbCurrent.server)
Set dbTemp = dirEntry.getFirstDatabase( DATABASE)
If dbTemp Is Nothing Then
isServerUp = False
Else
isServerUp = true
End If
End function
Cheers,
John
Subject: How to tell if server is running
You should check for a DB property and if you get an exception - the server is down. also do it on names.nsf so the exception would not be on ACL.
If dbTemp Is Nothing Then
isServerUp = False
Else
print db.size ’ Error if server is unavavile
isServerUp = true
End If
Regards
Tamir Ben Shoshan
http://www.systbs.com
SharePoint & Lotus plugins & Notes CAPI
Subject: On Error
Add an error trap and check for error 4072, I believe this is the error for “server not responding”.
Subject: Found a way
Not sure why the Size Property did not work, it seems that we are on a cluster so the size returned the size of the replica on the cluster.
The other idea of using the ddl was even slower than opening up a dB, maybe because it has to write the information to the Log dB.
The last thing that I tried was to create an adminstration request and that worked. Here is the code that I used.
Function createAdminP
On Error GoTo errorHandler
Dim adminP As NotesAdministrationProcess
' when I put in 'My server" instead of dbCurrent.server I got error 4000
Set adminP = s.CreateAdministrationProcess( dbCurrent.server )
Print "server must be up"
Exit function
errorHandler:
'-- leaving this here to see if we get an error
Print LSI_Info( 2) & " " & Error$ & " Error: " & Err & " at line: " & Erl
Print "got an error - must be down"
Resume exitFunction
exitFunction:
End Function
While I won’t need the print statements, when I ran this 100 times using the agent profilier it took 147 msecs, while using the opening of a dB for 100 times took about 1,400 msecs.
Hopefully this will help somebody else. I do thank the people who responded.
Cheers,
John
Subject: re: connectivity
Anywho, If you try to connect to a server using and application two things may occur. 1. error reported back to you. (in this case you can just capture the error and respond to it) or 2. the application locks up for ever and you have to kill it (very difficult to recover from)
Ok, the way administrators tell if a server is running and accessible from another server is to ping it. Well in domino you don’t use ping you use trace. basically you can call “trace serverx” and if it connects you are golden. you can use the below code and input the correct variables. Once you get the results do a instr comparision for a key word or what ever. I suggest going to the console and testing the trace command a few times to see the various outputs. trace is a realitively inexpensive way to test connectivity, hardly any resources. You could always use the connect to a database approach but you are running the risk of that database being moved or deleted or etc in the future and breaking your code in the process. If you do go with this approach use a small in size database so you are not using tons of resources.
Code stolen from Software applications news, help and research - WhatIs
but change by me.
Code: (Declarations) Declare Function NSFRemoteConsole Lib “nnotes.dll” _ (Byval ServerName As String, _ Byval ConsoleCommand As String, _ rethBuffer As Long) As Integer Sub SendConCMD Dim api_res As Integer Dim hBuf As Long 'Send the console command TELL ADMINP PROCESS ALL to server SALES01 api_res = NSFRemoteConsole(“SALES01”, “TELL ADMINP PROCESS ALL”, hBuf) End Sub