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
env 2>&1 | tee -a /tmp/dbout.log
Run it via check_nrpe from the Nagios server and post the dbout.log file so
we can see how it's environment variables are set.
[root@agasporap1855 tmp]# 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
XINETD_LANG=en_US
NRPE_PROGRAMVERSION=3.2.1
REMOTE_HOST=::ffff:10.110.143.26
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
PWD=/
LANG=en_US.UTF-8
SHLVL=2
EXTRAOPTIONS=
NRPE_MULTILINESUPPORT=1
_=/usr/bin/env
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
XINETD_LANG=en_US
NRPE_PROGRAMVERSION=3.2.1
REMOTE_HOST=::ffff:10.110.143.26
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
PWD=/
LANG=en_US.UTF-8
SHLVL=2
EXTRAOPTIONS=
NRPE_MULTILINESUPPORT=1
_=/usr/bin/env
bash-4.2$
I had copied the shared script in dbconnection.sh file and then I run the same script under the nagios user on Linux oracle server and it work as expected, below is the dbout.log of the same.
[root@agasporap1855 ~]# cat /tmp/dbout.log
sqlplus output:
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Aug 14 10:20:25 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Enter user-name: /u01/app/grid/19.3.0/gridhome_1/bin/sqlplus output:
SQL*Plus: Release 19.0.0.0.0 - Production on Sat Aug 14 10:20:55 2021
Version 19.3.0.0.0
Copyright (c) 1982, 2019, Oracle. All rights reserved.
Enter user-name:
Then as suggested I have run the same script through check_nrpe from nagiosxi server and observed the timeout.
[[email protected] ~]$ /usr/local/nagios/libexec/check_nrpe -H XX.XXX.X.55 -t 30 -c DBconnection_status
OK - Oracle DB connected Successfully
Thanks Smith. Speaking frankly I was losing hope that it will not get resolved. But you made it to work as expected.
However, just one last question in case DB connection failed alert will be raised as CRITICAL right. I can't perform the test as all those servers are Prod servers.