WOWZA Streaming Server Bandwidth consumption monitoring for specific app/folder -


i new wowza streaming server

  • have created new vod application "voddemo" generate streaming url video content of "voddemo" folder placed inside "content" directory of wowza app folder (aka 'application-specific directory')
  • looking know way obtain total streaming bandwidth consumption directory of "voddemo"
  • which used video analytic purpose

there's several ways can statistics info on wowza streaming application.

  1. as orde pointed out above, can use monitoring page manager ui. page can reached selecting application page, , clicking on monitoring left content menu. can view network usage on historical basis well.

  2. you can use built-in httpprovider connectioncounts (http://localhost:8086/connectioncounts). shows xml snapshot of current connection info. can see network usage particular application checking messagesoutbytesrate value. <messagesoutbytesrate>139055.0</messagesoutbytesrate>

  3. you can create own httpprovider developing custom module based on wowza java api.

    package com.wowza.wms.http;  import java.io.*; import java.util.*; import java.net.*; import com.wowza.wms.application.*; import com.wowza.wms.client.*; import com.wowza.wms.logging.*; import com.wowza.wms.server.*; import com.wowza.wms.vhost.*; import com.wowza.wms.http.*; import com.wowza.util.*; import com.wowza.wms.httpstreamer.model.*; //import org.json.*;  public class httpconnectioncountsxml extends httprovider2base {   class mycounter     {         int total = 0;     }     private void outputconnectioninfo(stringbuffer ret, connectioncounter counter)     {         ret.append(""+counter.getcurrent()+"");         ret.append(""+counter.gettotal()+"");         ret.append(""+counter.gettotalaccepted()+"");         ret.append(""+counter.gettotalrejected()+"");     }         private void outputioperformanceinfo(stringbuffer ret, ioperformancecounter ioperformance)     {         ret.append(""+ioperformance.getmessagesinbytesrate()+"");         ret.append(""+ioperformance.getmessagesoutbytesrate()+"");     }         private int tocount(integer intobj, mycounter counter)     {         int ret = intobj==null?0:intobj.intvalue();         counter.total += ret;         return ret;     }     public void onhttprequest(ivhost invhost, ihttprequest req, ihttpresponse resp)     {         if (!dohttpauthentication(invhost, req, resp))             return;         stringbuffer ret = new stringbuffer();  
        string querystr = req.getquerystring();     map<string, string> querymap = httputils.splitquerystr(querystr);     boolean isflat = false;     isflat = this.properties.getpropertyboolean("isflat", isflat);     if (querymap.containskey("flat"))         isflat = true;     try     {         list<string> vhostnames = vhostsingleton.getvhostnames();         ret.append("<?xml version=\"1.0\"?>\n<wowzamediaserver>");          iserver server = server.getinstance();         if (!isflat)         {             outputconnectioninfo(ret, server.getconnectioncounter());             outputioperformanceinfo(ret, server.getioperformancecounter());         }         iterator<string> iter = vhostnames.iterator();         while (iter.hasnext())         {             string vhostname = iter.next();             ivhost vhost = (ivhost)vhostsingleton.getinstance(vhostname);             if (vhost != null)             {                 if (!isflat)                 {                     ret.append("<vhost>");                     ret.append("<name>"+urlencoder.encode(vhostname, "utf-8")+"</name>");                     ret.append("<timerunning>"+vhost.gettimerunningseconds()+"</timerunning>");                     ret.append("<connectionslimit>"+vhost.getconnectionlimit()+"</connectionslimit>");                     outputconnectioninfo(ret, vhost.getconnectioncounter());                     outputioperformanceinfo(ret, vhost.getioperformancecounter());                 }                 list<string> appnames = vhost.getapplicationnames();                 iterator<string> appnameiterator = appnames.iterator();                 while (appnameiterator.hasnext())                 {                     string applicationname = appnameiterator.next();                     iapplication application = vhost.getapplication(applicationname);                     if (application == null)                         continue;                     if (!isflat)                     {                         ret.append("<application>");                         ret.append("<name>"+urlencoder.encode(applicationname, "utf-8")+"</name>");                         ret.append("<status>loaded</status>");                         ret.append("<timerunning>"+application.gettimerunningseconds()+"</timerunning>");                          outputconnectioninfo(ret, application.getconnectioncounter());                         outputioperformanceinfo(ret, application.getioperformancecounter());                     }                     list<string> appinstances = application.getappinstancenames();                     iterator<string> iterappinstances = appinstances.iterator();                     while (iterappinstances.hasnext())                     {                         string appinstancename = iterappinstances.next();                         iapplicationinstance appinstance = application.getappinstance(appinstancename);                         if (appinstance == null)                             continue;                          if (!isflat)                         {                             ret.append("<applicationinstance>");                             ret.append("<name>"+urlencoder.encode(appinstance.getname(), "utf-8")+"</name>");                             ret.append("<timerunning>"+appinstance.gettimerunningseconds()+"</timerunning>");                              outputconnectioninfo(ret, appinstance.getconnectioncounter());                             outputioperformanceinfo(ret, appinstance.getioperformancecounter());                         }                         map<string, integer> flashcounts = appinstance.getplaystreamcountsbyname();                         map<string, integer> smoothcounts = appinstance.gethttpstreamersessioncountsbyname(ihttpstreamersession.sessionprotocol_smoothstreaming);                         map<string, integer> cupertinocounts = appinstance.gethttpstreamersessioncountsbyname(ihttpstreamersession.sessionprotocol_cupertinostreaming);                         map<string, integer> sanjosecounts = appinstance.gethttpstreamersessioncountsbyname(ihttpstreamersession.sessionprotocol_sanjosestreaming);                         map<string, integer> rtspcounts = appinstance.getrtpsessioncountsbyname();                         map<string, integer> mpegdashcounts = appinstance.gethttpstreamersessioncountsbyname(ihttpstreamersession.sessionprotocol_mpegdashstreaming);                         list<string> publishstreams = appinstance.getstreams().getpublishstreamnames();                         set<string> streamnames = new hashset<string>();                         streamnames.addall(publishstreams);                         streamnames.addall(flashcounts.keyset());                         streamnames.addall(smoothcounts.keyset());                         streamnames.addall(cupertinocounts.keyset());                         streamnames.addall(sanjosecounts.keyset());                         streamnames.addall(rtspcounts.keyset());                         streamnames.addall(mpegdashcounts.keyset());                         iterator<string> siter = streamnames.iterator();                         while(siter.hasnext())                         {                             string streamname = siter.next();                             mycounter counter = new mycounter();                             if (isflat)                             {                                 int flashcount = tocount(flashcounts.get(streamname), counter);                                 int cupertinocount = tocount(cupertinocounts.get(streamname), counter);                                 int smoothcount = tocount(smoothcounts.get(streamname), counter);                                 int sanjosecount = tocount(sanjosecounts.get(streamname), counter);                                 int rtspcount = tocount(rtspcounts.get(streamname), counter);                                 int mpegdashcount = tocount(mpegdashcounts.get(streamname), counter);                                 ret.append("<stream ");                                 ret.append("vhostname=\""+urlencoder.encode(vhostname, "utf-8")+"\" ");                                 ret.append("applicationname=\""+urlencoder.encode(applicationname, "utf-8")+"\" ");                                 ret.append("appinstancename=\""+urlencoder.encode(appinstancename, "utf-8")+"\" ");                                 ret.append("streamname=\""+urlencoder.encode(streamname, "utf-8")+"\" ");                                 ret.append("sessionsflash=\""+flashcount+"\" ");                                 ret.append("sessionscupertino=\""+cupertinocount+"\" ");                                 ret.append("sessionssanjose=\""+sanjosecount+"\" ");                                 ret.append("sessionssmooth=\""+smoothcount+"\" ");                                 ret.append("sessionsrtsp=\""+rtspcount+"\" ");                                 ret.append("sessionsmpegdash=\""+mpegdashcount+"\" ");                                 ret.append("sessionstotal=\""+counter.total+"\" ");                                 ret.append("/>");                             }                             else                             {                                 ret.append("<stream>");                                 ret.append("<name>"+urlencoder.encode(streamname, "utf-8")+"</name>");                                 ret.append("<sessionsflash>"+tocount(flashcounts.get(streamname), counter)+"</sessionsflash>");                                 ret.append("<sessionscupertino>"+tocount(cupertinocounts.get(streamname), counter)+"</sessionscupertino>");                                 ret.append("<sessionssanjose>"+tocount(sanjosecounts.get(streamname), counter)+"</sessionssanjose>");                                 ret.append("<sessionssmooth>"+tocount(smoothcounts.get(streamname), counter)+"</sessionssmooth>");                                 ret.append("<sessionsrtsp>"+tocount(rtspcounts.get(streamname), counter)+"</sessionsrtsp>");                                 ret.append("<sessionsmpegdash>" + tocount(mpegdashcounts.get(streamname), counter) + "</sessionsmpegdash>");                                 ret.append("<sessionstotal>"+counter.total+"</sessionstotal>");                                 ret.append("</stream>");                             }                         }                          if (!isflat)                             ret.append("</applicationinstance>");                     }                     if (!isflat)                         ret.append("</application>");                 }                 if (!isflat)                     ret.append("</vhost>");             }         }         ret.append("</wowzamediaserver>");     }     catch (exception e)     {         wmsloggerfactory.getlogger(httpserverversion.class).error("httpserverinfoxml.onhttprequest: "+e.tostring());         e.printstacktrace();     }     try     {         resp.setheader("content-type", "text/xml");         outputstream out = resp.getoutputstream();         byte[] outbytes = ret.tostring().getbytes();         out.write(outbytes);     }     catch (exception e)     {         wmsloggerfactory.getlogger(httpserverversion.class).error("httpserverinfoxml.onhttprequest: "+e.tostring());         e.printstacktrace();     } } 
    }
  4. you can use rest api (for version 4.3+) query via curl or other http request method. 1 example query historical data given application.

    curl -x --header 'accept:application/json; charset=utf-8' http://localhost:8087/v2/servers/_defaultserver_/vhosts/_defaultvhost_/applications/testlive/monitoring/historic 

    this return data following data array values:

    index 0 = bandwidth usage coming application in kb/s
    index 1 = bandwidth usage going out of application in kb/s
    index 2 = rtmp connection count in , out of application
    index 3 = rtsp connection count in , out of application
    index 4 = hds connection count in , out of application
    index 5 = hls connection count in , out of application
    index 6 = smoothstreaming connection count in , out of application
    index 7 = web rtc connection count in , out of application
    index 8 = wem connection count in , out of application
    index 9 = dash connection count in , out of application

  5. you can use wowza google analytics module, lets integrate ga account wowza streaming data.


Comments

Popular posts from this blog

c# - How Configure Devart dotConnect for SQLite Code First? -

java - Copying object fields -

c++ - Clear the memory after returning a vector in a function -