Here’s one that goes thru the connectioncounts and presents some info about the apps & streams. Also shows current outbound bitate for the server & apps.
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.
I think he means he wants to have to authenticate instead of it just openly giving him the info.
IF that’s what he means, you said it earlier:
…I think you also have to change the connectioncounts HTTProvider in /conf/VHost.xml from “admin-digest” to “none”
If he makes the HTTProvider for connectioncounts back to “admin-digest”, it should try and authenticate. Then using PHP, instead of using “$page = simplexml_load_file($url);”, you’d use CURL and authenticate with a regular auth. Then just use simplexml_load_string().
interesting post, but how do you specify each stream in the php file? cause this will count all the connections to the server and not to a specify application or stream.
I get following by wireshark, but I don’t know how to encode my username and password:
Authorization: Digest username="admin",realm="Wowza Media Systems",nonce="957049024554bf2babf48a5467e52eec",uri="/connectioncounts",cnonce="d3b895b0d8dbc7e1e7b4a545d3e2504b",nc=00000006,algorithm=MD5,response="bd13373e2aa9218fe617221448e620b7",qop="auth"
I know how to set username and password in wowza configuartion file admin.passwd. I want pass the certification in my PHP code to get information I want automatically.
The following is what I did now.
I send a HTTP Header like ‘"Authorization: Basic ".base64_encode(“myusername:mypassword”)’ to ‘http://[wowza-server]:8086/connectioncounts’,
but the server return the following ‘401 Unauthorized WWW-Authenticate’ to me, why?
the following is the message wowza server returned.
Probably because clientaccesspolicy doesn’t require authentication. Where you able to turn off authentication so you can access connection counts without the password prompt? Remember, if you put in your credentials in your browser one time, it doesn’t ask you again until you restart Wowza.
I am having problems with this code (the connectioncounts XML parser), I have implemented the code exactly as told at the start of this topic, but when I go to the page, it returns the following PHP error:
Warning: DOMDocument::loadXML() [domdocument.loadxml]: Empty string supplied as input in /home/site/public_html/tv/test.php on line 6
Fatal error: Call to a member function getElementsByTagName() on a non-object in /home/site/public_html/tv/test.php on line 9
I can access the connectioncounts xml page directly through my web browser, but the script will not. I have no authentication required to access the page and I have also tried changing “loadXML()” to “load()”, which just returns even more PHP errors.
Any help on this matter would be greatly appreciated.
I see than the port is 5800, are your changed the default admin port into the VHost.xml? and do you have the php-xml extension installed into your server?
Yes I have changed the default port in the VHost file. Like I said, I can access the page directly by putting in the URL all fine.
As for the php-xml extension, what do you mean? Those functions are PHP standard. I am running the latest version of PHP and have “php_xsl” enabled in my php.ini.
I’m still having problems with the script. I changed the ‘connectioncounts’ port back to 8086, but i still get the following error. I can definately access the xml file directly through my browser, by going to “http://[myserverip]:8086/connectioncounts” but it simply won’t work in php. I checked my PHP config and all XML functions are enabled, yet it still returns this error. I am using no authentication either, so it should work.
Warning: DOMDocument::loadXML() [domdocument.loadxml]: Empty string supplied as input in /home/root/public_html/response.php on line 8
Fatal error: Call to a member function getElementsByTagName() on a non-object in /home/root/public_html/response.php on line 11
I have no idea what is happening. I’ll post my current code for you again.