rapidloop / pgmetrics

Collect and display information and stats from a running PostgreSQL server
https://pgmetrics.io
Apache License 2.0
960 stars 65 forks source link

Unable to login without password #5

Closed MichaelDBA closed 6 years ago

MichaelDBA commented 6 years ago

pgmetrics -h 127.0.0.1 -p 5441 -U postgres --no-password example pgmetrics: pq: unexpected error: "setting PGSYSCONFDIR not supported"

I have the right entries in .pgpass so this works:

psql -h 127.0.0.1 -p 5441 -U postgres example
psql (10.2 (Ubuntu 10.2-1.pgdg14.04+1))
SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
Type "help" for help.
mdevan commented 6 years ago

Thanks for reporting. Can you try:

PGSYSCONFDIR= pgmetrics -h 127.0.0.1 -p 5441 -U postgres --no-password example

Is PGSYSCONFDIR set usually?

Also, if SSL connection is required, then:

PGSSLMODE=require PGSYSCONFDIR= pgmetrics -h 127.0.0.1 -p 5441 -U postgres --no-password example
MichaelDBA commented 6 years ago

echo $PGSYSCONFDIR /etc/postgresql-common

mdevan commented 6 years ago

Thanks. Fixed in f7d944f. As a workaround, you've to unset (not just clear like I said above) the env. var.:

unset PGSYSCONFDIR
pgmetrics -h 127.0.0.1 -p 5441 -U postgres --no-password example
MichaelDBA commented 6 years ago

That gets around the problem, but creates another side issue: pg_createcluster will not be able to find cluster defaults (create_cluster.conf) in the /etc/postgresql-common directory.

So I guess the workaround is unset PGSYSCONFDIR, and then set it again after executing pgmetrics.

mdevan commented 6 years ago

Yes. You could also have a script:

#!/bin/bash
unset PGSYSCONFDIR
pgmetrics $@

or run it in parenthesis:

(unset PGSYSCONFDIR; pgmetrics -h 127.0.0.1 -p 5441 -U postgres --no-password example)

to avoid setting it back again.

MichaelDBA commented 6 years ago

Thanks.