Lightest way of checking if postgresql is running at the other end of an ssh tunnel?

From: Niels Kristian Schjødt <nielskristian(at)autouncle(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Lightest way of checking if postgresql is running at the other end of an ssh tunnel?
Date: 2016-05-11 09:17:54
Message-ID: C01E306B-DF31-44C9-A795-8361C6E3F122@autouncle.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

We have an ssh connection running from one server to our postgresql database on another server. Some times we experience that the ssh tunnel does not work anymore and needs to be restarted, even though we use the autossh package. I would like to write a script that “pings” postgresql on the specified port, to check if the connection goes through. I have tried with netcat, but it does not really check if postgresql is in the other end of the tunnel, it only check if there is as service (the tunnel) listing on the port on the local machine. Is there another way of pinging the port, to see if postgresql is alive at the other end? If possible, I would like to NOT actually establishing a connection to postgresql like if i used psql -c “select 1;”, to avoid connection overhead.

Any ideas?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Karsten Hilbert 2016-05-11 09:41:38 Re: Lightest way of checking if postgresql is running at the other end of an ssh tunnel?
Previous Message fredrik 2016-05-11 04:31:14 Streaming replication, master recycling