我有一个PHP脚本,可以从Wowza流服务器版本4获取统计信息。
PHP 脚本正在运行,但我只对实时流的统计信息感兴趣,而不是 VOD 流。如何改进我的 PHP 脚本,使其只能获取实时流?
我找不到任何 XML 值。
$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>"
}
要按流获取统计信息计数,您需要改进并重新编译此模块片段: http://www.wowza.com/forums/content.php?184-How-to-get-connection-counts-for-server-applications-application-instances-and-streams-with-an-HTTPProvider
您可以从 IApplicationInstance
中按流获取连接计数。