annotate time.pl @ 0:54da0bd509b0

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