Re: Querying the hostname of the server

From: Péter Kovács <maxottovonstirlitz(at)gmail(dot)com>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: Querying the hostname of the server
Date: 2010-04-30 14:33:38
Message-ID: i2zfdeb32eb1004300733rcbe5a4e3kffde4eb2e92bb966@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Thank you, Ross!

inet_server_addr() returns the correct IP address in this case. I am not
sure why... The tunnel goes through at least one port-forwarding node, but I
am not sure this makes postgresql see the connection any less local.

Thanks
Peter

On Fri, Apr 30, 2010 at 4:14 PM, Ross J. Reedstrom <reedstrm(at)rice(dot)edu>wrote:

> On Fri, Apr 30, 2010 at 03:33:13PM +0200, Péter Kovács wrote:
> > Hi,
> >
> > I have a number of PostgreSQL servers which I often access through ssh
> > tunnel with Pgadmin3. I would like to double check which one I have
> landed
> > on (if the tunnel is really configured the way I want). Is there a way to
> > query the hostname from the catalogs?
>
> Hmm, that's a bit tricky, since I assume you're using a local db
> connection inside the tunnel, so inet_server_addr() probably returns
> null. If you're talking unix/linux machines, then /etc/hostname _should_
> have the current hostname in it, so:
>
> create temp table foo (t text);
> copy foo from '/etc/hostname';
> select * from foo;
> drop table foo;
>
> Should work.
>
> Ross
> --
> Ross Reedstrom, Ph.D. reedstrm(at)rice(dot)edu
> Systems Engineer & Admin, Research Scientist phone: 713-348-6166
> The Connexions Project http://cnx.org fax: 713-348-3665
> Rice University MS-375, Houston, TX 77005
> GPG Key fingerprint = F023 82C8 9B0E 2CC6 0D8E F888 D3AE 810E 88F0 BEDE
>
> --
> Sent via pgsql-admin mailing list (pgsql-admin(at)postgresql(dot)org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-admin
>

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Glyn Astill 2010-04-30 14:43:49 Re: Querying the hostname of the server
Previous Message Kevin Grittner 2010-04-30 14:20:55 Re: Querying the hostname of the server