I want to find away out to obtain all Apache running request in a given moment. I have to list the vhost, cpu, request ip plus some additional information. This article be consumed with a PHP script.

I've mod_status installed and contains all the details I want. And So I attempted to make use of file_get_contents to obtain the report, producing a request in the server (http://localhost/server-status). It labored perfectly. I Quickly attempted to parse the report, transforming it to XML using simplexml_load_string. However , the HTML outputted by mod_status isn't well created.

This is actually the HTL in the table I have to parse:

<table border="0"><tr><th>Srv</th><th>PID</th><th>Acc</th><th>M</th><th>CPU
</th><th>SS</th><th>Req</th><th>Conn</th><th>Child</th><th>Slot</th><th>Client</th><th>VHost</th><th>Request</th></tr>

<tr><td><b>0-1</b></td><td>-</td><td>0/0/70</td><td>.
</td><td>0.00</td><td>107</td><td>0</td><td>0.0</td><td>0.00</td><td>0.34
</td><td>127.0.0.1</td><td nowrap>zsce</td><td nowrap>OPTIONS * HTTP/1.0</td></tr>

<tr><td><b>1-1</b></td><td>-</td><td>0/0/55</td><td>.
</td><td>0.04</td><td>108</td><td>0</td><td>0.0</td><td>0.00</td><td>0.70
</td><td>127.0.0.1</td><td nowrap>zsce</td><td nowrap>OPTIONS * HTTP/1.0</td></tr>

</table>

I am sure someone has attempted to behave such as this before. 1) Can there be a different way to access the data I want? 2) Has anybody attempted other tools / modules?

Thanks ahead of time.

I can not begin to see the trouble with the HTML. Wrong by using it?

Does PHP not have access to a liberal HTML parser something similar to Python's BeautifulSoup or Ruby's Nokogiri?

Also, keep in mind that mod_status has 'auto' way of creating machine-readable output.

http://www.apache.org/server-status?auto http://httpd.apache.org/paperwork/2.2/mod/mod_status.html#machinereadable

I simply discovered that basically remove "nowrap" in the HTML before parsing it, it really works.