Received: from maia.hub.org (maia-4.hub.org [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id D8D18632DFA for ; Fri, 30 Apr 2010 11:33:53 -0300 (ADT) Received: from mail.postgresql.org ([200.46.204.86]) by maia.hub.org (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 41637-05 for ; Fri, 30 Apr 2010 14:33:45 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from mail-ew0-f220.google.com (mail-ew0-f220.google.com [209.85.219.220]) by mail.postgresql.org (Postfix) with ESMTP id 99CDD632215 for ; Fri, 30 Apr 2010 11:33:45 -0300 (ADT) Received: by ewy20 with SMTP id 20so90841ewy.21 for ; Fri, 30 Apr 2010 07:33:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:content-type; bh=1URfVyyc9fjnezGFs66RuZnknmtlUEPV1g/lKjAD4ls=; b=cxaSO6T31CnRgCB4T27uZleyvYf6pJuGgS8AgcbP3/vEos1fv3VBYm9Xo6z+UE5f50 LUTaISH3+r4KJywa2cSKakl8v6vgNEVmmm8U1eBq1wWSsU+JTXAjkhYk1WQKCvxN1iJa UwSJy32IwX7bZ1W6Qwewd/XMkrxXTuHHjFouQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:content-type; b=HDfYKv+oi+Jt5WZKOKyEi6CSkRJzEEU2fHugErRDUC1OyUNO4pAwAW5xDQYN/ciuOF XqA28a+sd8TwXwCT+/SSOrlGvubDboOxYm4aegC66RMHSeQAsRw6uNdFnZxSa/6v03Sg fBwE4pxpgQRS0iduC7U9o9L6sG+B9/YeygsLs= MIME-Version: 1.0 Received: by 10.213.44.20 with SMTP id y20mr4132885ebe.17.1272638018280; Fri, 30 Apr 2010 07:33:38 -0700 (PDT) Received: by 10.213.17.6 with HTTP; Fri, 30 Apr 2010 07:33:38 -0700 (PDT) In-Reply-To: <20100430141404.GB28614@rice.edu> References: <20100430141404.GB28614@rice.edu> Date: Fri, 30 Apr 2010 16:33:38 +0200 X-Google-Sender-Auth: a6d9efc87d8c894d Message-ID: Subject: Re: Querying the hostname of the server From: =?UTF-8?B?UMOpdGVyIEtvdsOhY3M=?= To: pgsql-admin@postgresql.org Content-Type: multipart/alternative; boundary=00148531a52b02479204857521c8 X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=-1.888 tagged_above=-10 required=5 tests=BAYES_00=-1.9, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, T_TO_NO_BRKTS_FREEMAIL=0.01 X-Spam-Level: X-Archive-Number: 201004/365 X-Sequence-Number: 34459 --00148531a52b02479204857521c8 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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 wrote= : > On Fri, Apr 30, 2010 at 03:33:13PM +0200, P=C3=A9ter Kov=C3=A1cs 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@rice.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 =3D F023 82C8 9B0E 2CC6 0D8E F888 D3AE 810E 88F0 BED= E > > -- > Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org) > To make changes to your subscription: > http://www.postgresql.org/mailpref/pgsql-admin > --00148531a52b02479204857521c8 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Th= ank you, Ross!

inet_server_addr() returns the correct IP address in this case. I am no= t sure why... The tunnel goes through at least one port-forwarding node, bu= t 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@rice.edu> wrote:
On Fri, Apr 30, 2010 at 03:33:13PM +0200, P= =C3=A9ter Kov=C3=A1cs 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 la= nded
> 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. =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 reedstrm@rice.edu
Systems Engineer & Admin, Research Scientist =C2=A0 =C2=A0 =C2=A0 =C2= =A0phone: 713-348-6166
The Connexions Project =C2=A0 =C2=A0 =C2=A0http://cnx.org =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0fa= x: 713-348-3665
Rice University MS-375, Houston, TX 77005
GPG Key fingerprint =3D F023 82C8 9B0E 2CC6 0D8E =C2=A0F888 D3AE 810E 88F0 = BEDE

--
Sent via pgsql-admin mailing list (pgsql-admin@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-admin

--00148531a52b02479204857521c8--