Page 3 of 4

Re: check_nrpe is showing incorrect output

Posted: Tue Aug 10, 2021 1:47 pm
by gsmith
Hi,

To find out where sqlplus is located run:

Code: Select all

whereis sqlplus
let's say it is: /opt/oracle/instantclient_10_2/sqlplus

then you can add this to your .bash_profile:

Code: Select all

export SQLPATH="/opt/oracle/instantclient_10_2/"
---------OR-----------------

you can change your shell script:

Code: Select all

DBstatus=`echo "exit;" |/opt/oracle/instantclient_10_2/sqlplus user/password@(connect string)" 2>&1 | tee /tmp/dbout.log| grep "Connected to:" | wc -l`
Give one of those a try.

Thanks

Re: check_nrpe is showing incorrect output

Posted: Wed Aug 11, 2021 3:02 am
by Amit_Alone
Hi Smith,

As suggested I ran the command for sql locate and the same location I can observe present in the ~/.bash_profile of nagios on Linux Oracle server.

Code: Select all

[root@agasporap1855 ~]# whereis sqlplus
sqlplus: /u01/app/grid/19.3.0/gridhome_1/bin/sqlplus /u01/app/oracle/product/19.3.0/dbhome_1/bin/sqlplus
[root@agasporap1855 ~]# su - nagios
Last login: Tue Aug 10 11:37:39 EDT 2021 on pts/0
[nagios@agasporap1855 ~]$ whereis sqlplus
sqlplus: /u01/app/grid/19.3.0/gridhome_1/bin/sqlplus
Also, I mention the same path in the script but still while performing the check_nrpe it was giving incorrect o/p.

Code: Select all

bash-4.2$ /usr/local/nagios/libexec/check_nrpe -H XX.XX.XX.55 -t 30 -c DBconnection_status
CRITICAL - Oracle DB Connection Failed
Thanks.

Re: check_nrpe is showing incorrect output

Posted: Wed Aug 11, 2021 9:51 am
by gsmith
Hi,

What did the /tmp/dbout.log show this time?

Thx

Re: check_nrpe is showing incorrect output

Posted: Wed Aug 11, 2021 10:37 am
by Amit_Alone
Observing the same error.

Code: Select all

[root@agasporap1855 tmp]# cat dbout.log
/usr/local/nagios/libexec/check_dbconnection.sh: line 6: sqlplus: command not found
Thanks

Re: check_nrpe is showing incorrect output

Posted: Wed Aug 11, 2021 10:52 am
by gsmith
Hi

Please send me the following files from the Linux Oracle server, you can send them via PM for security reasons:

~/.bash_profile of nagios
check_dbconnection.sh


Thanks

Re: check_nrpe is showing incorrect output

Posted: Wed Aug 11, 2021 12:07 pm
by Amit_Alone
I have shared the requested data through PM.

Thanks

Re: check_nrpe is showing incorrect output

Posted: Wed Aug 11, 2021 12:27 pm
by gsmith
Hi

Please add:

Code: Select all

export SQLPATH="/u01/app/grid/19.3.0/gridhome_1/bin"
to the .bash_profile script for user nagios on the Linux Oracle machine

I know you already have this directory in your PATH variable but we need to have the
SQLPATH variable set correctly.

Once that is done open a NEW bash shell as the user nagios and run

Code: Select all

env
and verify the SQLPATH variable exists and has the correct value

then run:

Code: Select all

rm -f /tmp/dbout.log

Now try to run the check_nrpe from the nagios server.

Let me know the results and the contents of /tmp/dbout.log

Thanks

Re: check_nrpe is showing incorrect output

Posted: Thu Aug 12, 2021 8:39 am
by Amit_Alone
I have made the requested changes but still it's same.

Code: Select all

[root@agasporap1855 ~]# cat /tmp/dbout.log
/usr/local/nagios/libexec/check_dbconnection.sh: line 6: sqlplus: command not found
[root@agasporap1855 ~]#
env command output

Code: Select all

