#!/usr/bin/perl -w
main: {
my
(
$broker_name
,
$broker_host
);
(
$broker_name
,
$broker_host
) =
split
( /\@/,
$ARGV
[0] )
if
(
@ARGV
);
$broker_host
||=
"localhost"
;
$broker_name
||=
""
;
my
$client_group
=
"admin"
;
my
$c
= new Aw::Admin::Client (
$broker_host
,
$broker_name
,
""
,
$client_group
,
"Client Finger"
)
||
die
"Error connecting to broker.\n"
;
foreach
(
$c
->getClientIds ) {
my
$info
=
$c
->getClientInfoById (
$_
);
my
%stats
=
$c
->getClientStatsById (
$_
)->toHash;
my
@subs
=
$c
->getClientSubscriptionsById (
$_
);
print
"$_\n"
;
foreach
(
sort
keys
%$info
) {
if
( /^sessions/ ) {
next
unless
(
$info
->{num_sessions} );
my
$sessions
=
$info
->{sessions};
print
" sessions[$info->{num_sessions}] {\n"
;
my
$i
= 0;
foreach
(@{
$sessions
}) {
print
" session["
,
$i
++,
"] {\n"
;
my
$session
=
$_
;
foreach
(
sort
keys
%$session
) {
if
( /^platform_info/ ) {
my
$platform
=
$session
->{
$_
};
foreach
(
keys
%$platform
) {
print
" $_ => $platform->{$_}\n"
;
}
}
elsif
( /^ip_address/ ) {
printf
(
" $_ => %d.%d.%d.%d\n"
,
unpack
(
'C4'
,
pack
(
'l4'
,
$session
->{
$_
}) ) );
}
elsif
(
ref
(
$session
->{
$_
}) eq
"Aw::Date"
) {
print
" $_ => "
,
$session
->{
$_
}->toString,
"\n"
;
}
elsif
(
ref
(
$session
->{
$_
}) eq
"Aw::SSLCertificate"
) {
my
$ssl
=
$session
->{
$_
}->toIndentedString(0);
$ssl
=~ s/\n//;
$ssl
=~ s/^/ /mg;
print
$ssl
,
"\n"
;
}
elsif
( !/num_/ ) {
print
" $_ => $session->{$_}\n"
;
}
}
if
(
$i
<
$info
->{num_sessions} ) {
print
" },\n"
;
}
else
{
print
" }\n"
;
}
}
print
" };\n"
;
}
elsif
(
ref
(
$info
->{
$_
}) eq
"CORBA::LongLong"
) {
print
" $_ => "
,
int
$info
->{
$_
},
"\n"
;
}
elsif
( !/num_/ && !/^_/ ) {
print
" $_ => $info->{$_}\n"
;
}
}
delete
(
$stats
{_name} );
foreach
(
sort
keys
%stats
) {
if
(
ref
(
$stats
{
$_
}) eq
"Aw::Date"
) {
print
" $_ => "
,
$stats
{
$_
}->toString,
"\n"
;
}
else
{
print
" $_ => $stats{$_}\n"
;
}
}
print
" Subscribed To:\n"
if
(
@subs
);
foreach
(
@subs
) {
print
" "
,
$_
->getEventTypeName,
"\n"
;
}
}
}