Nagios check_oracle_health - ORA-12154 ERROR

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.
admincauce
Posts: 34
Joined: Wed Sep 19, 2018 3:20 am

Nagios check_oracle_health - ORA-12154 ERROR

Post by admincauce »

Hi

I am trying to configure the Oracle check "check_oracle_health" on my Nagios server.

I have followed the steps described for the installation of "check_oracle_health" on the Oracle server. I have done some tests locally, on the Oracle server (mounted on a Linux Oracle) giving a correct output as shown in the examples shown below:

[root @ cnfora10 oracle] # / usr / local / nagios / libexec / check_oracle_health --mode = tnsping --connect orcl
OK - connection established to orcl.

[root @ cnfora10 oracle] # / usr / local / nagios / libexec / check_oracle_health --connect = nagios / ****** @ ORCL --environment --mode connected-users
OK - 2 connected users | connected_users = 2; 50; 100

[root @ cnfora10 oracle] # / usr / local / nagios / libexec / check_oracle_health --connect = nagios / oradbmon @ ORCL --mode tablespace-free --name USERS
OK - tbs USERS has 99.99% free space left | 'tbs_users_free_pct' = 99.99%; 5:; 2: 'tbs_users_free' = 32766MB; 1638.40:; 655.36:; 0; 32767.98

I have correctly configured my NRPE file to make the call of the check from the nagios server, in the following way:

command [check_tablespaces] = / usr / local / nagios / libexec / check_oracle_health --connect = nagios / oradbmon @ orcl --environment --environment ORACLE_HOME = / u01 / app / oracle / product / 12c / dbhome_1 --mode tablespace-free --name USERS

When I run the test to run the check remotely from the NAGIOS server with NRPE, it gives the following error:

[root @ GESNAG00 ~] # / usr / local / nagios / libexec / check_nrpe -H 10.200.3.14 -c check_tablespaces
CRITICAL - can not connect to nagios / *** @ orcl. ORA-12154: TNS: could not resolve the connect identifier specified (DBD ERROR: OCIServerAttach)

What can be happening so that I do not run the check remotely? Any environment variable not declared? On the NAGIOS server I have not installed anything related to Oracle.

Best regards.
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Nagios check_oracle_health - ORA-12154 ERROR

Post by tgriep »

I would suspect that the environment variable is not getting setup all of the way for the plugin and it is causing the error.
Typically the ORACLE_HOME and the LD_LIBRARY_PATH environment variable needs to be setup and the following example is how you can create the command in the nrpe.cfg file. Adjust the path to where you installed the Oracle Instant Client.

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 --connect=$HOSTADDRESS$:1521/xe --username=nagios --password=oradbmon --mode=connection-time
Try that out and see if this fixes the issue.
Be sure to check out our Knowledgebase for helpful articles and solutions!
admincauce
Posts: 34
Joined: Wed Sep 19, 2018 3:20 am

Re: Nagios check_oracle_health - ORA-12154 ERROR

Post by admincauce »

Thank you very much for the reply,

From what I understand in your answer, I have to have installed the Oracle Instant Client on the NAGIOS server in order to define those environment variables that are needed and be able to do the corresponding checks on the Oracle server that I have installed on another machine.

Is what I say true?

Thank you very much in advance.
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Nagios check_oracle_health - ORA-12154 ERROR

Post by tgriep »

If you want to run the check_oracle_health on the remote Oracle server using the check_nrpe plugin, you will have to install the Oracle Instant Client on the Oracle server and setup the NRPE command like the example, adjusting the path to the client version.
Be sure to check out our Knowledgebase for helpful articles and solutions!
admincauce
Posts: 34
Joined: Wed Sep 19, 2018 3:20 am

Re: Nagios check_oracle_health - ORA-12154 ERROR

Post by admincauce »

Thank you very much again for your response,

I have made the changes you mentioned in the previous post, and still give me error.

The last thing I have done is the following:

On the Nagios server, I have installed Oracle Instant Client, and the environment variables are:

