line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# $Id$ |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Queue::Q4M::Status; |
4
|
3
|
|
|
3
|
|
19
|
use strict; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
133
|
|
5
|
3
|
|
|
3
|
|
24
|
use DBI; |
|
3
|
|
|
|
|
11
|
|
|
3
|
|
|
|
|
235
|
|
6
|
3
|
|
|
3
|
|
19
|
use Carp(); |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
307
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
sub fetch { |
9
|
|
|
|
|
|
|
# Black magic. Since I don't know if the parameters will be the same |
10
|
|
|
|
|
|
|
# for every future release of Q4M, I'll just create a cached |
11
|
|
|
|
|
|
|
# anonymous class via moose. Wicked! |
12
|
|
|
|
|
|
|
|
13
|
0
|
|
|
0
|
1
|
|
my $class = shift; |
14
|
0
|
|
0
|
|
|
|
my $dbh = shift || Carp::confess("Q4M requires a database handle"); |
15
|
|
|
|
|
|
|
|
16
|
0
|
|
|
|
|
|
my $sth = $dbh->prepare( "SHOW ENGINE QUEUE STATUS" ); |
17
|
|
|
|
|
|
|
|
18
|
0
|
|
|
|
|
|
$sth->execute(); |
19
|
0
|
|
|
|
|
|
my %attributes; |
20
|
|
|
|
|
|
|
|
21
|
0
|
|
|
|
|
|
my ($dummy1, $dummy2, $status); |
22
|
0
|
|
|
|
|
|
$sth->bind_columns(\($dummy1, $dummy2, $status)); |
23
|
0
|
|
|
|
|
|
$sth->fetchrow_arrayref; |
24
|
0
|
|
|
|
|
|
$sth->finish; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
# now parse the status |
27
|
3
|
|
|
3
|
|
17
|
{ no strict 'refs'; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
3807
|
|
|
0
|
|
|
|
|
|
|
28
|
0
|
|
|
|
|
|
foreach my $line (split(/\r?\n/, $status)) { |
29
|
0
|
0
|
|
|
|
|
next unless $line =~ /^([\w_]+)\s+(\d+)$/; |
30
|
|
|
|
|
|
|
|
31
|
0
|
|
|
|
|
|
my ($name, $value) = ($1, $2); |
32
|
0
|
0
|
|
|
|
|
if (! defined &{$class.'::'.$name}) { |
|
0
|
|
|
|
|
|
|
33
|
0
|
|
|
0
|
|
|
*{$class.'::'.$name} = sub { shift->{$name} }; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
} |
35
|
0
|
|
|
|
|
|
$attributes{$1} = $2; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
} |
38
|
0
|
|
|
|
|
|
return bless {%attributes}, $class; |
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
1; |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
__END__ |