-
Notifications
You must be signed in to change notification settings - Fork 0
/
getQueueValueFromActivemq.pl
64 lines (56 loc) · 1.26 KB
/
getQueueValueFromActivemq.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/perl -w
use strict;
require 5.6.0;
use LWP::Simple;
use LWP::UserAgent;
my $address = "xx.xx.xx.xx";
my $port = "8163";
my $username = "xxxxx";
my $pass = "xxxxxx";
my $browser = LWP::UserAgent->new;
my $req = HTTP::Request->new( GET => "http://$address:$port/admin/xml/queues.jsp");
$req->authorization_basic( "$username", "$pass" );
my $page = $browser->request( $req );
my (%args, %queues);
my ( $tmp, $switch, $queueselect, $queuevalue);
my $key = my $value = my $i = my $k = 0;
my $num_args = "1";
# main();
$num_args = $#ARGV + 1;
if ($num_args != 1) {
print "\nUsage: getCountForQueue.pl <Queue_Name>\n";
exit -1;
}
$queueselect=$ARGV[0];
&getinfo;
$queuevalue=-1;
foreach my $str (keys %queues){
if($queueselect eq $str){
$queuevalue = $queues{$queueselect};
last; }
else {
next; }
}
print $queuevalue;
exit;
# Subroutines
sub getinfo {
my @lines = split ' ', $page->content();
foreach my $line (@lines){
if($line =~ /name/i || $line =~ /size/i){
$line =~ s/^name="//g;
$line =~ s/^size="//g;
$line =~ s/"(>)?$//g;
#print "line ".${line} ;
if($i == 1){
#print "line ".${line} ;
$queues{$tmp} = $line;
$i = 0;
}
else{
$tmp = $line;
$i++;
}
}
}
}