LD_LIBRARY_PATH = / usr / lib / oracle / 11.2 / client64 / lib
ORACLE_HOME = / usr / lib / oracle / 11.2 / client64

On the Oracle server, I modified the command call in my nrpe.cfg file, leaving it as follows:

command [check_connection_time] = / usr / bin / env LD_LIBRARY_PATH = / usr / lib / oracle / 11.2 / client64 / lib ORACLE_HOME = / usr / lib / oracle / 11.2 / client64 / usr / local / nagios / libexec / check_oracle_health --connect = nagios / oradbmon @ orcl --mode = connection-time.

If I launch the check directly from the Oracle server, it gives the following result:

[root @ cnfora10 ~] # / usr / local / nagios / libexec / check_oracle_health --mode connection-time --connect = nagios / oradbmon @ orcl
OK - 0.04 seconds to connect as NAGIOS | connection_time = 0.0442; 1; 5

If I launch it from the Nagios server using NRPE, it gives the following error:

[root @ GESNAG00 ~] # / usr / local / nagios / libexec / check_nrpe -H 10.200.3.14 -c check_conn
CRITICAL - can not connect to nagios / *** @ orcl. ERROR OCIEnvNlsCreate. Check ORACLE_HOME (Linux) env or PATH (Windows) and or NLS settings, permissions, etc.

I do not know where the problem may be.

Thank you very much in advance.
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Nagios check_oracle_health - ORA-12154 ERROR

Post by tgriep »

Login to the Oracle server as root and run the following to get the environment variables while logged in as root and the nagios user.

Code: Select all

env
su - nagios
env
Thanks.
Be sure to check out our Knowledgebase for helpful articles and solutions!
admincauce
Posts: 34
Joined: Wed Sep 19, 2018 3:20 am

Re: Nagios check_oracle_health - ORA-12154 ERROR

Post by admincauce »

Here the result.

Environment variables for user "root"
HOSTNAME=cnfora10
SELINUX_ROLE_REQUESTED=
TERM=xterm
SHELL=/bin/bash
HISTSIZE=1000
ORACLE_UNQNAME=cnfora00
TMPDIR=/tmp
SSH_CLIENT=10.60.152.33 40516 22
SELINUX_USE_CURRENT_RANGE=
QTDIR=/usr/lib64/qt-3.3
QTINC=/usr/lib64/qt-3.3/include
SSH_TTY=/dev/pts/0
USER=root
LD_LIBRARY_PATH=/u01/app/oracle/product/12c/dbhome_1/lib:/lib:/usr/lib
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:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=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:*.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:
ORACLE_SID=oracl
ORACLE_HOSTNAME=cnfora00
MAIL=/var/spool/mail/root
PATH=/u01/app/oracle/product/12c/dbhome_1/bin:/usr/sbin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/u01/app/oracle/product/12c/dbhome_1/bin:/root/bin
PWD=/root
LANG=en_US.UTF-8
SELINUX_LEVEL_REQUESTED=
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
HISTCONTROL=ignoredups
SHLVL=1
HOME=/root
TMP=/tmp
LOGNAME=root
QTLIB=/usr/lib64/qt-3.3/lib
CVS_RSH=ssh
CLASSPATH=/u01/app/oracle/product/12c/dbhome_1/jlib:/u01/app/oracle/product/12c/dbhome_1/rdbms/jlib
SSH_CONNECTION=10.60.152.33 40516 10.200.3.14 22
LESSOPEN=||/usr/bin/lesspipe.sh %s
ORACLE_HOME=/u01/app/oracle/product/12c/dbhome_1
G_BROKEN_FILENAMES=1
_=/bin/env
Environment variables for user "nagios"
HOSTNAME=cnfora10
SELINUX_ROLE_REQUESTED=
SHELL=/bin/bash
TERM=xterm
HISTSIZE=1000
SSH_CLIENT=10.60.152.33 40516 22
TMPDIR=/tmp
ORACLE_UNQNAME=cnfora00
SELINUX_USE_CURRENT_RANGE=
QTDIR=/usr/lib64/qt-3.3
QTINC=/usr/lib64/qt-3.3/include
SSH_TTY=/dev/pts/0
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:*.arj=01;31:*.taz=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lz=01;31:*.xz=01;31:*.bz2=01;31:*.tbz=01;31:*.tbz2=01;31:*.bz=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.rar=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=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:*.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:
LD_LIBRARY_PATH=/u01/app/oracle/product/12c/dbhome_1/lib:/lib:/usr/lib
ORACLE_SID=oracl
ORACLE_HOSTNAME=cnfora00
PATH=/u01/app/oracle/product/12c/dbhome_1/bin:/usr/sbin:/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/u01/app/oracle/product/12c/dbhome_1/bin:/root/bin
MAIL=/var/spool/mail/root
_=/bin/env
PWD=/root
LANG=en_US.UTF-8
SELINUX_LEVEL_REQUESTED=
HISTCONTROL=ignoredups
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
HOME=/var/spool/nagios
SHLVL=2
LOGNAME=nagios
TMP=/tmp
CVS_RSH=ssh
QTLIB=/usr/lib64/qt-3.3/lib
SSH_CONNECTION=10.60.152.33 40516 10.200.3.14 22
CLASSPATH=/u01/app/oracle/product/12c/dbhome_1/jlib:/u01/app/oracle/product/12c/dbhome_1/rdbms/jlib
LESSOPEN=||/usr/bin/lesspipe.sh %s
ORACLE_HOME=/u01/app/oracle/product/12c/dbhome_1
G_BROKEN_FILENAMES=1
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Nagios check_oracle_health - ORA-12154 ERROR

