写了一个perl脚本统计数据库alert日志中各种ora错误出现的次数,并按出现的次数排行:
#######################################################################
#统计alert日志文件中的ora错误数目并按数目排行
#######################################################################
#!/usr/bin/perl -w
use strict;
my (%oracodes,$alert);
print "input alertlog name including path:\n";
$alert=
chomp $alert;
open(ALERTLOG,$alert)|| die "Cannot open alert log:$!";
while(
my ($oraerrorstr,@oracodestr,$oracode);
next if(index($_,"ORA-")==-1);
$oraerrorstr=substr($_,index($_,"ORA-"));
#print $oraerrorstr,"\n";
@oracodestr=split(/\s+/,$oraerrorstr);
$oracode=$oracodestr[0];
$oracode=~s/[:)]//;
#print $oracode,"\n";
if(exists $oracodes{$oracode}){
$oracodes{$oracode}++;
}else{
$oracodes{$oracode}=1;
}
}
close(ALERTLOG);
foreach(sort {$oracodes{$a}<=>$oracodes{$b}} keys %oracodes){
print "$_ $oracodes{$_}\n";
}
下面是对一个alert日志进行统计的结果:
/opt/oracle/admin/dev1/bdump/alert_1.log
ORA-02019 1
ORA-00604 1
ORA-1100 1
ORA-27037 1
ORA-1990 1
ORA-1156 1
ORA-3214 1
ORA-00236 1
ORA-00060 1
ORA-00202 1
ORA-205 1
ORA-00603 2
ORA-08103 3
ORA-1109 3
ORA-1507 5
ORA-01555 10
ORA-00600 24
ORA-07445 46
ORA-20001 100
通过对统计的结果中出现次数较多的ora错误进行分析,并看是否有好的办法进行解决和避免,可以让数据库以更健康的状态运行。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/21805468/viewspace-622300/ ,如需转载,请注明出处,否则将追究法律责任。