troubleshooting Question

catch connection oracle failed and write it in csv file

Avatar of bibi92
bibi92Flag for France asked on
Linux* ShellOracle DatabaseUnix OS
3 Comments1 Solution12 ViewsLast Modified:
Hello,
If connection to a database is not possible I add to catch and write the line below but how is it possible in below shell script:
"US","Hostname","","","","","","","connection failed","date"


#!/bin/sh
for BASE in $(ps -ef | grep pmon | grep -v "grep" |  awk -F "pmon_"  '{print$2}')
do
export ORACLE_SID=$BASE
. oraenv $BASE
${ORACLE_HOME}/bin/sqlplus -S / as sysdba << !
SET TERMOUT OFF
SET VERIFY OFF


select '"'||'US'||'"'||','||'"'||SYS_CONTEXT('USERENV','HOST') ||'"'||','||'"'||instance_name||'"'||','||'"'||u.username||'"'||','||'"'||u.PROFILE||'"'||','||'"'||p.limit||'"'||','||'"' ||sysdate||'"'  from dba_users u, dba_profiles p, v\$instance, dual where u.profile=p.profile;


!
done

Open in new window

Thank you

regards 
ASKER CERTIFIED SOLUTION
Join our community to see this answer!
Unlock 1 Answer and 3 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 3 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros