| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# Schedule::SGE::Status |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# POD docs |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
=head1 Schedule::SGE::Status |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
Check on the status of the Schedule::SGE queues. You should not use this method directly, rather you should use the Schedule::SGE method that inherits from this, then all the methods herein are available to you. |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 AUTHOR |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
Rob Edwards (rob@salmonella.org) |
|
12
|
|
|
|
|
|
|
3/24/05 |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=cut |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package Schedule::SGE::Status; |
|
17
|
1
|
|
|
1
|
|
4
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
26
|
|
|
18
|
1
|
|
|
1
|
|
4
|
use Exporter; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
28
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
1
|
|
|
1
|
|
4
|
use vars qw(@ISA @EXPORT_OK); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
920
|
|
|
21
|
|
|
|
|
|
|
@ISA = qw(Schedule::SGE Exporter); |
|
22
|
|
|
|
|
|
|
@EXPORT_OK = qw(user status brief_job_stats all_jobs); |
|
23
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head2 user() |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Set the user of the processes. If not defined will be guess by whoami |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub user { |
|
32
|
0
|
|
|
0
|
1
|
|
my ($self, $user)=@_; |
|
33
|
0
|
0
|
|
|
|
|
$self->{'user'} = $user if ($user); |
|
34
|
0
|
0
|
|
|
|
|
unless ($self->{'user'}) { |
|
35
|
0
|
|
|
|
|
|
$self->{'user'}=`whoami`; |
|
36
|
0
|
|
|
|
|
|
chomp($self->{'user'}); |
|
37
|
|
|
|
|
|
|
} |
|
38
|
0
|
|
|
|
|
|
return $self->{'user'}; |
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head2 status() |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Get the queue status. This will return a hash where each key is the name of a node, and each value is a reference to an array. The array has the following components: |
|
44
|
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
0. Queue type (one of B(atch), I(nteractive), C(heckpointing), P(arallel), T(ransfer) or combinations thereof or N(one)) |
|
46
|
|
|
|
|
|
|
1. Processors used |
|
47
|
|
|
|
|
|
|
2. Load average |
|
48
|
|
|
|
|
|
|
3. State |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub status { |
|
53
|
0
|
|
|
0
|
1
|
|
my ($self)=@_; |
|
54
|
0
|
|
|
|
|
|
my $qstat=$self->executable('qstat'); |
|
55
|
0
|
|
|
|
|
|
my @status = `$qstat -f`; |
|
56
|
0
|
|
|
|
|
|
my $node; |
|
57
|
|
|
|
|
|
|
my $allstats; |
|
58
|
0
|
|
|
|
|
|
while (@status) { |
|
59
|
0
|
|
|
|
|
|
my $line=shift @status; |
|
60
|
0
|
|
|
|
|
|
chomp($line); |
|
61
|
0
|
0
|
|
|
|
|
next if ($line =~ /^\-/); |
|
62
|
0
|
0
|
|
|
|
|
next if ($line =~ /queuename/); |
|
63
|
0
|
0
|
0
|
|
|
|
next if (!$line || $line =~ /^\s*$/); |
|
64
|
0
|
0
|
0
|
|
|
|
if ($line =~ /^\S+/ && $line !~ /^\#/) { |
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# it is a node status |
|
66
|
0
|
|
|
|
|
|
my @pieces = split /\s+/, $line; |
|
67
|
0
|
|
|
|
|
|
$node=shift @pieces; |
|
68
|
0
|
|
|
|
|
|
my $type=shift @pieces; |
|
69
|
0
|
0
|
|
|
|
|
if ($type =~ /[^BICPTN]/) { |
|
70
|
0
|
|
|
|
|
|
die "Received type of $type from \n$line\n\tbut it should not contain anything other than B,I,C,P,T or N"; |
|
71
|
|
|
|
|
|
|
} |
|
72
|
0
|
|
|
|
|
|
my $procs=shift @pieces; |
|
73
|
0
|
0
|
|
|
|
|
if ($procs !~ m#\d+/\d+#) { |
|
74
|
0
|
|
|
|
|
|
die "Received procs of $procs from \n$line\n\tbut it should not contain anything other than \\d+/\\d+"; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
0
|
|
|
|
|
|
my ($load_avg, $arch, $states)= @pieces; |
|
77
|
0
|
0
|
0
|
|
|
|
if ($self->verbose && $states) {print STDERR "Node $node has state $states\n"} |
|
|
0
|
|
|
|
|
|
|
|
78
|
0
|
0
|
|
|
|
|
unless (defined $states) {$states=''} |
|
|
0
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
$allstats->{$node}=[$type, $procs, $load_avg, $states]; |
|
80
|
|
|
|
|
|
|
} |
|
81
|
|
|
|
|
|
|
elsif ($line =~ m#^\s+(\d+)\s+(\d+\.\d+)\s+(\S+.*?)\s+\S+\s+(\S+)\s+(\d+/\d+/\d+\s+\d+\:\d+\:\d+)\s+\S+#) { |
|
82
|
|
|
|
|
|
|
# it is a job |
|
83
|
|
|
|
|
|
|
# something like |
|
84
|
|
|
|
|
|
|
# 1441 0.56000 testing123 rob r 03/25/2005 11:59:12 1 |
|
85
|
0
|
|
|
|
|
|
my ($pid, $load, $name, $user, $date)=($1, $2, $3, $4, $5); |
|
86
|
0
|
|
|
|
|
|
$self->{'job'}->{$pid}=[$node, $pid, $load, $name, $user, $date]; |
|
87
|
|
|
|
|
|
|
} |
|
88
|
|
|
|
|
|
|
elsif ($line =~ /^\#/ || $line =~ /PENDING/) { |
|
89
|
|
|
|
|
|
|
# at the end of the list there are some pending jobs |
|
90
|
0
|
|
|
|
|
|
while (@status) { |
|
91
|
0
|
|
|
|
|
|
my $pend=shift(@status); |
|
92
|
0
|
0
|
0
|
|
|
|
next if ($pend =~ /PENDING/ || $pend =~ /^\#/); |
|
93
|
0
|
|
|
|
|
|
$pend =~ s/^\s+//; $pend =~ s/\s+$//; |
|
|
0
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
my @pieces=split /\s+/, $pend; |
|
95
|
0
|
0
|
|
|
|
|
next unless (scalar @pieces > 5); |
|
96
|
0
|
|
|
|
|
|
my ($user, $status, $date, $time, $processes)=splice(@pieces, -5, 5); |
|
97
|
0
|
|
|
|
|
|
my ($pid, $load)=splice(@pieces, 0, 2); |
|
98
|
0
|
|
|
|
|
|
$date .= " ".$time; |
|
99
|
0
|
|
|
|
|
|
my $name = join " ", @pieces; |
|
100
|
0
|
|
|
|
|
|
$self->{'job'}->{$pid}=['pending', $pid, $load, $name, $user, $date]; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
} |
|
103
|
|
|
|
|
|
|
else { |
|
104
|
0
|
|
|
|
|
|
print STDERR "We don't know how to parse |$line|\n"; |
|
105
|
|
|
|
|
|
|
} |
|
106
|
|
|
|
|
|
|
} |
|
107
|
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
|
|
109
|
0
|
|
|
|
|
|
return $allstats; |
|
110
|
|
|
|
|
|
|
} |
|
111
|
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 brief_job_stats() |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Get some brief statistics about a job. This method will return a reference to an array with the following statistics: |
|
116
|
|
|
|
|
|
|
Node the job is/was running on |
|
117
|
|
|
|
|
|
|
Process ID of the job |
|
118
|
|
|
|
|
|
|
Load |
|
119
|
|
|
|
|
|
|
Name of process |
|
120
|
|
|
|
|
|
|
Username |
|
121
|
|
|
|
|
|
|
Date and time of submission |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
for example, my $stats=$sge->brief_job_stats($job); |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub brief_job_stats { |
|
128
|
0
|
|
|
0
|
1
|
|
my ($self, $job)=@_; |
|
129
|
0
|
0
|
|
|
|
|
return [] if (!$job); |
|
130
|
0
|
0
|
|
|
|
|
return $self->{'job'}->{$job} if ($self->{'job'}->{$job}); |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# if we get this far, we should run status and quickly get the status |
|
133
|
0
|
|
|
|
|
|
$self->status(); |
|
134
|
0
|
0
|
|
|
|
|
if ($self->{'job'}->{$job}) { |
|
135
|
0
|
|
|
|
|
|
return $self->{'job'}->{$job}; |
|
136
|
|
|
|
|
|
|
} |
|
137
|
|
|
|
|
|
|
else { |
|
138
|
0
|
|
|
|
|
|
return []; |
|
139
|
|
|
|
|
|
|
} |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=head2 all_jobs() |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
Returns an array of all jobs that were found in the queues. |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=cut |
|
148
|
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub all_jobs { |
|
150
|
0
|
|
|
0
|
1
|
|
my ($self)=@_; |
|
151
|
0
|
0
|
|
|
|
|
unless ($self->{'job'}) {$self->status()} |
|
|
0
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
|
return keys %{$self->{'job'}}; |
|
|
0
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
} |
|
154
|
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
1; |