<pre name="code" class="sql">#!/usr/bin/perl
while (1==1){
$dir='/root/log';
$file_tmp = `cd $dir; ls -ltr logs.log* | tail -1 `;
$file = (split/s+/,"$file_tmp")[8];
$mon_file="$dir/$file",
print "$mon_file is $mon_file
";
open (C,"<","$file.tmp");
while (<C>){
$count = $_;
}
print "$count is $count
";
$info =`tac $mon_file | grep excep | head -1`;
open (A ,"<","$mon_file") || die "$!
";
$i=0;
while (<A>) {
if ( $_ =~/exception/i){$i++};
}
if ($i > $count) {print "error--$info
";};
open (B,">","$file.tmp");
print B ("$i
");
sleep (10);
}