2 # Batch EXecutor 2.0 -- Show Queued Jobs
3 # (c) 2011 Martin Mares <mj@ucw.cz>
17 "h|by-host!" => \$by_host,
18 "q|queue=s" => \$queue_name,
20 Usage: bq [<options>] [[!]<machine-or-class> ...]
23 -h, --by-host Show jobs sorted by host (default: by job)
24 -q, --queue=<name> Show jobs in the given queue
27 my @machines = BEX::Config::parse_machine_list(@ARGV ? @ARGV : '*');
28 my $queue = BEX::Queue->new($queue_name);
34 for my $m (@machines) {
35 for my $j ($queue->scan($m)) {
36 push @{$jobs{$j}}, $m;
37 push @{$machs{$m}}, $j;
38 my $job = $queue->job_metadata($j);
39 $subj{$j} = ' (' . $job->{'Subject'} . ')';
40 my $st = $queue->read_job_status($m, $j);
41 if (defined($st->{'Time'}) && defined($st->{'Status'})) {
42 $stat{$m}{$j} = ' [' . $st->{'Status'} . ' on ' .
43 POSIX::strftime('%Y-%m-%d', localtime $st->{'Time'}) . ']';
51 for my $m (sort keys %machs) {
53 for my $j (@{$machs{$m}}) {
54 print "\t$j", $subj{$j}, $stat{$m}{$j}, "\n";
58 for my $j (sort keys %jobs) {
59 print $j, $subj{$j}, "\n";
60 for my $m (sort @{$jobs{$j}}) {
61 print "\t$m", $stat{$m}{$j}, "\n";