How to query a postgresql database to determine it's cluster and version (and port)?
That would be

SELECT current_setting('cluster_name'), current_setting('server_version');


You can get all parameters that way. For automated processing, server_version_num is often better.