使用Wowza版本4获取XML格式的实时统计信息

时间:2014-11-15 16:49:05

标签: php xml live-streaming wowza

我有这个PHP脚本从Wowza Streaming Server版本4获取统计信息。

PHP脚本正在运行,但我只对Live Streams而非VOD Streams的统计信息感兴趣。我的PHP脚本如何改进我的PHP脚本才能获得Live Streams?

我找不到任何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>"

} 

1 个答案:

答案 0 :(得分:0)

要按流获取统计信息,您需要改进并重新编译此模块代码段:http://www.wowza.com/forums/content.php?184-How-to-get-connection-counts-for-server-applications-application-instances-and-streams-with-an-HTTPProvider

您可以从IApplicationInstance开始按流获取连接数。