1###############################################################################
2#
3#   Sub Name:       status
4#
5#   Description:    Create a status-reporting struct and returns it.
6#
7#   Arguments:      NAME      IN/OUT  TYPE      DESCRIPTION
8#                   $srv      in      ref       Server object instance
9#
10#   Globals:        None.
11#
12#   Environment:    None.
13#
14#   Returns:        hashref
15#
16###############################################################################
17sub status
18{
19    use strict;
20
21    my $srv = shift;
22    my $no_inc = shift || 0;
23
24    my $status = {};
25    my $time = time;
26    my $URI;
27
28    require URI;
29
30    $status->{name} = ref($srv);
31    $status->{version} = RPC::XML::string->new( $srv->version );
32    $status->{host} = $srv->host || $srv->{host} || '';
33    $status->{port} = $srv->port || $srv->{port} || '';
34    $status->{path} = RPC::XML::string->new( $srv->path );
35    $status->{child_pid} = $$;
36    $status->{date} = RPC::XML::datetime_iso8601
37        ->new(RPC::XML::time2iso8601($time));
38    $status->{started} = RPC::XML::datetime_iso8601
39        ->new(RPC::XML::time2iso8601($srv->started));
40    $status->{child_started} = RPC::XML::datetime_iso8601
41        ->new(RPC::XML::time2iso8601($srv->child_started));
42    $status->{date_int} = $time;
43    $status->{started_int} = $srv->started;
44    $status->{child_started_int} = $srv->child_started;
45    $status->{total_requests} = $srv->requests;
46    # In special cases where the call to system.status is not going to incr
47    # the total, don't add the extra here, either...
48    $status->{total_requests}++ unless $no_inc;
49    $status->{methods_known} = scalar($srv->list_methods);
50
51    $status;
52}
53