Difference between revisions of "Recent errors in database alert log"

From dbawiki
Jump to: navigation, search
(Created page with " #!/bin/ksh printf "Enter Destination File: " read dest files="/*/u??/oradata/$ORACLE_SID/oralogs -name alert_$ORACLE_SID.log" for file in $(find $files) do DT=$(date) ...")
 
Line 8: Line 8:
 
     awk '
 
     awk '
 
     BEGIN {Flg=0}
 
     BEGIN {Flg=0}
     NR==1 {R=split(DATE,TMP," ")
+
     NR==1 {
    Day=TMP[1]
+
        R=split(DATE,TMP," ")
    Month=TMP[2]
+
        Day=TMP[1]
    NoDay=TMP[3]}
+
        Month=TMP[2]
    {NoDayM=NoDay-1}
+
        NoDay=TMP[3]}
    NF==5 && $2==Month && ($3==(NoDayM) || $3==(NoDayM)) {Flg=1}
+
        {NoDayM=NoDay-1}
    Flg==1 {print $0}
+
        NF==5 && $2==Month && ($3==(NoDayM) || $3==(NoDayM)) {Flg=1}
    ' DATE="$DT" $file | awk '
+
        Flg==1 {print $0}
    /^ORA-/ || /cannot/ {print DATE print $0}
+
        ' DATE="$DT" $file | awk '
    NF==5 {DATE=$0}
+
        /^ORA-/ || /cannot/ {print DATE print $0}
 +
        NF==5 {DATE=$0
 +
    }
 
     ' >> $dest
 
     ' >> $dest
 
  done
 
  done
 
  exit 0
 
  exit 0

Revision as of 20:12, 6 December 2011

#!/bin/ksh
printf "Enter Destination File: "
read dest
files="/*/u??/oradata/$ORACLE_SID/oralogs -name alert_$ORACLE_SID.log"
for file in $(find $files)
do
    DT=$(date)
    awk '
    BEGIN {Flg=0}
    NR==1 {
        R=split(DATE,TMP," ")
        Day=TMP[1]
        Month=TMP[2]
        NoDay=TMP[3]}
        {NoDayM=NoDay-1}
        NF==5 && $2==Month && ($3==(NoDayM) || $3==(NoDayM)) {Flg=1}
        Flg==1 {print $0}
        ' DATE="$DT" $file | awk '
        /^ORA-/ || /cannot/ {print DATE print $0}
        NF==5 {DATE=$0
    }
    ' >> $dest
done
exit 0