[nagios@agasporap1855 ~]$ env
XDG_SESSION_ID=701177
HOSTNAME=agasporap1855.agasp.ad
SHELL=/bin/bash
TERM=xterm
HISTSIZE=1000
USER=nagios
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=01;05;37;41:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.axv=01;35:*.anx=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=01;36:*.au=01;36:*.flac=01;36:*.mid=01;36:*.midi=01;36:*.mka=01;36:*.mp3=01;36:*.mpc=01;36:*.ogg=01;36:*.ra=01;36:*.wav=01;36:*.axa=01;36:*.oga=01;36:*.spx=01;36:*.xspf=01;36:
MAIL=/var/spool/mail/nagios
PATH=/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/nagios/.local/bin:/home/nagios/bin:/u01/app/grid/19.3.0/gridhome_1/bin/
PWD=/home/nagios
LANG=en_US.UTF-8
SQLPATH=/u01/app/grid/19.3.0/gridhome_1/bin
HISTCONTROL=ignoredups
SHLVL=1
HOME=/home/nagios
LOGNAME=nagios
LESSOPEN=||/usr/bin/lesspipe.sh %s
ORACLE_HOME=/u01/app/oracle/product/19.3.0/dbhome_1
_=/bin/env

Re: check_nrpe is showing incorrect output

Posted: Thu Aug 12, 2021 11:41 am
by gsmith
Hi

Let's try this, on the Linux Oracle machine:
on the command line:

Code: Select all

cp check_dbconnection.sh check_dbconnection.sh.orig
Now edit check_dbconnection.sh, remove everything that's there and replace it with:

Code: Select all

echo "sqlplus output:" > /tmp/dbout.log
sqlplus   2>&1 | tee -a /tmp/dbout.log
echo "/u01/app/grid/19.3.0/gridhome_1/bin/sqlplus output:" >> /tmp/dbout.log
/u01/app/grid/19.3.0/gridhome_1/bin/sqlplus 2>&1 | tee -a /tmp/dbout.log
echo "/u01/app/grid/19.3.0/gridhome_1/bin/sqlplus perms:" >> /tmp/dbout.log
ls -l u01/app/grid/19.3.0/gridhome_1/bin/sqlplus 2>&1 | tee -a /tmp/dbout.log
Save the file

on the command line:

Code: Select all

/usr/local/nagios/libexec/check_dbconnection.sh
copy the output of /tmp/dbout.log and send to me

Now run the check_nrpe from the Nagios server

copy the output of /tmp/dbout.log and send to me

Thanks

Re: check_nrpe is showing incorrect output

Posted: Fri Aug 13, 2021 7:49 am
by Amit_Alone
Hi Smit,

As suggested, I have copy the provided data in .sh file and after running the script on Linux Oracle server. Below is the o/p from /tmp/dbout.log file.

Code: Select all

root@agasporap1855 libexec]# cat /tmp/dbout.log
sqlplus output:

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Aug 13 08:39:16 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Enter user-name: Enter password:
Last Successful login time: Wed Aug 11 2021 03:55:58 -04:00

Connected to:
Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.10.0.0.0

SQL> Disconnected from Oracle Database 19c Enterprise Edition Release 19.0.0.0.0 - Production
Version 19.10.0.0.0
/u01/app/grid/19.3.0/gridhome_1/bin/sqlplus output:

SQL*Plus: Release 19.0.0.0.0 - Production on Fri Aug 13 08:39:52 2021
Version 19.3.0.0.0

Copyright (c) 1982, 2019, Oracle.  All rights reserved.

Enter user-name: 
Then I removed the /tmp/dbout.log file and then I ran the script from the Nagios server and below is the o/p.

Code: Select all

bash-4.2$ /usr/local/nagios/libexec/check_nrpe -H 10.110.3.55 -t 30 -c DBconnection_status
/usr/local/nagios/libexec/check_dbconnection.sh: line 2: sqlplus: command not found
Error 6 initializing SQL*Plus
SP2-0667: Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
-rwxr-xr-x. 1 root oinstall 24800 Sep 18  2020 u01/app/grid/19.3.0/gridhome_1/bin/sqlplus
bash-4.2$
Below is the dbout.log file data.

Code: Select all

[root@agasporap1855 libexec]# cat /tmp/dbout.log
sqlplus output:
/usr/local/nagios/libexec/check_dbconnection.sh: line 2: sqlplus: command not found
/u01/app/grid/19.3.0/gridhome_1/bin/sqlplus output:
Error 6 initializing SQL*Plus
SP2-0667: Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directory
/u01/app/grid/19.3.0/gridhome_1/bin/sqlplus perms:
-rwxr-xr-x. 1 root oinstall 24800 Sep 18  2020 u01/app/grid/19.3.0/gridhome_1/bin/sqlplus
[root@agasporap1855 libexec]#