For an easier way to get info on just 1 VHost, you can use the original script and just break out of a loop when you find the one you want (Poor man’s single VHost info )
Here’s my code I wrote from scratch, similar to the first post but it uses PHP’s simpleXML and I am looping through the vhosts. This way you can get info on 1 stream (although you still have to download all vhost info before you can get it)
<?php
// Get connection counts for all vhosts; print single VHost info
$url = 'http://MYHOST:8086/connectioncounts';
$page = simplexml_load_file($url);
/*
echo '<pre>';
print_r($page);
echo '</pre>';
*/
// All VHosts in an array
$vhosts = $page->VHost;
// Loop through each VHost
foreach($vhosts as $vh)
{
$vh_name = $vh->Name;
$vh_conn_cur = $vh->ConnectionsCurrent;
$vh_conn_accepted = $vh->ConnectionsTotalAccepted;
$vh_conn_rejected = $vh->ConnectionsTotalRejected;
if($vh_name == 'coolVhost')
{
break;
}
}
// JSON Output for portability
echo '{"current":"' . $vh_conn_cur . '","accepted":"' . $vh_conn_accepted . '","rejected":"' . $vh_conn_rejected . '"}';
?>
If there is any more info on an easy way how to get info on just 1 vhost and NOT all Vhosts’s at once, I am all ears! The current method takes roughly 3 seconds on my server to get info on all vhosts.