ServOnline
Introduction
ServOnline is a little tool designed to check the avaibility of a SERVICE (not a server) on a regular basis.
This was mainly done in order for me to toy a bit with the Lazarus IDE (check it at www.lazarus.freepascal.org), and the lNet component, so don't expect too much of the product, anyway, source code is provided.
How it works....
As it was told in the introduction part, we are trying to check the avaibility of SERVICES (the software was primiraly intended to use with webservices, but it can adress any kind of services as long as thoses services accept an incoming TCP connection).
So we won't deal with ICMP (great and fast way to check the fact that a server is online, but it would only tell us if the computer is online, no way with ICMP to tell if the services that are running on the computer are alive).
Instead, we'll use the LTCPComponent of the lNet package. With this component, we can quickly set up a TCP connection to a remote host, so in order to achieve our tool we'll simply use a text file in order to define the server hosting the service, and the associated port. The software will read the list, and using a timer we'll regulary poll the service, using the following way:
OnlineServ send a TCP connection request
The remote service, if online, accept the connection request, otherwise send a RESET packet
OnlineServ send a TCP deconnection request if connected to close the connection.
And we set the status of the service following the answer we got, either the connection was accepted and we can consider that the service is online, either the connection is reset by the remote host wich indicate the the remote service is not online. An error status is shown is there's some other problemes (such as an incorrect domain name)
Lazarus, an IDE for FreePascal
Lazarus is the class libraries for Free Pascal that emulate Delphi. Free Pascal is a GPL'ed compiler that runs on Linux, Win32, OS/2, 68K and more. Free Pascal is designed to be able to understand and compile Delphi syntax, which is of course OOP. Lazarus is the part of the missing puzzle that will allow you to develop Delphi like programs in all of the above platforms
(extracted from the Lazarus homepage, check the full text here : http://www.lazarus.freepascal.org
The text file that define services...
Services to check are listed in a text file, in the following way:
<service name>;<port>
<service name>;<port>
<service name>;<port>
The separator must be the semi-colon caracter (';'), and the software does not check for a valid line. So be carefull when enterring some data. A legal file should look as:
intranet.company.com;8080
source.company.com;80
library.company.com;443
Download here...
The following package contain the complete source code:
And here the compiled version. Du to size upload restriction, I had to break it in multiparts (total size is around 450k). This is a self extractable archive:
LOCKY