...
Status | ||||
---|---|---|---|---|
|
Panel | ||||||
---|---|---|---|---|---|---|
| ||||||
|
Deploy Plugin to PostgreSQL-Server
Single instance
Create a .env file for instance-settings (name should always be the same as the instance)
Code Block language bash theme RDark root@myhost:~# vi /etc/check_mk/main.env
.
Panel borderColor black bgColor #F8F8F8 title Supply the following - PGDATABASE
- PGPORT
- PGVERSION
e.g.,
Code Block language bash theme RDark title /etc/check_mk/main.env PGDATABASE=postgres PGPORT=5432 PGVERSION=15
.
Create a .pgpass file with the password of the User configured in the .env-file (PGDATABASE)
Code Block language bash theme RDark root@myhost:~# vi /etc/check_mk/main.pgpass
.
Panel borderColor black bgColor #f8f8f8 title Example .pgpass file Code Block language bash theme RDark title /etc/check_mk/main.pgpass hostname:port:database:username:password
.
Tip Besides the password, you can use wildcards ("*") for every option.
The agent looks for all databases, so create a line for every database in your instance or use * instead of a database name.
e.g.,Code Block language bash theme RDark title /etc/check_mk/main.pgpass *:*:*:*:password
.
Note .pgpass-file should only have read/write rights for the root user: no group or others.
.
Configure the GUI
Setup → Agents → Windows, Linux, Solaris, AIX → Agent rules → PostgreSQL database and sessions (Linux, Windows) → Add rule
.Panel borderColor black bgColor #f8f8f8 title Provide the following - DB username
- Path to .env file
- Instance username
- Path to .pgpass file
.
- Click Save
. - Activate changes
. - Bake and sign agents
Multiple Instances
Create a .env file for instance-settings
Code Block language bash theme RDark root@myhost:~# vi /etc/check_mk/main.env
Tip The name should always be the same as the instance.
.
Panel borderColor black bgColor #f8f8f8 title Supply the following - PGDATABASE
- PGPORT
- PGVERSION
e.g.,
Code Block language bash theme RDark title /etc/check_mk/main.env PGDATABASE=postgres PGPORT=5432 PGVERSION=15
.
Create a .env file for any additional instances
Code Block language bash theme RDark root@myhost:~# vi /etc/check_mk/secondinst.env
.
Panel borderColor black bgColor #f8f8f8 title Supply the following - PGDATABASE
- PGPORT
- PGVERSION
e.g.,
Code Block language bash theme RDark title /etc/check_mk/secondinst.env PGDATABASE=postgres_second PGPORT=5433 PGVERSION=15
Note Ensure that the port numbers and names are unique for each instance.
.
Create a .pgpass file with the password of the User configured in the .env-file (PGDATABASE) for each instance
Code Block language bash theme RDark root@myhost:~# vi /etc/check_mk/main.pgpass root@myhost:~# vi /etc/check_mk/secondinst.pgpass
Panel borderColor black bgColor #f8f8f8 title Example .pgpass file Code Block language bash theme RDark title /etc/check_mk/main.pgpass hostname:port:database:username:password
.
Tip Besides the password, you can use wildcards ("*") for every option.
The agent looks for all databases, so create a line for every database in your instance or use * instead of a database name.
e.g.,Code Block language bash theme RDark title /etc/check_mk/main.pgpass *:*:*:*:password
.
Note .pgpass-file should only have read/write rights for the root user: no group or others.
.
Configure the GUI
Setup → Agents → Windows, Linux, Solaris, AIX → Agent rules → PostgreSQL database and sessions (Linux, Windows) → Add rule
.Panel borderColor black bgColor #f8f8f8 title Provide the following for each instance - DB username
- Path to .env file
- Instance username
- Path to .pgpass file
.
- Click Save
. - Activate changes
. - Bake and sign agents
Debugging
A simple test if the connection is up (The Script is using your settings, saved in /etc/check_mk/postgres.cfg):
Code Block language bash theme RDark title Linux root@myhost:~# /usr/lib/check_mk_agent/plugins/mk_postgres.py -t
Code Block language bash theme RDark title Windows C:\ProgramData\checkmk\agent\modules\python-3\.venv\Scripts\python.exe C:\ProgramData\checkmk\agent\plugins\mk_postgres.py -t
.
Info Only the first one is tested if you have configured more than one instance.
.
Run /usr/lib/check_mk_agent/plugins/mk_postgres.py on Agent Host
Code Block language bash theme RDark title /usr/lib/check_mk_agent/plugins/mk_postgres.py root@myhost:~# /usr/lib/check_mk_agent/plugins/mk_postgres.py -vv
Code Block language bash theme RDark title Windows C:\ProgramData\checkmk\agent\modules\python-3\.venv\Scripts\python.exe C:\ProgramData\checkmk\agent\plugins\mk_postgres.py -vv
.
Panel borderColor black bgColor #f8f8f8 title Errors Errors are in the first lines before the output.
You will get a DEBUG-Message if paths to conf, .env, or .pgpass-file are wrong or access to files isn't possible.
psql-errors are displayed even without verbose-option. e.g.:
- connection to server on socket " failed: No such file or directory" → if the wrong port is configured or port is not accessible
- connection to server on socket " failed: FATAL: database does not exist" → if the wrong User is configured
Related articles
Filter by label (Content by label) | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
...