Wowza version 4 - get live stats XML (PHP)



I have this PHP script that gets stats from the Wowza Streaming Server version 4.


The PHP script is working but I am only interested in the stats for the Live Streams and not the VOD Streams. How can my PHP script be improved my PHP script to it only gets the Live Streams?


I could not find any XML value for this.



$hostname = "localhost";

$xml_data=file_get_contents("http://$hostname:8086/connectioncounts");

$doc = new DOMDocument();
$doc->loadXML($xml_data);

$wms = $doc->getElementsByTagName('WowzaStreamingEngine');
print_r($wms);
$wmstotalactive = $wms->item(0)->getElementsByTagName("ConnectionsCurrent")->item(0)->nodeValue;
$wmstotaloutbytes = $wms->item(0)->getElementsByTagName("MessagesOutBytesRate")->item(0)->nodeValue;
$wmstotaloutbits = $wmstotaloutbytes * '8';

echo "<center><b>Hostname:</b> $hostname<br></center><hr> <b>Server Total Active Connections:</b> $wmstotalactive<br> <b>Total Outbo
and bitrate:</b> $wmstotaloutbits<br><hr>";

$wmsapp = $doc->getElementsByTagName('Application');
$wmscnt = $wmsapp->length;

echo "<center>Applications</center>";

for ($idx = 0; $idx < $wmscnt; $idx++) {
$appname = $wmsapp->item($idx)->getElementsByTagName("Name")->item(0)->nodeValue;
$appccount = $wmsapp->item($idx)->getElementsByTagName("ConnectionsCurrent")->item(0)->nodeValue;
$appoutbytes = $wmsapp->item($idx)->getElementsByTagName("MessagesOutBytesRate")->item(0)->nodeValue;
$appoutbits = $appoutbytes * '8';

echo "<hr><b>Application Name:</b> $appname<br><b> Active Connections:</b> $appccount<br> <b>Application Bits Out:</b> $appoutbits
<br>";
}
echo "<hr><center>Streams</center>";
$wmsast = $doc->getElementsByTagName('Stream');
$wmsasct = $wmsast->length;

for ($sidx = 0; $sidx < $wmsasct; $sidx++) {
$strname = $wmsast->item($sidx)->getElementsByTagName("Name")->item(0)->nodeValue;
$strctot = $wmsast->item($sidx)->getElementsByTagName("SessionsTotal")->item(0)->nodeValue;

echo "<hr><b>Stream URL:</b> $strname <br> <b>Connections to Stream:</b> $strctot<br>"

}

No comments:

Post a Comment