Solved

How to log TNSPING every 15 minutes

Posted on 2014-01-22
9
959 Views
Last Modified: 2014-04-10
Hi,
I have an application server which holds an webapp and it talks to Oracle database server. I want to use tnsping and log it. How can we do it? Are there any tools to do this?

Thanks,
Ravi
0
Comment
9 Comments
 
LVL 1

Accepted Solution

by:
Qwadrat4 earned 50 total points
ID: 39802173
You can use batch file on windows or shell script on unix and run with scheduler or cron:
tnsping your_ORACLE_SID >> log.txt

Open in new window

0
 
LVL 76

Expert Comment

by:slightwv (䄆 Netminder)
ID: 39802916
The above post will work to capture the output of the tnsping.

My question is:
What are you wanting to guarantee with the tnsping?

All tnsping does is talk to the listener and see that it is listening for that SID/SERVICE.

The instance can be down and tnsping can still show OK.

If you are wanting to ensure the instance is up you will actually need to connect and select something like: select sysdate from dual;

Possible a better option is to have the database actually email you from a stored procedure.
0
 
LVL 13

Assisted Solution

by:Alexander Eßer [Alex140181]
Alexander Eßer [Alex140181] earned 50 total points
ID: 39802930
Possible a better option is to have the database actually email you from a stored procedure.
This could be done periodically via dbms_job ("old style") or scheduler.

But I'd prefer the OS version, like sqlplus with "select 1 from dual"...
0
 

Author Comment

by:Ravi Kiran Reddy Katkuri
ID: 39828557
Hi,
But the issue is Database is not in our environment and we dont have control on it. Can we use sqlplus to connect and log it to some output files. Then we can use nagios to monitor the log files.

Thanks,
Ravi
0
 
LVL 76

Assisted Solution

by:slightwv (䄆 Netminder)
slightwv (䄆 Netminder) earned 50 total points
ID: 39828628
>>Can we use sqlplus to connect and log it to some output files.

Yes.

What OS?

If a flavor of Unix, you can use a HERE script and do everything in 1 file.  There a re a LOT of examples on the Internet about reading output from sqlplus in a shell script.

In Windows, it is common to use two files.  Once .sql script that does the select and possibly spooled output and a CMD/BAT script to run sqlplus.

Again, a lot of examples out there.

A quick and dirty:

create q.sql:
set pages 0
spool q.out
select sysdate from dual;
spool off

Open in new window


create q.bat:
sqlplus user/password @q.sql

Open in new window


The the result will be in q.out.  You just need to parse the file for the correct value.  Sorry, I don't have one of those readily available.

I prefer sysdate instead of '1' just in case you want to parse the date for the 'correct' value.  Or the CMD file could just delete the spooled file.

It is all up to you for what you want to do.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

Working with Network Access Control Lists in Oracle 11g (part 2) Part 1: http://www.e-e.com/A_8429.html Previously, I introduced the basics of network ACL's including how to create, delete and modify entries to allow and deny access.  For many…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
This video shows how to copy a database user from one database to another user DBMS_METADATA.  It also shows how to copy a user's permissions and discusses password hash differences between Oracle 10g and 11g.
Via a live example, show how to take different types of Oracle backups using RMAN.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now