- 论坛徽章:
- 0
|
请教perl脚本内如何更改才能在输出结果中过滤掉orig的效果
#!/usr/bin/perl
# 监控FIS往IMP传生产状态数据是否正常运行
#
$ENV{XPG_UNIX98}="ON";
#require "zp8.pl";
#use strict;
use File::stat;
use Time::Local;
my(%fields);
my($sec, $min, $hour, $mday, $mon, $year) = (localtime(time))[0..5];
my(@listadelogs);
my(@conteudo);
$mon = zeroFill($mon, 2);
$mon = $mon + 1;
$mon = zeroFill($mon, 2);
$mday = zeroFill($mday, 2);
$year = $year + 1900;
$hour = zeroFill($hour, 2);
$min = zeroFill($min, 2);
$sec = zeroFill($sec, 2);
my($DAY_FROM) = $mday;
my($MON_FROM) = $mon;
my($YEA_FROM) = $year;
my($HOR_FROM) = $hour;
my($DAY_TO) = $mday;
my($MON_TO) = $mon;
my($YEA_TO) = $year;
my($HOR_TO) = $hour;
$DATE1 ="$MON_TO/$DAY_TO/$YEA_TO $hour min sec";
listalogs(\%fields,$diference);
displayPage();
exit(0);
sub listalogs {
my($hashref) = shift;
my($difref) = shift;
$hostname = 'l79fis24';
$hostname2 = 'l79fis81';
$rows=$hashref->{'rows'};
$str_search = $hashref->{'search'};
$str_search =~ s!%20! !g;
@listadelogs5 = `rsh l79fis81 -l ufhread ls -tl /ap/os/oscom06/exchange/imp*`;
##@listadelogs3 = `rsh l79fis81 -l ufhread ls -tl /ap/os/oscom06/exchange |grep -e "JIT_SAP_INTERFACE"`;
}
sub displayPage {
#l79fis81---EXPSTT
if ( @listadelogs5 == 0 )
{
$number = 1;
}
else
{
$number = 1;
foreach(@listadelogs5){
$flag = $number % 2;
$filname = substr($_,45,12);
#print "filename substr: $filname\n";
$time1 = $filname;
#print "time1 is $time1\n";
$filepath = substr($_,58,57);
##$filepath = join("/","/ap/os/oscom06/exchange",$filepath);
chomp($filepath);
chomp($filname);
$para = compTimes($time1);
#print "para is : $para\n";
$substring = "orig";
if (index($filepath, $substring)>0){
print ("$number;$filepath;$filname;$para","\n" ;
}else{
print ("$number;$filepath;$filname;$para","\n" ;
}
$number++;
}
}
}
sub zeroFill {
my($temp) = shift;
my($len) = shift;
my($diff) = $len - length($temp);
return($temp) if $diff <= 0;
return(('0' x $diff) . $temp);
}
##====================================================================================
sub getMonths{
@months{qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec)} = (0..11);
$mon_cp1 = exists($months{$strmon}) ? $months{$strmon} : die "Bad month";
return $mon_cp1;
}
sub compTimes{
$now = localtime();
#print "localtime: $now\n";
($sec, $min, $hour, $mday, $mon, $year) = (localtime(time))[0..5];
$ltime = timelocal($sec, $min, $hour, $mday, $mon, $year);
#print "timelocal ltime: $year, $mon, $mday, $hour, $min, $sec\n";
#print "timelocal ltime: $ltime\n";
@array1 = split(/ /,$time1);
$strmon = $array1[0];
#print "time1 strmon: $strmon\n";
$mon1 = getMonths($strmon);
#print "time1 mon1: $mon1\n";
$mday1 = $array1[1];
#print "time1 day1: $mday1\n";
$t1 = $array1[2];
#print "time1 t1: $t1\n";
$year1, $hour1, $min1;
@ifarray = split(/:/, $t1);
$length = @ifarray;
#print "length: $length\n";
if(($t1=~m/:/) == 0){
$year1 = $t1;
$hour1 = 0;
$min1 = 0;
#print "time1 year1: $year1\n";
$year1 = $year1 - 1900;
#print "time1 gm year1: $year1\n";
} else {
$year1 = $year;
$hour1 = $ifarray[0];
$min1 = $ifarray[1];
#print "time1 year1: $year1\n";
}
$cptime = timelocal(00, $min1, $hour1, $mday1, $mon1, $year1);
#print "cptime: $cptime\n";
$comp = $ltime - $cptime;
#print "comptimes is $comp\n";
if($comp/60 >= 480){
return "light";
}elsif($comp/60 < 480){
return "ok";
}
}
脚本输出的结果如下图 |
|