Get stream statistics from Wowza Media Server

Recently I needed to know how many connections were made to a stream on our Wowza server, as real time as possible. For Windows Media Services you can use performance counters for that. And you can read these counters with PowerShell. I made a script for that in the past.

For Wowza I wanted something similar for that. The good thing is that Wowza has an xml interface that outputs the current connections. In default configuration you find the interface at http://wowza-ip:8086/connectioncounts. For humans the output is not very readable. So I made a function to parse the output.

Function Get-WowzaStreamStats{
    $webclient = new-Object System.Net.WebClient
    $webclient.credentials = new-Object system.Net.NetworkCredential("user", "password", "")
    [xml]$xml = $webclient.DownloadString("http://wowza-ip:8086/connectioncounts")

    for ($i=0; $i -lt $xml.WowzaMediaServer.VHost.Application.ApplicationInstance.Stream.Count; $i++) {
    $Node = @{}
    $Node.TotalConnections = $xml.WowzaMediaServer.VHost.Application.ApplicationInstance.Stream[$i].SessionsTotal
    $Node.StreamName = $xml.WowzaMediaServer.VHost.Application.ApplicationInstance.Stream[$i].Name
    $Node.FlashConnections = $xml.WowzaMediaServer.VHost.Application.ApplicationInstance.Stream[$i].SessionsFlash
    $Node.SilverlightConnections = $xml.WowzaMediaServer.VHost.Application.ApplicationInstance.Stream[$i].SessionsSmooth
    $Node.RTSPConnections = $xml.WowzaMediaServer.VHost.Application.ApplicationInstance.Stream[$i].SessionsRTSP
    $Node.iPadConnections = $xml.WowzaMediaServer.VHost.Application.ApplicationInstance.Stream[$i].SessionsCupertino
    $StreamStats = new-Object PSObject -Property $Node
    Write-Output $StreamStats

The output of the function is an object. So you can use it in the pipeline. For example you can type:
Get-WowzaStreamStats | Where-Object {$_.StreamName –eq ‘’}