Output of plugin changes when called from agent

CMK version:
2.0.0p29

OS version:
Oracle Linux 7.9

Error message:
No error message

I’m using the mk_oracle plugin. Running it directly, I can see information about tablespaces for all the databases, but if I run it via the agent, I can only see some of them.

Here some example calling the agent directly:

[root@sbghodat1n0 (22:35:54) /usr/lib/check_mk_agent/plugins (BT90_2) ]$./mk_oracle  | egrep "oracle_tablespaces" -A1
<<<oracle_tablespaces>>>
<<<oracle_instance>>>
--
<<<oracle_tablespaces:sep(124):cached(1678993055,600)>>>
BD81|/u02/app/oracle/oradata/BD81_sbghodat1/BD81_SBGHODAT1/datafile/o1_mf_tiger_k64v62fd_.dbf|TIGER|AVAILABLE|YES|1902216|4194176|1902088|65536|ONLINE|8192|ONLINE|1636848|PERMANENT|11.2.0.4.0
--
<<<oracle_tablespaces:sep(124):cached(1678993111,600)>>>
BD81N|/u02/app/oracle/oradata/BD81n_sbghodat1/BD81N_SBGHODAT1/datafile/o1_mf_tiger_krn4sct8_.dbf|TIGER|AVAILABLE|YES|1902216|4194176|1902088|65536|ONLINE|8192|ONLINE|1498088|PERMANENT|19.0.0.0.0
--
<<<oracle_tablespaces:sep(124):cached(1678993051,600)>>>
BT90|/u02/app/oracle/oradata/BT90_sbghodat1/BT90_SBGHODAT1/datafile/o1_mf_users_jwy38xfm_.dbf|USERS|AVAILABLE|YES|32768|4194176|32640|12800|ONLINE|8192|ONLINE|32632|PERMANENT|19.0.0.0.0

Here some example when calling the agent:

[root@sbghodat1n0 (22:36:18) /usr/lib/check_mk_agent/plugins (BT90_2) ]$/usr/bin/check_mk_agent  | egrep "oracle_tablespaces" -A1
11:blkio:/user.slice,8:pids:/user.slice,7:memory:/user.slice,6:devices:/user.slice,4:cpu,cpuacct:/user.slice,1:name=systemd:/user.slice/user-169126.slice/session-621.scope root 114296 2344 00:00:00 00:01 70544 grep -E --color=auto oracle_tablespaces -A1
11:blkio:/system.slice/ohasd.service,8:pids:/system.slice/ohasd.service,7:memory:/system.slice/ohasd.service,6:devices:/system.slice/ohasd.service,1:name=systemd:/system.slice/oracle-ohasd.service oracle 17535012 27640 00:14:09 21-05:21:35 70548 ora_scm0_BT24_2
--
<<<oracle_tablespaces>>>
<<<oracle_instance>>>
--
<<<oracle_tablespaces:sep(124):cached(1679002350,600)>>>
BT90|/u02/app/oracle/oradata/BT90_sbghodat1/BT90_SBGHODAT1/datafile/o1_mf_users_jwy38xfm_.dbf|USERS|AVAILABLE|YES|32768|4194176|32640|12800|ONLINE|8192|ONLINE|32632|PERMANENT|19.0.0.0.0

As you can see, if I call the plugin directly, I get information from 3 different databases, but if I call it via the agent, I get information only from one of the databases.

Any ideas what to do here, please?

Thanks and best regards,
Rafael

You are running both under the same user, I am assuming?

This usually is a problem with differing environments (paths, libraries and other variables). To debug I suggest dumping the environment one time from the shell:

env > /tmp/env_shell.txt

and once by adding this lines to a dummy plugin /usr/lib/check_mk_agent/plugins/dummy.sh:

#!/bin/bash
env > /tmp/env_plugin.txt

Make it executable chmod 0755 /usr/lib/check_mk_agent/plugins/dummy.sh, then wait a minute until it got executed and compare both. Differing variables that cause the differing outputs have to be set explicitly. There are some plugins where you can set environment variables by rules, for others you have to edit (or fork the plugin script itself).

2 Likes

I suggest env | sort > /tmp/env_shell.txt for easier comparison.

2 Likes

Hello mschlenker,

thank you very much for the hint. Finally, the problem was due to MK_VARDIR pointing to a different location. Now the issue is solved :slight_smile:

Best regards,
Rafael

1 Like