Mk_postgres.py not finding new databases

CMK version:2.1.0p38
OS version:RedHat 7.9 ← Client Site

Error message from service:
Instance MAIN not running or postgres DATADIR name is not identical with instance name.

Output of “mk_postgres.py” runned from Check_MK: (If it is a problem with checks or plugins)

<<<postgres_instances>>>
[[[main]]]

<<<postgres_stat_database:sep(59)>>>
[[[main]]]

<<<postgres_version:sep(1)>>>
[[[main]]]

<<<postgres_conn_time>>>
[[[main]]]
0.037

Even though the postgre-process can be found in the process list and IS found by the plugin at first, after the regex matching, the plugin seems to “lose” all database related lines.
If you run the script as an bash user, the plugin works fine.

We could pin-point the problem down to the lamba-function which will be called and used in line Z. 847 (_filter_instances). If you cut out the “and (proc_sensitive_filter)…” the plugin (runned as agent) finds all relevant outputs, but also unrelevant information.

We are a little bit confused, how it seems to be the case, that the no-shell run is reading in the “lambda”-function differently than an shell-user.

Someone had this problem and found a fix already? It’s an default agent with the postgres-plugin.

Is this the only output you get when running mk_postgres.py directly on the command line?
How does the /etc/check_mk/postgres.cfg look like?

Like i mentioned, if i run the plugin as an root-user with a shell (putty), then i get all necessary information from the plugin related to the database.

It’s only that the agent itself, running as a service, won’t match the progress and therefore won’t recognize the database process. We are confused how this is even possible.

If we integrate “print()” into the plugin and print out the variable “procs_list”, we can clearly see the process we want to be match, but the agent can’t “match it” without an active shell from an user.

Somehow it seems, that the lambda-function is treated differently.

Are you using some special Postgres variables as root and exporting them while running the postgres agent plugin manually ? If yes, maybe those have to be defined a .bashrc or .bash_profile ?

You can also try printing the self.name here because thats what checked in the proc_sensitive_filter

Hey @chauhan_sudhir
i tried printing “self.name.lower()” and just got “main” as a result.
Everything else like the plugin headers “<<<postgre_instance>>>” and co disappeard.

And we got no addition environment-variable set, it’s just → Change to root, run plugin → works
Agent runs plugins → does not work

The agent runs also as root but without the whole environment of root.
I think there are some “hidden” settings in your root account that lead to the different behavior.

That is what i was thinking, but as for now, we can’t find these “variables” that are the reason for this. And also, i can’t see how a environmental variable is changing the filter behavior, which is set in the script itself.