Skip to content

add PGHOST variable to env files so mk_postgres can use type local co… #792

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

robertdahlem
Copy link

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.

Copy link

github-actions bot commented Feb 17, 2025

All contributors have signed the CLA ✍️ ✅
Posted by the CLA Assistant Lite bot.

@robertdahlem
Copy link
Author

I have read the CLA Document and I hereby sign the CLA or my organization already has a signed CLA.

@mo-ki mo-ki added the tracked label Feb 19, 2025
@robertdahlem
Copy link
Author

@mo-ki I see failing tests here. Do I need to change/add something?

@mo-ki
Copy link
Member

mo-ki commented Feb 20, 2025

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.

@robertdahlem
Copy link
Author

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants