Apache Server Status Parser Component for PHP
This project aims to deliver an easy to use component to read the apache server status for a configured list of hosts and gain information about that.
This component is relying on the apache mod_status and the undocumented query "?notable" ("?auto" does not contain information about the pid).
The build status of the current master branch is tracked by Travis CI:
The scrutinizer status is:
Take a look on openhub.net.
The current change log can be found here.
provides simple access to process information (deals with strings)
provides detailed access to all information (building a lot of objects)
Let me give you an scenario I got on my desk and had to solve it.
As a maintainer of an infrastructure with multiple apache HTTP servers, I need to know if a given process (identified by its pid, a infrastructure wide unique identifier and its uri) is still running or not.
Sometimes I know the IP Address of the server where process is running, mostly all I have is a pid, the unique identifier and the uri.
And finally, it is allowed to use the apache server status but no ssh command execution.
How To Use
Because of the shipped with builders, it is really easy to getting started with.
If you want to use your application instance pooling, use the builders as manual how to plumper things together.
There are two different kind of builders, one (AbstractStorageBuilder) gives you the control over where to fetch and how much to fetch information.
The second one (ParserBuilder) simple uses the result from the first one to parse the information into domain objects.
//If you want to parse the whole apache server status
// and create domain objects out of the information.
//begin of dependencies
$parserBuilderFactory = new \Net\Bazzline\Component\ApacheServerStatusParser\Service\Builder\ParserBuilderFactory();
$storageBuilder = new \Net\Bazzline\Component\ApacheServerStatusParser\Service\Builder\RemoteStorageBuilder();
$parserBuilder = $parserBuilderFactory->create();
//end of dependencies
//begin of business logic
// the following five logical lines are doing the trick
$storageBuilder->setUrlToTheApacheStatusFileToParseUpfront('<the url to your apache server status>');
// and now, do something with the result
//end of business logic
Examples are placed in the path <project root>/example. Because of the two implemented content fetchers, they are devide into the two categories "local" and "remote".
Example Using Local File
cd <project root>/example/local
#if no file path is provided, the shipped with example file will be used
php parse_all.php [<string: path to the apache status file to parse>]
#parse detail only
php parse_detail_only.php [<string: path to the apache status file to parse>]
#check if a request is still running
php check_if_a_request_is_still_running <int: pid> [<string: uri path> [<string: path to the example file>]]
Example Using Remote File
cd <project root>/example/remote
#if no file path is provided, the build in example url will be used
php remote/parse_all.php [<string: url to the apache status page>]
#parse detail only
php parse_detail_only.php [<string: url to the apache status page>]
Just one detail.
date_of_built: Oct 06 1983 20:44:43
identifier: first.example.host.org (via 18.104.22.168)
version: Apache/2.4.10 (Debian)
0: "_" Waiting for Connection,
1: "S" Starting up,
2: "R" Reading Request,
3: "W" Sending Reply,
4: "K" Keepalive (read),
5: "D" DNS Lookup,
6: "C" Closing connection,
7: "L" Logging,
8: "G" Gracefully finishing,
9: "I" Idle cleanup of worker,
10: "." Open slot with no current process
cpu_usage: u959.08 s127.38 cu1.72 cs.95
server_load: 1.22 1.05 0.83
server_up_time: 5 hours 10 minutes 35 seconds
total_traffic: 29.6 MB
mkdir -p vendor/net_bazzline/php_component_apache_server_status_parser
git clone https://github.com/bazzline/php_component_apache_server_status_parser .
composer require net_bazzline/php_component_apache_server_status_parser:dev-master
split content into dedicated sections
parse each section into its fitting domain object
List Of Domain Model
* dynamic detail information about each worker
* general static information about the environment
* dynamic and general worker information
* dynamic server statistic
List Of Service
* contains builder classes to kickstart the usage of this component
* contains classes to get the apache status content from somewhere
* contains classes to create domain objects out of the content
* contains the class to split the content into logical parts (does the heavy lifting)
* contains classes to share the logical content parts
* contains a class to ease up splitting the content into logical parts
* determine if an apache process is still running
* apache for the cloud
* reading apache server status
* Apache Server Status
Star it if you like it :-). Add issues if you need it. Pull patches if you enjoy it. Write a blog entry if you use it. Donate something if you love it :-].