Data-Apache-mod_status

 view release on metacpan or  search on metacpan

lib/Data/Apache/mod_status.pm  view on Meta::CPAN

        
        $info_line =~ m/^Server \s Version: \s (.+)$/xms
            ? $info->server_version($1) :
        $info_line =~ m/^Server \s Built: \s (.+)$/xms
            ? $info->server_build_str($1) :
        $info_line =~ m/^Current \s Time: \s (.+)$/xms
            ? $info->current_time_str($1) :
        $info_line =~ m/^Restart \s Time: \s (.+)$/xms
            ? $info->restart_time_str($1) :
        $info_line =~ m/^Parent \s Server \s Generation: \s (\d+)$/xms
            ? $info->parent_server_generation($1) :
        $info_line =~ m/^Server \s uptime: \s (.+)$/xms
            ? $info->server_uptime_str($1) :
        $info_line =~ m/^Total \s accesses: \s (\d+) \s - \s Total \s Traffic: \s (\d+(?:\.\d+)?\s.+)$/xms
            ? ($info->total_accesses($1), $info->total_traffic_str($2)) :
        $info_line =~ m/^CPU \s Usage: \s (.+)$/xms
            ? $info->cpu_usage_str($1) :
        $info_line =~ m{requests/sec \s - \s .+/second \s - \s .+/request$}xms
            ? 1 :
        $info_line =~ m/^(\d+) \s requests \s currently \s being \s processed, \s (\d+) \s idle \s workers$/xms
            ? ($info->current_requests($1), $info->idle_workers($2))
        : (die 'unknown mod_status info line "', $info_line, '"');
    }
    
    # store new values
    $self->info($info);
    
    my ($workers_tag) = $dom->findnodes('/mod_status/workers');
    $self->workers(
        Data::Apache::mod_status::Workers->new(
            'workers_tag' => $workers_tag,
        )
    );
    
    return $self;
}


=head2 _fetch_mod_status_page()

Method that fetches C<mod_status> page and returning it's content.

=cut

sub _fetch_mod_status_page {
    my $self = shift;
    
    my $url = $self->url;
    croak 'set url'
        if not defined $url;
    
    # get mod_status page
    my $ua = LWP::UserAgent->new;
    $ua->timeout(10);
    $ua->env_proxy;
    my $response = $ua->get($url);
    die 'failed to fetch "', $url, '" - '.$response->status_line
        if $response->is_error();
    
    # tidy mod_status page to be xhtml document
    return $response->decoded_content;
}

"Zed's Dead, baby";


__END__

=head1 SEE ALSO

L<examples/rrd/> folder for examples how to create, update and graph C<mod_status>
data using L<Data::Apache::mod_status> and rrdtool.

=head1 DEBIAN

    Build-Depends: debhelper (>= 5), libmodule-build-perl, libtest-differences-perl,
     libtest-exception-perl, libfile-slurp-perl, tidy
    Depends: ${perl:Depends}, ${misc:Depends}, libxml-libxslt-perl,
     libdatetime-format-strptime-perl, libmoose-perl, libwww-perl, libcarp-clan-perl,
     libxml-libxml-perl, libipc-run3-perl, libmoose-perl, tidy

=head1 COPYRIGHT AND LICENSE

This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=head1 AUTHOR

Jozef Kutej

=cut



( run in 0.607 second using v1.01-cache-2.11-cpan-2398b32b56e )