POSTGRESQL - Status: instance CHECK_MK_POSTGRES is not running

Hi,

i’ve upgraded the CheckMK agent to release [2.3.0p21] on a PostgreSQL Server.

I changed the script [mk_postgres] to [mk_postgres.py].

My /etc/check_mk/postgres.cfg

DBUSER=postgres
PG_BINARY_PATH=/logiciel/postgresql/bin/psql
INSTANCE=/etc/check_mk/check_mk_postgres.env:checkmk:/etc/check_mk/.check_mk_postgres.pgpass

My environment file [/etc/check_mk/check_mk_postgres.env]

export PGHOST=mypgsqlserver
export PGDATABASE=mydatabase
export PGPORT=1854
export PGUSER=supervision
export PGPASSFILE=/home/postgres/.mypgsqlserver.pgpass
export PGHOME=/logiciel/postgresql/bin

When i execute the script [mk_postgres.py] in the section [postgres_instances] there is nothing :

<<<postgres_instances>>>
[[[check_mk_postgres]]]

<<<postgres_sessions>>>
[[[check_mk_postgres]]]

In GUI CheckMK i’ve got this error:

Do you know how to resolve my problem ?

Thanks for your help,

Matt

Hi,

Is someone has an idea please ?

Thanks for your help,
Matt

Hi,

Is someone has an idea please ?

Thanks for your help,
Matt

Hello Matt,

Please note that the Forum is a place where people engage voluntarily and on the topics they could relate to or with which they could help. Bumping up the same post several times with no additional data, for example, that appeared in the course of your own research of the issue, are usually not helpful, and creates uninformative messages.

Please try to look into other posts on the related issues in the forum – they might have helpful information and hopefully provide additional details to this case. It is possible that the results of your additional research could help Community Members help you.

Best regards,
Sara

Hi @Sara

I fully understand what you said.

The problem is :
Status: instance CHECK_MK_POSTGRES is not running or postgres DATADIR name is not identical with instance nameCRIT, Version: PostgreSQL 14.10 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 8.5.0 20210514 (Red Hat 8.5.0-22.0.1), 64-bit

I can’t understand why the script said [INSTANCE] naming while there is no concept of [INSTANCE_NAME] in PostgreSQL like Oracle or SQL Server.

ps -fu postgres
UID          PID    PPID  C STIME TTY          TIME CMD
postgres  206963       1  0 09:01 ?        00:00:00 /soft/postgresql/bin/postmaster -D /pgsql/xxxxx/data
postgres  206970  206963  0 09:01 ?        00:00:00 postgres: logger
postgres  206972  206963  0 09:01 ?        00:00:00 postgres: checkpointer
postgres  206973  206963  0 09:01 ?        00:00:00 postgres: background writer
postgres  206974  206963  0 09:01 ?        00:00:00 postgres: walwriter
postgres  206975  206963  0 09:01 ?        00:00:00 postgres: autovacuum launcher
postgres  206976  206963  0 09:01 ?        00:00:00 postgres: stats collector
postgres  206977  206963  0 09:01 ?        00:00:00 postgres: logical replication launcher

I found an improvment about the message :

In this article :
https://checkmk.atlassian.net/wiki/spaces/KB/pages/16646145/How-to+monitor+PostgreSQL
they said that “Create a .env file for instance-settings (name should always be the same as the instance)”

My .env file is :

ls -rtl /etc/check_mk/check_mk_postgres.env
-rw------- 1 postgres postgres 188 21 mars  09:04 /etc/check_mk/check_mk_postgres.env

I have to change the name ?

Thanks for your help,

Matt

Hi,

I’ve rename the file as main.env and .main.pgpass

Environment File for Checkmk

  • OLD NAME : /etc/check_mk/check_mk_postgres.env
  • NEW NAME : /etc/check_mk/main.env

PGPASS File for CheckMK

  • OLD_NAME : /etc/check_mk/.check_mk_postgres.pgpass
  • NEW_NAME : /etc/check_mk/.main.pgpass

Now the check seems OK

Question do you know if it’s possible to customize MAIN name of “PostrgreSQL Instance Name” ?

Thanks for your help,
Matt

Hi,

In mk_postgres.py :

    for line in postgres_cfg:
        if line.startswith("#") or "=" not in line:
            continue
        line = line.strip()
        key, value = line.split("=")
        if key == "DBUSER":
            dbuser = value.rstrip()
        if key == "PG_BINARY_PATH":
            pg_binary_path = value.rstrip()
        if key == "INSTANCE":
            env_file, pg_user, pg_passfile, instance_name = _parse_INSTANCE_value(
                value, config_separator
            )
            pg_database, pg_port, pg_version = parse_env_file(env_file)

When the python script read postgres.cfg, it searches 4 arguments, in the documentation i always found 3 :

  • Env File
  • User
  • PGPASS

It’s possible to add a fourth argument to customize “INSTANCE_NAME”.’

Environment File for Checkmk

OLD NAME : /etc/check_mk/main.env
NEW NAME : /etc/check_mk/dbpgtst.env

PGPASS File for CheckMK

OLD_NAME : /etc/check_mk/.main.pgpass
NEW_NAME : /etc/check_mk/.dbpgtst.pgpass

Line INSTANCE in postgres.cfg :
INSTANCE=/etc/check_mk/dbpgtst.env:checkmk:/etc/check_mk/.dbpgtst.pgpass:DBPGTST

The Instance Name in CheckMK is customize but again i have the problem.

I’v tried with the directory monitor by postmaster PID :

postgres  206963       1  0 09:01 ?        00:00:00 /soft/postgresql/bin/postmaster -D /pgsql/xxxxx/data
postgres=# show data_directory;
   data_directory
---------------------
 /pgsql/xxxxx/data
(1 ligne)

I can’t what i have to confgiure to customize Instance Name.

Thanks for your help,

Matt

Hi,

I think i understand what is INSTANCE_NAME for mk_postgres.py.

The script catch the line for PID [postmaster -D] and configure [INSTANCE_NAME] is the last directory name.

ps -fu postgres | grep postmaster
postgres  302594       1  0 14:08 ?        00:00:00 /soft/postgresql/bin/postmaster -D /pgsql/xxxxx/data

So in /etc/check_mk/postrges.cfg, i configure INSTANCE_NAME like below (added last directory name as fourth argument)

INSTANCE=/etc/check_mk/check_mk_postgres.env:checkmk:/etc/check_mk/.check_mk_postgres.pgpass:data

Now all is OK :

Matt

1 Like

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed. Contact an admin if you think this should be re-opened.