Check_mk_agent loop execution

Hi all,

I’ve executed the check_mk agent inside one server, and everything seems to work fine, meantime on the same server I’ve also some databases and I would like to monitor them as well, since that, what I’ve done, was to copy the mk_oracle and also the mk_oracle.cfg inside the same server and then I’ve forced the executión of the mk_oracle and it was grabbing data from db server.

Now my issue is: how can I get both data from check_mk_agent and also from mk_oracle agent at the same time?

Also, I’ve changed inside the check_mk_agent the routes of export to my own routes, but when I do this, directly the check_mk_agent when executed remains in loop and don’t give any data.

export MK_LIBDIR=${MK_LIBDIR:-/usr/lib/check_mk_agent}
export MK_CONFDIR=${MK_CONFDIR:-/etc/check_mk}
export MK_VARDIR=${MK_VARDIR:-/var/lib/check_mk_agent}

How can I fix this issue, so I can get all data from check_mk_agent and mk_oracle agent?

Thanks in advance.

Hi @whity

Try changing in WATO for this particular host the setting for the “Check MK Agent” from
Normal Checkmk agent, or special agent if configured (Default value) to Normal Checkmk agent, all configured special agents.

HTH,
Thomas

Even with that option, the result is the same as before…

mk_oracle is an agent plugin and belongs into the plugins directory of the agent installation. It will then be executed by the agent and its output will be appended to the agent output.

2 Likes

Hi @whity

I’m not sure what you mean with your statement above that you changed “the routes of export to my own routes”, in the CMK agent, but if you also say that your agent is no longer working as expected afterwards, it was probably a “bad idea”… What exactly were you/are you trying to achieve by this?

In any case, I just checked on one of my test instances, where I also monitor Oracle. I didn’t change the setting I mentioned earlier after all, so you can ignore this. I didn’t have to do much to get the plugin to work (other than bother my DBAs to create an account on the DB for me…). The steps I used were the following ones:

  • Installed the CheckMK agent
  • Didn’t modify it in any way
  • Copied the mk_oracle plugin to the proper location, as @r.sander pointed out as well.
  • Configured the plugin with an appropriate /etc/check_mk/mk_oracle.cfg as described, here: Monitoring Oracle databases efficiently

That was it. Perhaps you forgot one or more of the steps above.

HTH,
Thomas

1 Like

The issue might be because of an important detail I forgot to mention.
All the servers I’m monitoring, I’ve just pasted there the check_mk_agent. I didn’t installed it. It was just dropped in a path of my choice. This is the reason why I’ve changed the path for these:
export MK_LIBDIR=${MK_LIBDIR:-/usr/lib/check_mk_agent}
export MK_CONFDIR=${MK_CONFDIR:-/etc/check_mk}
export MK_VARDIR=${MK_VARDIR:-/var/lib/check_mk_agent}

Meantime, I’ve got some success when I’ve included mk_oracle code, inside the check_mk_agent code, plus the change that openmindz has referred before.

I don’t know if this is the best or only solution, but is seems to work.

Another important thing to refer, I do not have root access on the servers I’ve to monitor, this was the reason so I’ve not installed the agent and just pasted it there.

Thanks for participating in my question, this is leading me to find out solutions.

Hi @whity

Indeed that is an important detail. As far as I know, in a bash script, the construct

VAR=${VAR:-some path}

means the following: If the variable $VAR is not defined, use some path for it. What I’m getting
at is that you could avoid modifying the agent itself, and simply define the variables MK_LIBDIR, MK_CONFDIR and MK_VARDIR in your environment. This way, when you update the agent, it’ll work “out of the box”.

Thomas

Hi openmindz,

Yes, you are correct. I was expecting that behaviour. I’ll just define the variables and everything will work, the big issue is that does not work like that and instead it remains in loop. because seems strange for me this behaviour, I’ve started this query. :slight_smile:

Hi all,

I’m using - Checkmk 1.6.0p20

Meantime, I’ve been doing some more tests. This time inside an AIX server.

What I can share is:
Scenario1:
Original check_mk_agent, just changed the exports for my path and added the 755.
Origical mk_oracle.
Original mk_oracle.cfg, where I added the information related to the database I want to monitor.
On server properties, I’ve change to Normal Checkmk agent, all configured special agents.

If I force the manual execution of check_mk_agent or I use the diagnotic option on WATO, it will not bring any info from mk_oracle.
If I force mk_oracle manually, its returning good data without any errors.

