пятница, 16 августа 2013 г.

ADRCI usage examples

Usage example 1:
[oracle@host ~]$ adrci
adrci> show homes
set home diag/rdbms/orcl/orcl
# Output with enter to editor
show alert -p "ORIGINATING_TIMESTAMP >= '2014-02-24 00:00:00'"
# Output to termnal without enter to editor
show alert -p "ORIGINATING_TIMESTAMP >= '2014-02-24 00:00:00'" -term
# Show all 'ORA-%' and 'TNS-%' messages
show alert -p "ORIGINATING_TIMESTAMP >= '2014-02-24 00:00:00' AND (MESSAGE_TEXT LIKE '%ORA-%' or MESSAGE_TEXT LIKE '%TNS-%')" -term
# Show all 'ORA-%' and 'TNS-%' messages with exclude from output specified
show alert -p "ORIGINATING_TIMESTAMP > '2013-08-16 00:00:00' AND (MESSAGE_TEXT LIKE '%ORA-%' or MESSAGE_TEXT LIKE '%TNS-%') AND (MESSAGE_TEXT NOT LIKE '%TNS-12502%' AND MESSAGE_TEXT NOT LIKE '%TNS-12537%' AND MESSAGE_TEXT NOT LIKE '%ORA-609%')" -term
show alert -tail -f
exit
Usage example 2:
[oracle@host ~]$ adrci
adrci> show homes
set home diag/rdbms/orcl/orcl
show alert -tail -f
exit
Incident & Problem
adrci>
show problem
show incident
show incident -mode detail -p "incident_id=6201"
show trace /u01/app/oracle/diag/rdbms/orcl/orcl/incident/incdir_6201/orcl_ora_2299_i6201.trc
Creation of Packages & ZIP files to send to Oracle Support
adrci>
ips create package problem 1 correlate all
ips generate package 2 in "/home/oracle"
Managing, especially purging of tracefiles
adrci>
show tracefile -rt
show control
set control (SHORTP_POLICY = 360)
set control (LONGP_POLICY = 2190)
show control

# Purge tracefiles manually
purge -age 2880 -type trace
show tracefile -rt

# Purge log directories for listener ADRCI Home
for i in `adrci exec="show homes"|grep listener`;do
# Purge ADRCI Homes log directories older 60 days ago
#for i in `adrci exec="show homes"|sed '1d'`;do
  du -hs $ORACLE_BASE/$i | sort -rh
  du -hs $ORACLE_BASE/$i/* | sort -rh
  du -hs $ORACLE_BASE/$i/trace | sort -rh

  # Purge listener log directory older 60 days ago
  # (60 days * 24h * 60 mins = 86400 mins)
  # -age  - The data older than  ago will be purged
  echo "adrci exec=\"set home $i;purge -age 86400\""
  adrci exec="set home $i;purge -age 86400";
  adrci exec="set home $i;show control;set control \(SHORTP_POLICY = 180\);set control \(LONGP_POLICY = 720\);show control";

  du -hs $ORACLE_BASE/$i | sort -rh
  du -hs $ORACLE_BASE/$i/* | sort -rh
  du -hs $ORACLE_BASE/$i/trace | sort -rh
done

# Check ADRCI Homes policy
for i in `adrci exec="show homes"|sed '1d'`;do
  adrci exec="set home $i;show control;";
done

# Set ADRCI Homes policy
for i in `adrci exec="show homes"|sed '1d'`;do
  adrci exec="set home $i;show control;set control \(SHORTP_POLICY = 180\);set control \(LONGP_POLICY = 720\);show control";
done