NRPE and linux 7 issue with DBD::Oracle

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

NRPE and linux 7 issue with DBD::Oracle

Post 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?
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

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

Post 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
User avatar
BanditBBS
Posts: 2474
Joined: Tue May 31, 2011 12:57 pm
Location: Scio, OH
Contact:

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

Post 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.
2 of XI5.6.14 Prod/DR/DEV - Nagios LogServer 2 Nodes
See my projects on the Exchange at BanditBBS - Also check out my Nagios stuff on my personal page at Bandit's Home and at github
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

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

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

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

Post 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
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

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

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

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

Post 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
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

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

Post by tgriep »

We do like duplication..... :)
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked