We know that we can put the plugin mk_postgres.py under /usr/lib/check_mk_agent/plugins on a host so that the checkmk-agent can fetch information about the PostgreSQL service and create servicess in Checkmk automatically.
What we like to know is what’s the easiest way to check that a login is possible to a certain database in PostgreSQL?
Method 1. Setup - Services - HTTP, TCP, Email, … - Check SQL Database - Add rule
then choose: PostgreSQL, port, user, password, Query or SQL statement
according to this info from Checkmk:
Are we supposes to write a query that gives the result in the form:
state name metrics where:
state is 0, 1, 2 or 3
name is service name
metrics is optional
This seems a bit cumbersome but maybe we misunderstand something.
Also a python-module seems to be required on the host so that check_sql works.
We just want to use the GUI to make a simple login-check against a PostgreSQL database.
Then if a login is possible and you for example can run SELECT version(); the service shows OK, otherwise Critical.
Method 2. Just make a shell-script that uses psql to log in to the database and execute SELECT version(); then depending on the result of the command the script outputs:
“0 check-name - Login is possible to database dbname”
or
“3 check-name - Can’t login to database dbname”
Method 3. Suggestions?
Best Regards
Bjorn.A