NAME

Parse::Apache::ServerStatus - Simple module to parse apache's server-status.

SYNOPSIS

use Parse::Apache::ServerStatus;

my $prs = new Parse::Apache::ServerStatus;

$prs->request(
   url     => 'http://localhost/server-status',
   timeout => 30
) or die $prs->errstr;

my $stat = $prs->parse or die $prs->errstr;

# or both in one step

my $stat = $prs->get(
   url     => 'http://localhost/server-status',
   timeout => 30
) or die $prs->errstr;

DESCRIPTION

This module parses the content of apache's server-status and countes the current status by each process. It works nicely with apache versions 1.3 and 2.x.

METHODS

new()

Call new() to create a new Parse::Apache::ServerStatus object.

request()

This method excepts one or two arguments: url and timeout. It requests the url and safes the content into the object. The option timeout is set to 180 seconds if it is not set.

parse()

Call parse() to parse the server status. This method returns a hash reference with the parsed content. There are diffenrent keys that contains the following counts:

r    Requests currenty being processed
i    Idle workers
p    Parents
ta   Total accesses
tt   Total traffic
_    Waiting for Connection
S    Starting up
R    Reading Request
W    Sending Reply
K    Keepalive (read)
D    DNS Lookup
C    Closing connection
L    Logging
G    Gracefully finishing
I    Idle cleanup of worker
.    Open slot with no current process

It's possible to call parse() with the content as argument.

my $stat = $prs->parse($content);

If no argument is passed then parse() looks into the object for the content that is stored by request().

get()

Call get() to request() and parse() in one step. It except the same options like request() and returns the hash reference that is returned by parse().

content()

Call content() if you need the full content of server-status.

my $content = $prs->content;

errstr()

errstr() contains the error string if the requests fails.

OPTIONS

There are only two options: url and timeout.

Set url with the complete url like http://localhost/server-status. There is only http supported, not https or other protocols.

Set timeout to define the time in seconds to abort the request if there is no response. The default is set to 180 secondes if the options isn't set.

EXAMPLE CONFIGURATION FOR APACHE

This is just an example to activate the handler server-status for localhost.

<Location /server-status>
    SetHandler server-status
    Order Deny,Allow
    Deny from all
    Allow from localhost
</Location>

DEPENDENCIES

Carp
LWP::UserAgent
Params::Validate

EXPORTS

No exports.

REPORT BUGS

Please report all bugs to <jschulz.cpan(at)bloonix.de>.

AUTHOR

Jonny Schulz <jschulz.cpan(at)bloonix.de>.

COPYRIGHT

Copyright (C) 2007 by Jonny Schulz. All rights reserved.

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