Test if Oracle listener is running | Unix Linux Forums | Infrastructure Monitoring

  Go Back    


Infrastructure Monitoring Forum for Nagios, Zabbix and other network monitoring and management tools.

Test if Oracle listener is running

Infrastructure Monitoring


Closed Thread    
 
Thread Tools Search this Thread Display Modes
    #1  
Old 06-15-2010
abdul bari abdul bari is offline
Registered User
 
Join Date: Jul 2008
Last Activity: 25 November 2010, 4:20 AM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Test if Oracle listener is running

Hi All ,

I am new to shall scripting, i want write an script for oracle tns and listener.

If tns working i want o/p as "Listener and TNS are working"
else o/p should be ""Listener and TNS are not Working"

below is the command in unix to check the tns status, if no output it means TNS is working fine otherwise there TNS or Listener are not working.

Can anybody help to achieve this.

Thanks in Advance.
Sponsored Links
    #2  
Old 06-15-2010
anbu23's Avatar
anbu23 anbu23 is offline Forum Advisor  
Advisor
 
Join Date: Mar 2006
Last Activity: 31 July 2014, 8:46 AM EDT
Location: Bangalore,India
Posts: 2,089
Thanks: 12
Thanked 131 Times in 126 Posts

Code:
if [ -z "$(Your_TNS_Cmd)" ]; then echo "Listener and TNS are working"; else echo "Listener and TNS are not working"; fi

Sponsored Links
    #3  
Old 06-15-2010
abdul bari abdul bari is offline
Registered User
 
Join Date: Jul 2008
Last Activity: 25 November 2010, 4:20 AM EST
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
The script looks like below.


Code:
if [ -z "$tnsping ora_tns_name |grep TNS- "]; then
        echo "Listener and TNS are working";
else
echo "Listener and TNS are not working";
fi

if tns is working value of "$tnsping ora_tns_name |grep TNS- " is null ( i mean no o/p).

otherwise it gives some value.

can you suggest how to proceed with the above if condition.

Thanks again.

Last edited by Scott; 06-15-2010 at 12:45 PM.. Reason: Please use code tags
    #4  
Old 06-15-2010
Scott's Avatar
Scott Scott is offline Forum Staff  
Administrator
 
Join Date: Jun 2009
Last Activity: 27 August 2014, 3:40 PM EDT
Location: Zürich
Posts: 8,473
Thanks: 330
Thanked 1,046 Times in 913 Posts
Hi.

I may be wrong, but tnsping output will never be "null".

IMO, the answer that jim mcnamara gave, which he has since deleted, was the correct answer.

You should test the result of the tnsping command, not necessarily the output.


Code:
# Listener not running...
/home/oracle > tnsping db1

TNS Ping Utility for Linux: Version 10.2.0.3.0 - Production on 15-JUN-2010 17:08:51

Copyright (c) 1997, 2006, Oracle.  All rights reserved.

Used parameter files:
/u01/app/oracle/product/10.2/db_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = DB1)))
TNS-12541: TNS:no listener
/home/oracle > echo $?
1


# Start listener
/home/oracle > lsnrctl start

LSNRCTL for Linux: Version 10.2.0.3.0 - Production on 15-JUN-2010 17:08:59

Copyright (c) 1991, 2006, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/10.2/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 10.2.0.3.0 - Production
System parameter file is /u01/app/oracle/product/10.2/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/product/10.2/db_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 10.2.0.3.0 - Production
Start Date                15-JUN-2010 17:08:59
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/10.2/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/product/10.2/db_1/network/log/listener.log
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC0)))
Services Summary...
Service "DB1" has 1 instance(s).
  Instance "DB1", status UNKNOWN, has 1 handler(s) for this service...
Service "PLSExtProc" has 1 instance(s).
  Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

# Listener running
/home/oracle > tnsping db1  

TNS Ping Utility for Linux: Version 10.2.0.3.0 - Production on 15-JUN-2010 17:09:04

Copyright (c) 1997, 2006, Oracle.  All rights reserved.

Used parameter files:
/u01/app/oracle/product/10.2/db_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = DB1)))
OK (10 msec)
/home/oracle > echo $?      
0

So...

Code:
if tnsping db1 > /dev/null; then
  echo Listener running
else
  echo Listener not running
fi

This says absolutely nothing about whether any database is actually running!


edit: I've renamed your thread from if else question in unix to Test if Oracle listener is running (which may not be a perfect title, but at least other forum members who know about Oracle will see it, and may offer better help )

Last edited by Scott; 06-15-2010 at 01:54 PM..
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Oracle - How to manage listener log files yhcheong UNIX and Linux Applications 1 01-15-2010 05:50 AM
make test fails for DBD::Oracle installation pstrosnyder UNIX for Advanced & Expert Users 1 01-07-2009 11:38 AM
A question/problem about oracle "tns listener" and "enterprise manager" talipk UNIX for Advanced & Expert Users 1 12-03-2008 06:55 AM
A question/problem about oracle "tns listener" and "enterprise manager" talipk UNIX and Linux Applications 0 12-01-2008 02:08 PM
running test skooly5 Linux 2 04-07-2008 12:22 PM



All times are GMT -4. The time now is 07:01 PM.