add PGHOST variable to env files so mk_postgres can use type local co…
General information
This adds an optional PGHOST variable to the .env file of mk_postgres.py
It answers my own question at the Checkmk forum.
This is useful when connecting to databases that only LISTEN on a socket and not on a TCP port. Set PGHOST to a directory where the socket .s.PGSQL.$PGPORT is located and you can use connections that are configured in pg_hba.conf as type local.
In theory you could also set PGHOST to the name of a remote host where a database resides. This might be useful in cases where you are not allowed to install a Checkmk agent on a database machine.
here is an example for monitoring a GitLab PostgreSQL instance:
postgres.sql:
DBUSER=gitlab-psql
PG_BINARY_PATH=/opt/gitlab/embedded/postgresql/14/bin/psql
INSTANCE=/etc/check_mk/gitlabhq_production.env:gitlab-psql::
gitlabhq_production.env:
PGDATABASE=gitlabhq_production
PGPORT=5432
PGHOST=/var/opt/gitlab/postgresql
Also I deleted the mentioning of export in the description of .env files. It created the false appearance that you could export environment variables to mk_postgres.py.
All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.
I have read the CLA Document and I hereby sign the CLA or my organization already has a signed CLA.
@mo-ki I see failing tests here. Do I need to change/add something?
For transparency: I so far only identified the colleague responsible for this area; I made no further assessment of this PR.
What I can say: You changed the function to return a 4-tuple instead of a 3-tuple, which means you will have to adjust the type hint in line 1218. I think it should be # type: (str) -> tuple[str, str, str | None, str] now.
What I can say: You changed the function to return a 4-tuple instead of a 3-tuple, which means you will have to adjust the type hint in line 1218. I think it should be
# type: (str) -> tuple[str, str, str | None, str]now.
Done.