Page 1 of 1

error"TNS:listener was not given the SERVICE_NAME"

Posted: Wed Apr 27, 2016 6:58 am
by ghostzy
Moderator Edit: This thread has been split from another - https://support.nagios.com/forum/viewto ... f=6&t=9482
In the future, please create a new thread and link to the old one instead of adding on.


Hi Guys, sorry to write on this old thread but i'm having the same issue:
CRITICAL - cannot connect to IP:1521/ORCL. ORA-12514: TNS:listener does not currently know of service requested in connect descriptor (DBD ERROR: OCIServerAttach)

Now , i'm running a centos build with NagiosXI , i've configured the oracleclient on my Nagios server, i had some issues on cpan installation. It was exaclty like in the https://assets.nagios.com/downloads/nag ... ios-XI.pdf, more exactly my export were as bellow:

Code: Select all

export ORACLE_HOME=/usr/lib/oracle/12.1/client64
LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib/
I've manage to fix the issue by pointing the export to oracle home like:

Code: Select all

export ORACLE_HOME=/usr/lib/oracle/12.1/client64
This allowed the cpan perl module to be installed, and i when from:

Code: Select all

CRITICAL - cannot connect to IP:1521. install_driver(Oracle) failed: Can't locate DBD/Oracle.pm in @INC (@INC
contains: /usr/local/nagios/libexec /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl
to
CRITICAL - cannot connect to IP:1521/ORCL. ORA-12514: TNS:listener does not currently know of service requested in connect descriptor (DBD ERROR: OCIServerAttach)
i'm pretty sure i can connect to that DB cause i tryied directly from splus, like:

Code: Select all

sqlplus "user/pass@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=IP)(Port=1521))(CONNECT_DATA=(SID=sid)))"
My oracle commands in nagiosxi are :

Code: Select all

check_xi_oraclequery
/usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib ORACLE_HOME=/usr/lib/oracle/12.1/client64/bin $USER1$/check_oracle_health $ARG1$
check_xi_oracleserverspace
/usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib ORACLE_HOME=/usr/lib/oracle/12.1/client64/bin $USER1$/check_oracle_health $ARG1$
check_xi_oracletablespace
/usr/bin/env LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib ORACLE_HOME=/usr/lib/oracle/12.1/client64/bin $USER1$/check_oracle_health $ARG1$
Any help is more than welcome, does anyone know why the service checks for oracle won't work for me?

many thanks
Cristi

Re: error"TNS:listener was not given the SERVICE_NAME"

Posted: Wed Apr 27, 2016 9:41 am
by rkennedy
I see you posted the output, and your command definitions, but not seeing anything for the actual service check_commands.

Could you post what you're trying to do with both the inputs / outputs for us to work with?

Re: error"TNS:listener was not given the SERVICE_NAME"

Posted: Thu Apr 28, 2016 4:03 am
by ghostzy
Hi Guys, thank for looking after this and sorry for the other post, i was not sure if they are both monitored.
So my checks are like this:

Code: Select all

this is one of the checks - Oracle Query - Test Query
check_xi_oraclequery!--connect 'SERVERIP:1521/ORCL' --username 'USER' --password 'PASSWORD' --mode sql --name="select count(*) from v\$session where status = "active"" --warning 50 --critical 200
and the output is:
CRITICAL - cannot connect to SERVERIP:1521/ORCL. ORA-12514: TNS:listener does not currently know of service requested in connect descriptor (DBD ERROR: OCIServerAttach)
Now i can try directly from CLI in nagios server:

Code: Select all

/usr/local/nagios/libexec/check_oracle_health --connect 'SERVERIP:1521/ORCL' --username 'USER' --password 'PASSWORD' --mode tablespace-can-allocate-next --warning 20 --critical 30
output:
CRITICAL - cannot connect to SERVERIP:1521/ORCL. ORA-12514: TNS:listener does not currently know of service requested in connect descriptor (DBD ERROR: OCIServerAttach)
I didn't see any check "check_xi_oraclequery" in libexec directory. I've tried all the oracle wizard templates, i'm getting the same output.

thanks
Cristi

Re: error"TNS:listener was not given the SERVICE_NAME"

Posted: Thu Apr 28, 2016 2:57 pm
by tgriep
In your sqlplus command, you have the SID defined as sid but the check_oracle_health, you are using ORCL, which one is the correct one?
Also, if there is a tnsnames.ora file on your system that isn't configured correctly, that could cause the issue too.
Run this to find out if and or where that file is located.

Code: Select all

find / -name tnsnames.ora

Re: error"TNS:listener was not given the SERVICE_NAME"

Posted: Fri Apr 29, 2016 3:15 am
by ghostzy
Hi Tgriep, i've replaced on pourpose the name, it's ORCL, here is the input and output:

Code: Select all

sqlplus "USER/PASSWORD@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=SERVERIP)(Port=1521))(CONNECT_DATA=(SID=ORCL)))"

Code: Select all

SQL*Plus: Release 12.1.0.2.0 Production on Fri Apr 29 10:56:52 2016
Copyright (c) 1982, 2014, Oracle.  All rights reserved.
ERROR:
ORA-00942: table or view does not exist
Error accessing PRODUCT_USER_PROFILE
Warning:  Product user profile information not loaded!
You may need to run PUPBLD.SQL as SYSTEM
Last Successful login time: Fri Apr 29 2016 11:55:42 +03:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
About tnsnames.ora i'm a little bit confused, more exactly don't know if i should have this set in nagios host or DB host. On the oracle DB server there nothing set ...the only files are those from sample folder. Now, with a little help from a friend he pointed me to :
https://docs.oracle.com/database/121/LA ... #LACLI1391
He suggested i should export "TNS_ADMIN" with a path for tnsnames.ora on the nagios host with the db server values.
my exports in /etc/profile.d/ora.sh :

Code: Select all

export ORACLE_HOME=/usr/lib/oracle/12.1/client64
export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib/
export PATH=$PATH:/usr/lib/oracle/12.1/client64/bin
export TNS_ADMIN=/usr/share/oracle/12.1/client64/admin/tnsnames.ora

Re: error"TNS:listener was not given the SERVICE_NAME"

Posted: Fri Apr 29, 2016 9:21 am
by tgriep
On my system, I do not have a tnsnames.ora file and I can connect to our Oracle Server without any problems.
I think if the Oracle Instant client finds a tnsnames.ora file it uses that file and if it is not configured, it could cause errors.
Try adding the entries for your server in it or just remove it and see if that helps out.

Also, are you receiving any errors on the Oracle Server?

Another thing to try is to downgrade the Oracle Instant Client to 11.2, I have heard that there are issues with the 12.1 version causing problems.