Perl 监控批量错误

前端之家收集整理的这篇文章主要介绍了Perl 监控批量错误前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
<pre name="code" class="sql">#!/usr/bin/perl 
$dir='/home/websphere/WebSphere/AppServer/profiles/AppSrv01/logs/server1';
$file = 'SystemErr.log';
$mon_file="$dir/$file";
print "\$mon_file is $mon_file\n";
@warn_arr = qw/连接已关闭 NullPointException IndexOutOfBound/;
foreach $a  (@warn_arr){
   open (C,"<","$a.tmp")  ;
       
              $count  = <C>;   
                        
        print "\$count is $count\n";   
                                       
        $info =`tac $mon_file  |  grep "$a" | head -1`;   
                                                   
        open (A,"$mon_file") || die "$!\n";   
$i=0;
        while (<A>) {   
 if ($_ =~ /$a/i){$i++};
                    };   
 if ($i !=0 && $i != $count && defined($count)) {print "error--$info\n";};
   open (B,">","$a.tmp");   
   print B ("$i\n"); 

};
 

猜你在找的Perl相关文章