Scenario2:
I’ve addedat the botton of check_mk_agent, mk_oracle script. Apart from this I’ve also kept all the changes for my path within the exports.
mk_oracle.cfg, remains equal.
On server properties, I’ve change to Normal Checkmk agent, or special agent if configured.

If I force the manual execution of check_mk_agent it works only the check_mk_agent part, mk_oracle is not working. If use the diagnotic option on WATO, it’s returning “Agent exited with code 3:”.

I really don’t know what I’m doing wrong here.

Thanks in advance,

I think without the knowledge of the real path locations of your files and your modifications/environment changes it is not possible to say why it is not working.

This is normally not relevant for your agent problem by itself, only if you get no data at all.

To check if you modified agent or your modified paths are working correctly you can make a small script with a single line output as debug information and place this script in your own plugins directory.
This line should be visible in the agent output also if you call the agent directly on your host.

Hi @whity

As I said in one of my earlier posts, and as Andreas correctly stated: The setting for the
agent is most likely unnecessary. Sorry for the misleading advice. In any case, here’s a
“quick and dirty test” on one of my AIX hosts that has has oslevel 7100-02-02-1316
(but that’s irrelevant… just for completeness).

I’m logged on as unprivileged, normal user thomas and am in /home/thomas

  • CMK agent check_mk_agent.aix is in /home/thomas/bin and of course made executable with chmod +x

  • CMK directories created under aforementioned homedir, e.g.: mkdir -p {lib/local,lib/plugins,etc,var/spool}

  • Relevant variables exported as follows:

export MK_LIBDIR=/home/thomas/lib
export MK_CONFDIR=/home/thomas/etc
export MK_VARDIR=/home/thomas/var

  • mk_oracle plugin copied to /home/thomas/lib/plugins and made it executable as well with chmod +x

  • “stock” mk_oracle.cfg copied to /home/thomas/etc

  • Also copied a tnsnames.ora and a sqlnet.ora my DBAs gave me into /home/thomas/etc

With all that in place, let’s give it a shot:

  • cd bin and ./check_mk_agent.aix

<<<oracle_instance>>>
<<<oracle_sessions>>>
<<<oracle_logswitches>>>
<<<oracle_undostat>>>
<<<oracle_recovery_area>>>
<<<oracle_processes>>>
<<<oracle_recovery_status>>>
<<<oracle_longactivesessions>>>
<<<oracle_dataguard_stats>>>
<<<oracle_performance>>>
<<<oracle_locks>>>
<<<oracle_tablespaces>>>
<<<oracle_rman>>>
<<<oracle_jobs>>>
<<<oracle_ts_quotas>>>
<<<oracle_resumable>>>
<<<oracle_instance>>>
<<<oracle_processes>>>
<<<oracle_asm_diskgroup>>>
Error Message: <DB1>|FAILURE|ERROR: ORA-01017: invalid username/password; logon denied SP2-0751: Unable to connect

Wonderful! Of course now I’d have to configure a DBUSER in
mk_oracle.cfg to really get results, but other than that:
Works just fine, even as unprivileged, normal user.
No modification of the agent itself was necessary whatsoever.

Please recheck your setup: You may be missing one
or multiple steps from above. Please also review the official
documentation of the Oracle plugin, posted above.

Notes:

  • Agent output above, intentionally truncated.
  • DB Name changed for security reasons.

HTH,
Thomas

1 Like

Hi,
Before, whatever, thanks for your time and the troubleshoot of your example.

My current configuration is:
check_mk_agent on: /home/whity/check_mk/plugins
with the following exports inside:
export MK_LIBDIR=/home/whity/check_mk/lib
export MK_CONFDIR=/home/whity/check_mk/etc
export MK_VARDIR=/home/whity/check_mk/var

mk_oracle on: /home/whity/check_mk/lib/plugins with -rwxr-xr-x
mk_oracle.cfg and sqlnet.ora on /home/whity/check_mk/etc with -rw-r–r--

With this configurations when I execute the check_mk_agent it doesn’t grab the mk_oracle. and if I execute the mk_oracle alony is says that MK_CONFDIR not set!.

Seems that I’m doing the same as you, I fear that I’m missing a minor detail, because its still not working…

Thanks in advance

Hi @whity

OK… or rather not OK… Can you try two things:

  1. After you export can you double check by echo’ing each variable e.g. with echo $MK_CONFDIR?
  2. Can you try to run your agent and the plugin with the -d switch to verify that your variables are actually used (Caution: You’ll get a very large output…)

Thomas

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