#!/usr/bin/env perl
use
5.008;
our
$VERSION
=
'2.71_4460'
;
our
$Service_Name
=
''
;
our
$Hostname
=
''
;
our
$Help_Mode
= 0;
our
$OPT_Epoch_Time
= 0;
GetOptions(
"service=s"
=> \
$Service_Name
,
"hostname=s"
=> \
$Hostname
,
"epoch-time"
=> \
$OPT_Epoch_Time
,
"help"
=> \
$Help_Mode
,
);
if
(
$Help_Mode
) {
Pod::Usage::pod2usage(
-verbose
=> 2,
-exitstatus
=> 0);
}
my
$s
= Helios::Service->new();
$s
->prep();
my
$dbh
=
$s
->dbConnect();
my
@placeholders
;
my
$sql
=
q{
SELECT
worker_class,
worker_version,
host,
process_id,
start_time,
register_time
FROM
helios_worker_registry_tb
WHERE
register_time > ?
}
;
push
(
@placeholders
,
time
() - 300 );
if
(
$Service_Name
) {
$sql
.=
' AND worker_class = ? '
;
push
(
@placeholders
,
$Service_Name
);
}
if
(
$Hostname
) {
$sql
.=
' AND host = ? '
;
push
(
@placeholders
,
$Hostname
);
}
my
$rs
;
eval
{
$rs
=
$dbh
->selectall_arrayref(
$sql
,
undef
,
@placeholders
);
1;
} or
do
{
my
$E
= $@;
warn
"$0: ERROR: $E\n"
;
exit
(1);
};
foreach
(
@$rs
) {
print
'Service: '
,
$_
->[0],
"\n"
;
print
'Version: '
,
$_
->[1],
"\n"
;
print
'Host: '
,
$_
->[2],
"\n"
;
print
'PID: '
,
$_
->[3],
"\n"
;
print
"Online Since: "
,
$OPT_Epoch_Time
?
$_
->[4] :
scalar
localtime
(
$_
->[4]),
"\n"
;
print
'Last Registered: '
,
$OPT_Epoch_Time
?
$_
->[5] :
scalar
localtime
(
$_
->[5]),
"\n"
;
print
"\n"
;
}
$dbh
->disconnect();
exit
(0);