/
status.code
47 lines (42 loc) · 1.62 KB
/
status.code
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
###############################################################################
#
# Sub Name: status
#
# Description: Create a status-reporting struct and returns it.
#
# Arguments: NAME IN/OUT TYPE DESCRIPTION
# $srv in ref Server object instance
# $no_inc in boolean A true/false value that tells
# whether to count this call
# in the total_requests field.
#
# Returns: hashref
#
###############################################################################
sub status
{
use strict;
my $srv = shift;
my $no_inc = shift || 0;
my $status = {};
my $time = time;
my $URI;
require URI;
$status->{name} = ref($srv);
$status->{version} = RPC::XML::string->new($srv->version);
$status->{host} = $srv->host || $srv->{host} || '';
$status->{port} = $srv->port || $srv->{port} || '';
$status->{path} = RPC::XML::string->new($srv->path);
$status->{date} = RPC::XML::datetime_iso8601
->new(RPC::XML::time2iso8601($time));
$status->{started} = RPC::XML::datetime_iso8601
->new(RPC::XML::time2iso8601($srv->started));
$status->{date_int} = $time;
$status->{started_int} = $srv->started;
$status->{total_requests} = $srv->requests();
# In special cases where the call to system.status is not going to incr
# the total, don't add the extra here, either...
$status->{total_requests}++ unless $no_inc;
$status->{methods_known} = scalar($srv->list_methods);
$status;
}