Script to collect log files in case of server crash


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script to collect log files in case of server crash
# 1  
Old 08-30-2013
HP Script to collect log files in case of server crash

Environmnet: HP-UX B.11.31 U ia64
RDBMS: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production

Question:

When server hangs or node evicts, we open up tickets with Oracle Support and Oracle Support ask for some list of log files.

Currently we can not use the TFA(trace file analyzer) tool/script.

We like to automate the log from following location;

Clusterware related:
1.CRS logs from $ORA_CRS_HOME/log/<hostname>/crsd/
2.CSS logs from $ORA_CRS_HOME/log/<hostname>/cssd/
3.CRS alert<nodename>.log present from the $ORA_CRS_HOME/log/<hostname>

OS related
4.OS log /var/adm/syslog/syslog.log
5. OSWatcher logs from all nodes

DB related
6. DB alert.log and all trace files from bdump & udump directories generated at time of problem
7. If ASM from use same information from it is needed


Please review and advise on the script.

Code:
#!/bin/ksh

HOST_NAME=`hostname -a`
export ORACLE_SID=+ASM1
export ORACLE_BASE=/app/oracle
export ORACLE_HOME=${ORACLE_BASE}/product/11.2.0.3/db
export PATH=$ORACLE_HOME/bin:$PATH
export TRACE_LOG=/exports/crs_trace.log
export ADR_HOME=/u01/oracle/admin/diag/rdbms/orcl/orcl
export ORA_CRS_HOME=/app/grid/product/11.2.0.3
export PATH=${PATH}:${ORACLE_HOME}/bin:${ORA_CRS_HOME}/bin
srcdir="/app/oracle/product/osw/archive"
dstdir="/exports"
d=$(date +%m%d%y)

for srcfile in ${srcdir}/*
do
    dstfile=$(basename $srcfile)
    dstfile=${dstfile/\./${d}\.}
    cp $srcfile $dstdir/$dstfile
done
cd /exports
$ORA_CRS_HOME/bin/diagcollection.pl --collect --adr --aftertime $1 >$TRACE_LOG
exit


Last edited by Scott; 08-30-2013 at 10:30 AM.. Reason: Removed FONT tags from within CODE tags
# 2  
Old 08-30-2013
Why, do the logs get truncated or lack restart headers?
# 3  
Old 08-30-2013
I would improve
Code:
cd /exports

by
Code:
cd "$dstdir" &&

I.e. the following command is only run if the cd was successful.

Further I am not used to the construct in your for loop, and would use simple shell code instead:
Code:
( # do the cd in a sub shell
if cd "$srcdir"
then
 for srcfile in *
  do
    [ -f "$srcfile" ] &&
    cp "$srcfile" "$dstdir/$srcfile.$d"
  done
fi
) # return from the sub shell = recover from the cd

At least have each $variable in quotes when used in command arguments!
--
If you need additional debugging tools, like tusc/truss and tcpdump:
simply download them from hpux.connect.org.uk. Do not forget to also download the run-time-dependent packages (e.g. libpcap and openssl are required by tcpdump).
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Collect files for specific hours

I have to fetch files from a location hour wise. Eg files available at location /tmp/data/ are A20140205.1300-1315...... . . A20140205.1400-1415...... . . A20140205.1700-1715...... . . . . Below is the code I have prepared. But it works only for one hour. For instance... (1 Reply)
Discussion started by: Saidul
1 Replies

2. Shell Programming and Scripting

Case script to get missing sequence among files

I want to use case statement to find the range of missing sequence in my directory which it has some few ( dat & DAT ) files my directory /home/arm/my_folder/20130428 contains : f01_201304280000.DAT f01_201304280001.DAT f01_201304280003.DAT f02_201304280000.dat f02_201304280002.dat... (2 Replies)
Discussion started by: arm
2 Replies

3. UNIX for Advanced & Expert Users

Collect files from different servers to a single server and append them

Hi, I have script1.sh on 3 servers. I want to collect output report generated by them to a single server and append all the reports. Please tell me how can i do this? (2 Replies)
Discussion started by: pratikm23
2 Replies

4. UNIX Desktop Questions & Answers

collect data from files

there are 200 files named file1_0.pdb,file1_60.pdb etc....it looks like: ATOM 1 N VAL 1 8.897 -21.545 -7.276 1.00 0.00 ATOM 2 H1 VAL 1 9.692 -22.015 -6.868 1.00 0.00 ATOM 3 H2 VAL 1 9.228 -20.766 -7.827 1.00 0.00 ATOM 4 H3 ... (5 Replies)
Discussion started by: kanikasharma
5 Replies

5. SCO

Crash error on my unix server

Hi there. Well i have a really bad problem with my server: UnixWare Version 5 Release 7 The system crash :wall: and show the error: Panic: Kernel-mode address fault on user address 0x00000004 :eek: If anyone knows about the reason of this error please give me a help Sorry by my english.... (3 Replies)
Discussion started by: danilosevilla
3 Replies

6. Shell Programming and Scripting

How to collect all the list of files along with the permissions

Hi guys, I have one problem. I need collect the list files along with the file permissions in all directories in one server. Is their any easy way to collect using any commands or any scripts? Advance Thanks :) (2 Replies)
Discussion started by: kartheek
2 Replies

7. UNIX for Advanced & Expert Users

Solaris Server Crash

We have had a server (Solaris 2.6) hardisk crash. When booting the server we get: ok> boot -S Boot Device: /sbus/espdmc@e, 8400000/esp@e,8800000/sd@0,0 short read 0x2000 chars read disk read error The only way we can get into the console is to ok> boot cdrom whereby everything (e.g.... (3 Replies)
Discussion started by: Breen
3 Replies

8. UNIX for Dummies Questions & Answers

server crash

Our SUn Solaris Server has crashed second time in 2 days, reason is not known , we are trying to determine what could have gone wrong, any ideas, the power supply seems to be fine, there is no response from keyboard,monitor etc and we had to do a hot boot yesterday.. Any suggestions what could be... (9 Replies)
Discussion started by: knarayan
9 Replies

9. UNIX for Advanced & Expert Users

linux server crash

Hi I faced a problem while booting linux which is as follows;- ************************************************* Inode 146180 has illegal block(s) xauth:error in locking authority file /home/root/.Xauthority Fatal Server Error: Could not create lock file in /tmp/tXo-lock ... (1 Reply)
Discussion started by: Abhishek
1 Replies
Login or Register to Ask a Question