Check if an indy Http server is active by indy client issue!

This is the forum for miscellaneous technical/programming questions.

Moderator: 2ffat

Check if an indy Http server is active by indy client issue!

Postby Ahmed Sayed » Tue Mar 12, 2019 7:53 am

Hi I am creating an app to monitor some of my http servers so in case they are down I get notified by email.

I used this code to check for the connection if it is active or not:

Code: Select all
bool SocketIsOpen( UnicodeString Host, int Port, String &Msg, int ATimeout)
{
unique_ptr<TIdTCPClient> Socket(new TIdTCPClient(nullptr));
Msg = "";
bool res = false;
try
   {
   Socket->ConnectTimeout = ATimeout;
   try
      {
      Socket->Connect( Host, Port);
      res = Socket->Connected();
      }
   catch (const Exception &E)
      {
      Msg = E.Message;
      res = false;
      }
   }
__finally
   {
   Socket->Disconnect();
   }
return res;
}
//---------------------------------------------------------------------------


I used this function periodically every 500 MS and the timeout is 1 MS but sometimes I get Connection timeout. The monitoring app and the servers are on the same machine so i don't think there should be any timeouts. The server itself is active all the time.

Actually what I am trying to do is monitor the following for each server:
Memory - CPU usage - No. Connections - Threads - detect if server is responding or not - TIdHttpServer is active or not

The reason why I use 1 Ms as timeout is that I don't want all the previous checks take a lot of time. There is an interval of 500 Ms between a check is made on all server process and the next check.

For example, if I have 4 servers running above data is collected for each server then wait for 500 Ms and then collect data for all servers again.

So is their a way to do so with speed with no timeouts.
Thanks in advance
Ahmed Sayed
Active Poster
Active Poster
 
Posts: 21
Joined: Thu Nov 08, 2018 4:12 pm

Re: Check if an indy Http server is active by indy client is

Postby mark_c » Wed Mar 13, 2019 12:01 am

always if I understand your problem: and setting a timeout of 100 ms instead of 1 ms what happens?
mark_c
BCBJ Guru
BCBJ Guru
 
Posts: 152
Joined: Thu Jun 21, 2012 1:13 am

Re: Check if an indy Http server is active by indy client is

Postby Ahmed Sayed » Fri Mar 15, 2019 7:39 am

If i changed the timeout to 100 MS sure the process will get slower and it still timeout from time to time like giving me 7 timeouts in 1 minute during monitoring 4 servers.
Ahmed Sayed
Active Poster
Active Poster
 
Posts: 21
Joined: Thu Nov 08, 2018 4:12 pm


Return to Technical

Who is online

Users browsing this forum: No registered users and 18 guests

cron