Post by tgriep »

The paths for the environment variables need to be adjusted for your environment.
Edit the command in the nrpe.cfg file and change it to the following. Verify that the paths are correct.

Code: Select all

/usr/bin/env LD_LIBRARY_PATH=/u01/app/oracle/product/12c/dbhome_1/lib ORACLE_HOME=/u01/app/oracle/product/12c/dbhome_1 $USER1$/check_oracle_health --connect=$HOSTADDRESS$:1521/xe --username=nagios --password=oradbmon --mode=connection-time
Since you are running the command on the Oracle server, the settings have to be for that server, not the Nagios server.
Be sure to check out our Knowledgebase for helpful articles and solutions!
admincauce
Posts: 34
Joined: Wed Sep 19, 2018 3:20 am

Re: Nagios check_oracle_health - ORA-12154 ERROR

Post by admincauce »

thank you very much

I think we are on the right track because with the change you have proposed, now the error is different:

[root @ GESNAG00 admin] # / usr / local / nagios / libexec / check_nrpe -H 10.200.3.14 -c check_conn
CRITICAL - can not connect to nagios / *** @ orcl. ORA-12154: TNS: could not resolve the connect identifier specified (DBD ERROR: OCIServerAttach)

Finally this is what I have in the nrpe.cfg file on the server side of oracle:

command [check_conn] = / usr / bin / env LD_LIBRARY_PATH = / u01 / app / oracle / product / 12c / dbhome_1 / lib ORACLE_HOME = / u01 / app / oracle / product / 12c / dbhome_1 / usr / local / nagios / libexec / check_oracle_health --connect = nagios / oradbmon @ orcl --mode = connection-time

And this is what my tnsname.ora file contains on the server side of Oracle:

LISTENER_ORACL =
  (ADDRESS = (PROTOCOL = TCP) (HOST = 10.200.3.14) (PORT = 1539))


ORCL =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP) (HOST = 10.200.3.14) (PORT = 1539))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl)
    )
  )

Thanks again!
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Nagios check_oracle_health - ORA-12154 ERROR

Post by tgriep »

What folder is the tnsnames.ora file in?

Go to this folder and verify that there is a bin folder

Code: Select all

/u01/app/oracle/product/12c/dbhome_1/
and verify that there is a bin folder with the Oracle Instant Client's applications.
and that there is a lib folder with the Oracle Instant Client's libraries.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked