Page 1 of 1

NRPE and linux 7 issue with DBD::Oracle

Posted: Fri Apr 28, 2017 1:43 pm
by BanditBBS
OK, let me try and describe my issue as best I can....

Running a check locally, works fine, running it through NRPE I get "NRPE: Unable to read output"
I *think* i know the root cause, but can not figure out a solution.
I do what I'm doing all the time on Linux 6.x and it works flawlessly, just won't work on Linux 7.x
  • Install perl/cpan/nrpe/etc...
  • install oracle instant client
  • export ORACLE_HOME and LD_LIBRARY_PATH environment variables
  • Try command locally, works great
  • Try through NRPE and get the error
If I unset LD_LIBRARY_PATH environment variable the script exits with a bunch or perl compilation errors. I believe when running through NRPE it for some reason is not picking up the environment variables(even though the export is in nagios user's .bashrc file) and it cause the compilation errors which results in the NRPE: Unable to read output error

Any hints or suggestions?

Re: NRPE and linux 7 issue with DBD::Oracle

Posted: Fri Apr 28, 2017 1:57 pm
by ssax
The reason it's not working is because it doesn't have the same envars when it runs without a TTY.

I think you can toss it in /etc/environment but I generally just throw the envars I need in the top of the plugin file and set them at runtime.

Thank you

Re: NRPE and linux 7 issue with DBD::Oracle

Posted: Fri Apr 28, 2017 2:15 pm
by BanditBBS
I've tried everything you said actually. I seem to be having issues setting them in the perl as well. I am using the proper context, but it seems to be DBD::Oracle cpan module that need the environment variable and can't read then for some reason. Oracle.pm tries to read from the OS so setting them in the perl script as soon as you use "use DBD::Oracle" it errors out because that cpan perl module can't see the variable. I have tried to hard set in the Oracle.pm but haven't found the proper place yet.

Re: NRPE and linux 7 issue with DBD::Oracle

Posted: Mon May 01, 2017 9:11 am
by tgriep
When running a command using the NRPE agent, it should run the command without a TTY and when that is done, I don't think it has the ability to use the environment variables.
The workaround would be to edit the command on the remote system and path out the full environment in the command like the example below.

Code: Select all

/usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client/lib ORACLE_HOME=/usr/lib/oracle/11.2/client $USER1$/check_oracle_health $ARG1$
Edit the paths to match your environment.
When the command runs, take a look in the /var/log/messages file for the error message and post that here.

Re: NRPE and linux 7 issue with DBD::Oracle

Posted: Mon May 01, 2017 3:31 pm
by SteveBeauchemin
All my Gearman systems have this file:

Code: Select all

cat /etc/profile.d/oracle.sh
# Oracle Required Variables for environment
export ORACLE_HOME=/usr/lib/oracle/11.2/client64
if [ -z "$LD_LIBRARY_PATH" ]; then
  export LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib
else
  export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/oracle/11.2/client64/lib
fi
All my Oracle 'Command' definitions start with:

Code: Select all

/usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client64/lib ORACLE_HOME=/usr/lib/oracle/11.2/client64 $USER1$/check_oracle_health ...
That is working well for me. I guess I am covering multiple situations, but whatever works right?
(I am in process of moving from RH6 to RH7 on mod_gearman so this is fresh in my mind.)

Steve B

Re: NRPE and linux 7 issue with DBD::Oracle

Posted: Mon May 01, 2017 3:46 pm
by tgriep
Thanks @SteveBeauchemin for the help.
The OP is trying to run it with NRPE which does not run remotely in a shell and may not be able to use the environment variables like your script uses.

Re: NRPE and linux 7 issue with DBD::Oracle

Posted: Mon May 01, 2017 4:13 pm
by SteveBeauchemin
Ahhh, I see...

How about nrpe.cfg file change on the remote system, add the check command something like this? I have not done it, but would this work? (all on one line)

Code: Select all

command[check_oracle_health]=/usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/11.2/client/lib 
ORACLE_HOME=/usr/lib/oracle/11.2/client /usr/local/nagios/libexec/check_oracle_health $ARG1$
Oh, never mind, this is exactly what tgriep already said. oops. ;)

Thanks

Steve B

Re: NRPE and linux 7 issue with DBD::Oracle

Posted: Mon May 01, 2017 4:28 pm
by tgriep
We do like duplication..... :)