pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedDiscovering postgres binary directory location
6+ messages / 4 participants
[nested] [flat]
* Discovering postgres binary directory location
@ 2020-11-11 22:22 Raul Kaubi <raulkaubi@gmail.com>
2020-11-11 22:26 ` Re: Discovering postgres binary directory location Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 6+ messages in thread
From: Raul Kaubi @ 2020-11-11 22:22 UTC (permalink / raw)
To: pgsql-general
Hi
CentOS 7
Postgres 9 to 12
I am looking ways to universally discover postgresql binary directory
for monitoring purpose.
For example postgres 12, it is: */usr/pgsql-12*
So what would be the best way to discover this in specific host.
Regards
Raul
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Discovering postgres binary directory location
2020-11-11 22:22 Discovering postgres binary directory location Raul Kaubi <raulkaubi@gmail.com>
@ 2020-11-11 22:26 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-11-12 06:22 ` Re: Discovering postgres binary directory location Paul Förster <paul.foerster@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Adrian Klaver @ 2020-11-11 22:26 UTC (permalink / raw)
To: Raul Kaubi <raulkaubi@gmail.com>; pgsql-general
On 11/11/20 2:22 PM, Raul Kaubi wrote:
> Hi
>
> CentOS 7
> Postgres 9 to 12
>
> I am looking ways to universally discover postgresql binary directory
> for monitoring purpose.
> For example postgres 12, it is: */usr/pgsql-12*
pg_config --bindir
/usr/local/pgsql12/bin
>
> So what would be the best way to discover this in specific host.
>
> Regards
> Raul
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Discovering postgres binary directory location
2020-11-11 22:22 Discovering postgres binary directory location Raul Kaubi <raulkaubi@gmail.com>
2020-11-11 22:26 ` Re: Discovering postgres binary directory location Adrian Klaver <adrian.klaver@aklaver.com>
@ 2020-11-12 06:22 ` Paul Förster <paul.foerster@gmail.com>
2020-11-12 15:19 ` Re: Discovering postgres binary directory location Mark Johnson <remi9898@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Paul Förster @ 2020-11-12 06:22 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; Raul Kaubi <raulkaubi@gmail.com>; +Cc: pgsql-general
Hi Raul, hi Adrian,
> On 11. Nov, 2020, at 23:26, Adrian Klaver <adrian.klaver@aklaver.com> wrote:
>
> On 11/11/20 2:22 PM, Raul Kaubi wrote:
>> Hi
>> CentOS 7
>> Postgres 9 to 12
>> I am looking ways to universally discover postgresql binary directory for monitoring purpose.
>> For example postgres 12, it is: */usr/pgsql-12*
>
> pg_config --bindir
> /usr/local/pgsql12/bin
or by query:
postgres=# select setting from pg_config where name = 'BINDIR';
setting
-------------------------
/data/postgres/12.4/bin
(1 row)
Cheers,
Paul
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Discovering postgres binary directory location
2020-11-11 22:22 Discovering postgres binary directory location Raul Kaubi <raulkaubi@gmail.com>
2020-11-11 22:26 ` Re: Discovering postgres binary directory location Adrian Klaver <adrian.klaver@aklaver.com>
2020-11-12 06:22 ` Re: Discovering postgres binary directory location Paul Förster <paul.foerster@gmail.com>
@ 2020-11-12 15:19 ` Mark Johnson <remi9898@gmail.com>
2020-11-12 15:37 ` Re: Discovering postgres binary directory location Paul Förster <paul.foerster@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Mark Johnson @ 2020-11-12 15:19 UTC (permalink / raw)
To: Paul Förster <paul.foerster@gmail.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; Raul Kaubi <raulkaubi@gmail.com>; pgsql-general
On any given server there could be zero, one, or many PGHOME/bin
locations. The OP wants to identify all of them. The default location
used by package-based installers is different from the default location of
software built from source, and when building from source you can specify a
non-default location. My server has PG 9.6, 12.1, and 13 from RPM and also
12.1 from source.
The solution might be as easy as finding all installations of a core
PostgreSQL executable like pg_ctl. I would not search for psql since you
will find one or more links in system folders and so your monitoring tool
would need some logic to filter out the links. The word postgres is both
an executable and a user directory name. Hence I am using pg_ctl in my
example. This example was written on CentOS 7.7.
# find / -name pg_ctl
/usr/pgsql-13/bin/pg_ctl
/usr/local/pgsql/bin/pg_ctl
/usr/pgsql-12/bin/pg_ctl
/usr/pgsql-9.6/bin/pg_ctl
/root/Downloads/postgresql-12.1/src/bin/pg_ctl
/root/Downloads/postgresql-12.1/src/bin/pg_ctl/pg_ctl
You have mail in /var/spool/mail/root
Notice above my server has three RPM installs and one source code install.
Also notice the results contain two false positives (in the Downloads
directory) and also a message about mail. You'll have to figure out how to
separate the good and bad results.
To strip off the file name and only return the directory, you can used the
-printf option as shown below or if not supported on your system use a host
command like sed or awk. This does not remove false positives or system
messages.
find / -name 'pg_ctl' -printf "%h\n"
/usr/pgsql-13/bin
/usr/local/pgsql/bin
/usr/pgsql-12/bin
/usr/pgsql-9.6/bin
/root/Downloads/postgresql-12.1/src/bin
/root/Downloads/postgresql-12.1/src/bin/pg_ctl
You have mail in /var/spool/mail/root
Careful when stripping out the false positives. PostgreSQL installed from
source can be pretty much anywhere including a Downloads directory, /tmp,
and so on. In my case, the Downloads directory has a src sub-directory,
which tells me it is just a staging area for source code.
-Mark
On Thu, Nov 12, 2020 at 1:22 AM Paul Förster <paul.foerster@gmail.com>
wrote:
> Hi Raul, hi Adrian,
>
> > On 11. Nov, 2020, at 23:26, Adrian Klaver <adrian.klaver@aklaver.com>
> wrote:
> >
> > On 11/11/20 2:22 PM, Raul Kaubi wrote:
> >> Hi
> >> CentOS 7
> >> Postgres 9 to 12
> >> I am looking ways to universally discover postgresql binary directory
> for monitoring purpose.
> >> For example postgres 12, it is: */usr/pgsql-12*
> >
> > pg_config --bindir
> > /usr/local/pgsql12/bin
>
> or by query:
>
> postgres=# select setting from pg_config where name = 'BINDIR';
> setting
> -------------------------
> /data/postgres/12.4/bin
> (1 row)
>
> Cheers,
> Paul
>
>
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Discovering postgres binary directory location
2020-11-11 22:22 Discovering postgres binary directory location Raul Kaubi <raulkaubi@gmail.com>
2020-11-11 22:26 ` Re: Discovering postgres binary directory location Adrian Klaver <adrian.klaver@aklaver.com>
2020-11-12 06:22 ` Re: Discovering postgres binary directory location Paul Förster <paul.foerster@gmail.com>
2020-11-12 15:19 ` Re: Discovering postgres binary directory location Mark Johnson <remi9898@gmail.com>
@ 2020-11-12 15:37 ` Paul Förster <paul.foerster@gmail.com>
2020-11-12 15:54 ` Re: Discovering postgres binary directory location Paul Förster <paul.foerster@gmail.com>
0 siblings, 1 reply; 6+ messages in thread
From: Paul Förster @ 2020-11-12 15:37 UTC (permalink / raw)
To: Mark Johnson <remi9898@gmail.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; Raul Kaubi <raulkaubi@gmail.com>; pgsql-general
Hi Mark,
> On 12. Nov, 2020, at 16:19, Mark Johnson <remi9898@gmail.com> wrote:
>
> # find / -name pg_ctl
> /usr/pgsql-13/bin/pg_ctl
> /usr/local/pgsql/bin/pg_ctl
> /usr/pgsql-12/bin/pg_ctl
> /usr/pgsql-9.6/bin/pg_ctl
> /root/Downloads/postgresql-12.1/src/bin/pg_ctl
> /root/Downloads/postgresql-12.1/src/bin/pg_ctl/pg_ctl
> You have mail in /var/spool/mail/root
how about searching for pg_ctl only inside a bin directory:
$ find / -type f -name "pg_ctl" -exec grep "/bin/" {} \; 2>/dev/null
Binary file /data/postgres/12.4/bin/pg_ctl matches
Binary file /data/postgres/13.0/bin/pg_ctl matches
That should also solve your source tree and root mail problems.
Cheers,
Paul
^ permalink raw reply [nested|flat] 6+ messages in thread
* Re: Discovering postgres binary directory location
2020-11-11 22:22 Discovering postgres binary directory location Raul Kaubi <raulkaubi@gmail.com>
2020-11-11 22:26 ` Re: Discovering postgres binary directory location Adrian Klaver <adrian.klaver@aklaver.com>
2020-11-12 06:22 ` Re: Discovering postgres binary directory location Paul Förster <paul.foerster@gmail.com>
2020-11-12 15:19 ` Re: Discovering postgres binary directory location Mark Johnson <remi9898@gmail.com>
2020-11-12 15:37 ` Re: Discovering postgres binary directory location Paul Förster <paul.foerster@gmail.com>
@ 2020-11-12 15:54 ` Paul Förster <paul.foerster@gmail.com>
0 siblings, 0 replies; 6+ messages in thread
From: Paul Förster @ 2020-11-12 15:54 UTC (permalink / raw)
To: Mark Johnson <remi9898@gmail.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; Raul Kaubi <raulkaubi@gmail.com>; pgsql-general
Hi Mark,
> On 12. Nov, 2020, at 16:37, Paul Förster <paul.foerster@gmail.com> wrote:
>
> how about searching for pg_ctl only inside a bin directory:
>
> $ find / -type f -name "pg_ctl" -exec grep "/bin/" {} \; 2>/dev/null
> Binary file /data/postgres/12.4/bin/pg_ctl matches
> Binary file /data/postgres/13.0/bin/pg_ctl matches
>
> That should also solve your source tree and root mail problems.
btw., you can also do it without calling grep:
$ find / -type f -executable -regex "*/bin/pg_ctl" 2>/dev/null
At least on openSUSE. But I guess, it should be pretty much the same on CentOS.
Cheers,
Paul
^ permalink raw reply [nested|flat] 6+ messages in thread
end of thread, other threads:[~2020-11-12 15:54 UTC | newest]
Thread overview: 6+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-11-11 22:22 Discovering postgres binary directory location Raul Kaubi <raulkaubi@gmail.com>
2020-11-11 22:26 ` Adrian Klaver <adrian.klaver@aklaver.com>
2020-11-12 06:22 ` Paul Förster <paul.foerster@gmail.com>
2020-11-12 15:19 ` Mark Johnson <remi9898@gmail.com>
2020-11-12 15:37 ` Paul Förster <paul.foerster@gmail.com>
2020-11-12 15:54 ` Paul Förster <paul.foerster@gmail.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox