check_oracle plugin - Cannot determine ORACLE_HOME for SID

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
Zippyduda
Posts: 25
Joined: Thu Oct 10, 2019 7:17 am

check_oracle plugin - Cannot determine ORACLE_HOME for SID

Post by Zippyduda »

Hi all.

Seeing the following error:

Code: Select all

Cannot determine ORACLE_HOME for sid carc_db/mydomain_carcdb@v08oracle.mydomain.org/carcdb
Even though these commands works fine from the nagios user itself:

Code: Select all

nagios@v07-monitoring:/$ /usr/local/libexec/check_oracle --connect carc_db/mydomain_carcdb@v08oracle.mydomain.org
OK - login successful

nagios@v07-monitoring:/$ /usr/local/libexec/check_oracle --connect carc_db/lh4s4_carcdb@v08oracle.lhasalimited.org/carcdb
OK - login successful
ORACLE_HOME is defined for the user though

Code: Select all

nagios@v07-monitoring:/$ echo $ORACLE_HOME
/usr/lib/oracle/12.1/client64

nagios@v07-monitoring:/$ printenv
LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib
LESSCLOSE=/usr/bin/lesspipe %s %s
LANG=en_US.UTF-8
ORACLE_HOME=/usr/lib/oracle/12.1/client64
OLDPWD=/etc/adagiosconf/objects/hosts
USER=nagios
PWD=/
HOME=/home/nagios
XDG_DATA_DIRS=/usr/local/share:/usr/share:/var/lib/snapd/desktop
MAIL=/var/mail/nagios
TERM=xterm
SHELL=/bin/bash
TNS_ADMIN=/usr/lib/oracle/12.1/client64/network/admin
SHLVL=2
LOGNAME=nagios
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
LESSOPEN=| /usr/bin/lesspipe %s
_=/usr/bin/printenv
Attempted solutions:

- Changing from root to nagios or www-data user:group did not fix the issue:
root@v07-monitoring:/usr/lib# chown nagios: oracle/ -R
root@v07-monitoring:/usr/lib# chown www-data: oracle/ -R

- Adding / to end of ORACLE_HOME did not fix the issue.

- Adding $ORACLE_HOME/bin to PATH did not fix the issue.

- Adding the variables to /etc/environment and /etc/profile did not fix issue

- Adding /usr/lib and $ORACLE_HOME/bin to PATH did not fix the issue

What am I missing?

Only solution I can't see to get to work is the bottom of this one: https://monitoring-portal.org/woltlab/i ... alpha-red/

How do I add variables to the check_oracle file without breaking the file? Nagios complains when I put ORACLE_HOME or PATH in it.

Contents of /etc/adagiosconf/objects/commands/check_oracle.cfg

Code: Select all

define command {
         command_name                   check_oracle
        command_line                 $USER1$/check_oracle $ARG1$
}
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: check_oracle plugin - Cannot determine ORACLE_HOME for S

Post by tgriep »

When the nagios process runs the plugin, it does not have access to the environment variables and is causing the check to fail.

If you change the command_line to the following, it will setup the environment before running the plugin and that should work for you.

Code: Select all

/usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib ORACLE_HOME=/usr/lib/oracle/12.1/client64 /usr/local/nagios/libexec/check_oracle $ARG1$
Be sure to check out our Knowledgebase for helpful articles and solutions!
Zippyduda
Posts: 25
Joined: Thu Oct 10, 2019 7:17 am

Re: check_oracle plugin - Cannot determine ORACLE_HOME for S

Post by Zippyduda »

Thanks for that.

Now I'm getting the following error:

(Return code of 127 is out of bounds. Check if plugin exists)

Tried all of these options:

command_line /usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib ORACLE_HOME=/usr/lib/oracle/12.1/client64 /usr/local/nagios/libexec/check_oracle $ARG1$

command_line /usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib ORACLE_HOME=/usr/lib/oracle/12.1/client64 $USER1$/usr/local/nagios/libexec/check_oracle $ARG1$

command_line /usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib ORACLE_HOME=/usr/lib/oracle/12.1/client64 $USER1$/check_oracle $ARG1$

File exists:

root@v07-monitoring:~# ls -lh /usr/local/nagios/libexec/check_oracle
-rwxr-xr-x 1 nagios nagios 9.2K Oct 31 14:58 /usr/local/nagios/libexec/check_oracle

Do I need to define the command in /opt/nagios/etc/objects/commands.cfg as well?
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: check_oracle plugin - Cannot determine ORACLE_HOME for S

Post by tgriep »

You should only have one command defined in the config files.
You can put it in the commands.cfg file but remove it from the other config file.

Make sure the paths are correct in my example and that the env application is in /usr/bin folder.
Adjust the command if needed.

Also, remove $USER1$ from the command and put in the full path.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Zippyduda
Posts: 25
Joined: Thu Oct 10, 2019 7:17 am

Re: check_oracle plugin - Cannot determine ORACLE_HOME for S

Post by Zippyduda »

Apologies it looked like I tried all three, but I was only trying one at a time I was just showing the variations I had tried :)

root@v07-monitoring:/usr/bin# ls -lh | grep env
-rwxr-xr-x 1 root root 35K Jan 18 2018 env

This one hasn't worked for me unfortunately in /etc/adagiosconf/objects/commands/check_oracle.cfg:

define command {
command_name check_oracle
command_line /usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib ORACLE_HOME=/usr/lib/oracle/12.1/client64 /usr/local/nagios/libexec/check_oracle $ARG1$
}

"Return code of 127 is out of bounds. Check if plugin exists"

I'll try define it in commands.cfg instead
Zippyduda
Posts: 25
Joined: Thu Oct 10, 2019 7:17 am

Re: check_oracle plugin - Cannot determine ORACLE_HOME for S

Post by Zippyduda »

Putting it /etc/adagiosconf/objects/commands/commands.cfg instead of /etc/adagiosconf/objects/commands/check_oracle.cfg has fixed it! Huzzah!

Thanks for your help tgriep! :D
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: check_oracle plugin - Cannot determine ORACLE_HOME for S

Post by scottwilkerson »

Zippyduda wrote:Putting it /etc/adagiosconf/objects/commands/commands.cfg instead of /etc/adagiosconf/objects/commands/check_oracle.cfg has fixed it! Huzzah!

Thanks for your help tgriep! :D
Great!

Locking thread
Former Nagios employee
Creator:
ahumandesign.com
enneagrams.com
Locked