php component to ease up reading and processing the apache server status (mod_status)
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.
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.
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>'); $storageBuilder->selectParseModeAllUpfront(); $storageBuilder->build(); $parserBuilder->setStorageUpfront( $storageBuilder->andGetStorageAfterTheBuild(); ); $parserBuilder->build(); // and now, do something with the result var_dump( $parserBuilder->andGetListOfDetailOrNullAfterwards() ); var_dump( $parserBuilder->andGetInformationOrNullAfterwards() ); var_dump( $parserBuilder->andGetScoreboardOrNullAfterwards() ); var_dump( $parserBuilder->andGetStatisticOrNullAfterwards() ); //end of business logic
cd <project root>/example/local #if no file path is provided, the shipped with example file will be used #parse all 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>]]
cd <project root>/example/remote #if no file path is provided, the build in example url will be used #parse all 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.
http_method: GET ip_address: 220.127.116.11 pid: 22754 status: Ready uri_authority: example.host.org:80 uri_path_with_query: /
date_of_built: Oct 06 1983 20:44:43 identifier: first.example.host.org (via 18.104.22.168) mode_of_mpm: prefork version: Apache/2.4.10 (Debian)
process: _WWW_WWWWKW_....._.W.................................................................................................................................. legend 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
b_per_request: 1667 cpu_load: 584 cpu_usage: u959.08 s127.38 cu1.72 cs.95 current_timestamp: 1485804167 idle_workers: 4 kb_per_request: 57 parent_server_configuration_generation: 1 parent_server_mpm_generation: 1 requests_currently_being_processed: 10 requests_per_second: 283 restart_timestamp: 1485785532 server_load: 1.22 1.05 0.83 server_up_time: 5 hours 10 minutes 35 seconds total_accesses: 5279 total_traffic: 29.6 MB
mkdir -p vendor/net_bazzline/php_component_apache_server_status_parser cd 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
- get content
- split content into dedicated sections
- parse each section into its fitting domain object
- dynamic detail information about each worker
- general static information about the environment
- dynamic and general worker information
- dynamic server statistic
- 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 :-].