comparison time.pl @ 0:54da0bd509b0

commit
author pitagora <ryota.yamanaka@riken.jp>
date Tue, 31 Mar 2015 03:21:33 +0900
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:54da0bd509b0
1 use Time::Local 'timegm';
2 use POSIX 'strftime';
3
4 my $file = "/home/galaxy/galaxy-dist/paster.log";
5 open(my $fh, "<", $file)
6 or die "Cannot open $file: $!";
7
8 my %dic_sta;
9 my %dic_end;
10
11 while (my $line = readline $fh) {
12 if ($line =~ /([0-9]+)-([0-9]+)-([0-9]+) ([0-9]+):([0-9]+):([0-9]+),[0-9]+ \(([0-9]+)\) Job dispatched/) {
13 #print $line;
14 $sec_sta = timegm($6, $5, $4, $3, $2 - 1, $1);
15 $dic_sta{$7} = $sec_sta;
16 }
17 if ($line =~ /galaxy.jobs DEBUG ([0-9]+)-([0-9]+)-([0-9]+) ([0-9]+):([0-9]+):([0-9]+),[0-9]+ job ([0-9]+) ended/) {
18 #print $line;
19 $sec_end = timegm($6, $5, $4, $3, $2 - 1, $1);
20 $dic_end{$7} = $sec_end;
21 }
22 }
23
24 foreach (sort {$b<=>$a} keys %dic_sta) {
25 $time_sta = $dic_sta{$_};
26 $time_end = $dic_end{$_};
27 print "Dataset ", $_, "\t", strftime("%Y-%m-%d %H:%M:%S", localtime($time_sta)), "\t";
28 if ($time_end != "") {
29 $total = $time_end - $time_sta;
30 $hour = int($total/60/60);
31 $min = int(($total - $hour*60*60)/60);
32 $sec = $total - $hour*60*60 - $min*60;
33 print strftime("%Y-%m-%d %H:%M:%S", localtime($time_end)), "\t", $hour, " hour\t", $min, " min\t", $sec, " sec\n";
34 } else {
35 print "Running or aborted.\t-\t-\t-\n";
36 }
37 }