Results 1 to 1 of 1

Thread: Realtime monitoring using JMX and MRTG

  1. #1

    Default Realtime monitoring using JMX and MRTG

    So using an examples from here ( http://www.wowza.com/forums/showthre...MRTG-and-Munin ), I managed to get the graph from MRTG and it is working perfectly

    The output :

    The settings
    ==========

    Instance : EC2 m1.large
    OS : Ubuntu 12.04.1 LTS (GNU/Linux 3.2.0-31-virtual i686)

    Wowza version : 3.5.x

    Java :
    java version "1.6.0_24"
    OpenJDK Runtime Environment (IcedTea6 1.11.5) (6b24-1.11.5-0ubuntu1~12.04.1)
    OpenJDK Client VM (build 20.0-b12, mixed mode, sharing)

    Wowza : Enable JMX access at port 8085 and edit these files
    /usr/local/WowzaMediaServer/conf/jmxremote.access
    /usr/local/WowzaMediaServer/conf/jmxremote.password


    on my setting, username is "admin" and password is "admin"

    Next is to compile java program that can access the data via JMX interface and return some numbers

    I create a file in /home/ubuntu/scripts/JMXCommandLine.java
    PHP Code:
    import java.util.*;
    import javax.management.*;
    import javax.management.remote.*;

    public class 
    JMXCommandLine
    {
        public static final 
    String STREAMINGTYPES_TOTAL "total";
        public static final 
    String STREAMINGTYPES_CUPERTINO "cupertino";
        public static final 
    String STREAMINGTYPES_SMOOTH "smooth";
        public static final 
    String STREAMINGTYPES_RTMP "rtmp";
        public static final 
    String STREAMINGTYPES_RTSP "rtsp";

        public static final 
    String[][] countStrs = {
            {
    "Connections"STREAMINGTYPES_TOTAL},
            {
    "ConnectionsHTTPCupertino"STREAMINGTYPES_CUPERTINO},
            {
    "ConnectionsHTTPSmooth"STREAMINGTYPES_SMOOTH},
            {
    "ConnectionsRTMP"STREAMINGTYPES_RTMP},
            {
    "ConnectionsRTP"STREAMINGTYPES_RTSP},
        };

        public static final 
    String[][] ioStrs = {
            {
    "IOPerformance"STREAMINGTYPES_TOTAL},
            {
    "IOPerformanceHTTPCupertino"STREAMINGTYPES_CUPERTINO},
            {
    "IOPerformanceHTTPSmooth"STREAMINGTYPES_SMOOTH},
            {
    "IOPerformanceRTMP"STREAMINGTYPES_RTMP},
            {
    "IOPerformanceRTP"STREAMINGTYPES_RTSP},
        };

        public static final 
    int SESSIONPROTOCOL_SMOOTHSTREAMING 0;
        public static final 
    int SESSIONPROTOCOL_CUPERTINOSTREAMING 1;

        public static final 
    String MBEANNAME "WowzaMediaServerPro";

        public static final 
    String CMD_GETSERVERVERSION "getServerVersion";
        public static final 
    String CMD_STARTVHOST "startVHost";
        public static final 
    String CMD_STOPVHOST "stopVHost";
        public static final 
    String CMD_RELOADVHOSTCONFIG "reloadVHostConfig";
        public static final 
    String CMD_STARTAPPINSTANCE "startAppInstance";
        public static final 
    String CMD_TOUCHAPPINSTANCE "touchAppInstance";
        public static final 
    String CMD_SHUTDOWNAPPINSTANCE "shutdownAppInstance";
        public static final 
    String CMD_STARTMEDIACASTERSTREAM "startMediaCasterStream";
        public static final 
    String CMD_STOPMEDIACASTERSTREAM "stopMediaCasterStream";
        public static final 
    String CMD_RESETMEDIACASTERSTREAM "resetMediaCasterStream";
        public static final 
    String CMD_GETCONNECTIONCOUNTS "getConnectionCounts";
        public static final 
    String CMD_GETIOOUTBYTERATE "getIOOutByteRate";
        public static final 
    String CMD_GETIOINBYTERATE "getIOInByteRate";

        public static final 
    String DEFAULT_VHOST "_defaultVHost_";
        public static final 
    String DEFAULT_APPLICATION "_defapp_";
        public static final 
    String DEFAULT_APPINSTANCE "_definst_";

        public static class 
    AppConextName
        
    {
            
    String vhostName null;
            
    String appName null;
            
    String appInstName null;

            public 
    AppConextName()
            {
            }

            public 
    AppConextName(String fullnameboolean startWithDefaults)
            {
                if (
    startWithDefaults)
                {
                    
    vhostName DEFAULT_VHOST;
                    
    appName DEFAULT_APPLICATION;
                    
    appInstName DEFAULT_APPINSTANCE;
                }

                
    int qloc fullname.indexOf(":");
                if (
    qloc >= 0)
                {
                    
    vhostName fullname.substring(0qloc);
                    
    fullname fullname.substring(qloc+1);
                }
                else
                    
    vhostName DEFAULT_VHOST;

                if (
    fullname.length() > 0)
                {
                    
    appName fullname;
                    
    int sloc fullname.indexOf("/");
                    if (
    sloc >= 0)
                    {
                        
    appName fullname.substring(0sloc);
                        
    appInstName fullname.substring(sloc+1);
                    }
                }
            }

            
    String getObjName()
            {
                
    String ret "";

                while(
    true)
                {
                    if (
    vhostName == null)
                        break;

                    
    ret += "vHosts=VHosts,vHostName="+vhostName;

                    if (
    appName == null)
                        break;

                    
    ret += ",applications=Applications,applicationName="+appName;

                    if (
    appInstName == null)
                        break;

                    
    ret += ",applicationInstances=ApplicationInstances,applicationInstanceName="+appInstName;
                    break;
                }

                return 
    ret;
            }
        }

        public static 
    void printUsage()
        {
            
    System.out.println("");
            
    System.out.println("Usage:");
            
    System.out.println("");
            
    System.out.println("[command] -[switch [value]...] [command] [params...]");
            
    System.out.println("");
            
    System.out.println("Switches:");
            
    System.out.println("");
            
    System.out.println("  -jmx  [jmx-url]");
            
    System.out.println("  -user [jmx-username]");
            
    System.out.println("  -pass [jmx-password]");
            
    System.out.println("");
            
    System.out.println("Commands:");
            
    System.out.println("");

            
    System.out.println("  "+CMD_GETSERVERVERSION);

            
    System.out.println("  "+CMD_STARTVHOST+" [vhost]");
            
    System.out.println("  "+CMD_STOPVHOST+" [vhost]");
            
    System.out.println("  "+CMD_RELOADVHOSTCONFIG+"");

            
    System.out.println("  "+CMD_STARTAPPINSTANCE+" [vhost:application/appInstance]");
            
    System.out.println("  "+CMD_TOUCHAPPINSTANCE+" [vhost:application/appInstance]");
            
    System.out.println("  "+CMD_SHUTDOWNAPPINSTANCE+" [vhost:application/appInstance]");

            
    System.out.println("  "+CMD_STARTMEDIACASTERSTREAM+" [vhost:application/appInstance] [stream-name] [mediacaster-type]");
            
    System.out.println("  "+CMD_STOPMEDIACASTERSTREAM+" [vhost:application/appInstance] [stream-name]");
            
    System.out.println("  "+CMD_RESETMEDIACASTERSTREAM+" [vhost:application/appInstance] [stream-name]");

            
    System.out.println("  "+CMD_GETCONNECTIONCOUNTS);
            
    System.out.println("  "+CMD_GETCONNECTIONCOUNTS+" [vhost:application/appInstance]");
            
    System.out.println("  "+CMD_GETCONNECTIONCOUNTS+" [vhost:application/appInstance] [stream-name]");

            
    System.out.println("  "+CMD_GETIOOUTBYTERATE);
            
    System.out.println("  "+CMD_GETIOOUTBYTERATE+" [vhost:application/appInstance]");

            
    System.out.println("  "+CMD_GETIOINBYTERATE);
            
    System.out.println("  "+CMD_GETIOINBYTERATE+" [vhost:application/appInstance]");

            
    System.out.println("");
        }

        public static 
    long objToLong(Object valueObj)
        {
            
    long ret 0;
            if (
    valueObj != null)
            {
                try
                {
                    
    ret Long.parseLong(valueObj.toString());
                }
                catch(
    Exception e)
                {
                }
            }
            return 
    ret;
        }

        public static 
    Object doInvoke(MBeanServerConnection connectionObjectName connectsObjNameString cmdStrObject[] argumentsString[] signature)
        {
            
    Object returnObj null;
            try
            {
                
    returnObj connection.invoke(connectsObjNamecmdStrargumentssignature);
            }
            catch(
    Exception e)
            {
                
    System.out.println("ERROR: doInvoke: "+e.toString());
            }

            return 
    returnObj;
        }

        public static 
    Object doGetAttribute(MBeanServerConnection connectionObjectName connectsObjNameString attributeName)
        {
            
    Object returnObj null;
            try
            {
                
    returnObj connection.getAttribute(connectsObjNameattributeName);
            }
            catch(
    Exception e)
            {
            }

            return 
    returnObj;
        }

        public static 
    void main(String[] args)
        {

            try
            {
                for(
    int i=0;i<args.length;i++)
                    
    args[i] = args[i].trim();

                
    String host "localhost";
                
    String username null;
                
    String password null;
                
    String jmxURL "service:jmx:rmi://"+host+":8084/jndi/rmi://"+host+":8085/jmxrmi";

                
    int argOffset 0;
                while(
    true)
                {
                    if (
    argOffset >= args.length)
                        break;

                    if (!
    args[argOffset].startsWith("-"))
                        break;

                    if (
    args[argOffset].startsWith("-host"))
                    {
                        
    argOffset++;
                        
    host args[argOffset];
                        
    jmxURL "service:jmx:rmi://"+host+":8084/jndi/rmi://"+host+":8085/jmxrmi";
                    }
                    else if (
    args[argOffset].startsWith("-jmx"))
                    {
                        
    argOffset++;
                        
    jmxURL args[argOffset];
                    }
                    else if (
    args[argOffset].startsWith("-user"))
                    {
                        
    argOffset++;
                        
    username args[argOffset];
                    }
                    else if (
    args[argOffset].startsWith("-pass"))
                    {
                        
    argOffset++;
                        
    password args[argOffset];
                    }

                    
    argOffset++;
                }

                if (
    argOffset >= args.length)
                {
                    
    printUsage();
                    return;
                }

                
    // create a connection URL
                
    JMXServiceURL serviceURL = new JMXServiceURL(jmxURL);

                
    // create a environment hash with username and password
                
    Map<StringObjectenv = new HashMap<StringObject>();

                if (
    username != null && password != null)
                {
                    
    String[] creds = {usernamepassword};
                    
    env.put(JMXConnector.CREDENTIALScreds);
                }

                
    JMXConnector connector JMXConnectorFactory.connect(serviceURLenv);
                
    MBeanServerConnection connection connector.getMBeanServerConnection();

                if (
    connection == null)
                {
                    
    System.out.println("ERROR: Cannot connect to JMX interface: "+jmxURL);
                    return;
                }

                if (
    args[argOffset].equalsIgnoreCase(CMD_GETSERVERVERSION))
                {
                    
    String connectsName MBEANNAME+":name=Server";
                    
    ObjectName connectsObjName = new ObjectName(connectsName);

                    
    Object attrObj doGetAttribute(connectionconnectsObjName"version");
                    if (
    attrObj != null)
                        
    System.out.println(attrObj);
                    else
                        
    System.out.println("unknown");
                }
                else if (
    args[argOffset].equalsIgnoreCase(CMD_STARTVHOST))
                {
                    
    String connectsName MBEANNAME+":name=Server";
                    
    ObjectName connectsObjName = new ObjectName(connectsName);

                    
    System.out.println(args[argOffset]+" "+args[argOffset+1]);
                    
    Object[] arguments = {args[argOffset+1]};
                    
    String[] signature = {"java.lang.String"};
                    
    doInvoke(connectionconnectsObjName"startVHost"argumentssignature);
                }
                else if (
    args[argOffset].equalsIgnoreCase(CMD_STOPVHOST))
                {
                    
    String connectsName MBEANNAME+":name=Server";
                    
    ObjectName connectsObjName = new ObjectName(connectsName);

                    
    System.out.println(args[argOffset]+" "+args[argOffset+1]);
                    
    Object[] arguments = {args[argOffset+1]};
                    
    String[] signature = {"java.lang.String"};
                    
    doInvoke(connectionconnectsObjName"stopVHost"argumentssignature);
                }
                else if (
    args[argOffset].equalsIgnoreCase(CMD_RELOADVHOSTCONFIG))
                {
                    
    String connectsName MBEANNAME+":name=Server";
                    
    ObjectName connectsObjName = new ObjectName(connectsName);

                    
    System.out.println(args[argOffset]);
                    
    Object[] arguments = {};
                    
    String[] signature = {};
                    
    doInvoke(connectionconnectsObjName"reloadVHostConfig"nullnull);
                }
                else if (
    args[argOffset].equalsIgnoreCase(CMD_STARTAPPINSTANCE))
                {
                    
    System.out.println(args[argOffset]+" "+args[argOffset+1]);

                    
    AppConextName context = new AppConextName(args[argOffset+1], true);

                    
    String connectsName MBEANNAME+":vHosts=VHosts,vHostName="+context.vhostName+",name=VHost";
                    
    ObjectName connectsObjName = new ObjectName(connectsName);

                    
    Object[] arguments = {context.appNamecontext.appInstName};
                    
    String[] signature = {"java.lang.String""java.lang.String"};
                    
    doInvoke(connectionconnectsObjName"startApplicationInstance"argumentssignature);
                }
                else if (
    args[argOffset].equalsIgnoreCase(CMD_TOUCHAPPINSTANCE))
                {
                    
    System.out.println(args[argOffset]+" "+args[argOffset+1]);

                    
    AppConextName context = new AppConextName(args[argOffset+1], true);

                    
    String connectsName MBEANNAME+":vHosts=VHosts,vHostName="+context.vhostName+",name=VHost";
                    
    ObjectName connectsObjName = new ObjectName(connectsName);

                    
    Object[] arguments = {context.appNamecontext.appInstName};
                    
    String[] signature = {"java.lang.String""java.lang.String"};
                    
    doInvoke(connectionconnectsObjName"touchApplicationInstance"argumentssignature);
                }
                else if (
    args[argOffset].equalsIgnoreCase(CMD_SHUTDOWNAPPINSTANCE))
                {
                    
    System.out.println(args[argOffset]+" "+args[argOffset+1]);

                    
    AppConextName context = new AppConextName(args[argOffset+1], true);

                    
    String connectsName MBEANNAME+":vHosts=VHosts,vHostName="+context.vhostName+",applications=Applications,applicationName="+context.appName+",name=Application";
                    
    ObjectName connectsObjName = new ObjectName(connectsName);

                    
    Object[] arguments = {context.appInstName};
                    
    String[] signature = {"java.lang.String"};
                    
    doInvoke(connectionconnectsObjName"shutdownAppInstance"argumentssignature);
                }
                else if (
    args[argOffset].equalsIgnoreCase(CMD_STARTMEDIACASTERSTREAM))
                {
                    
    System.out.println(args[argOffset]+" "+args[argOffset+1]+" "+args[argOffset+2]+" "+args[argOffset+3]);

                    
    AppConextName context = new AppConextName(args[argOffset+1], true);

                    
    String connectsName MBEANNAME+":vHosts=VHosts,vHostName="+context.vhostName+",applications=Applications,applicationName="+context.appName+",applicationInstances=ApplicationInstances,applicationInstanceName="+context.appInstName+",name=ApplicationInstance";
                    
    ObjectName connectsObjName = new ObjectName(connectsName);

                    
    Object[] arguments = {args[argOffset+2], args[argOffset+3]};
                    
    String[] signature = {"java.lang.String""java.lang.String"};
                    
    doInvoke(connectionconnectsObjName"startMediaCasterStream"argumentssignature);
                }
                else if (
    args[argOffset].equalsIgnoreCase(CMD_STOPMEDIACASTERSTREAM))
                {
                    
    System.out.println(args[argOffset]+" "+args[argOffset+1]+" "+args[argOffset+2]);

                    
    AppConextName context = new AppConextName(args[argOffset+1], true);

                    
    String connectsName MBEANNAME+":vHosts=VHosts,vHostName="+context.vhostName+",applications=Applications,applicationName="+context.appName+",applicationInstances=ApplicationInstances,applicationInstanceName="+context.appInstName+",name=ApplicationInstance";
                    
    ObjectName connectsObjName = new ObjectName(connectsName);

                    
    Object[] arguments = {args[argOffset+2]};
                    
    String[] signature = {"java.lang.String"};
                    
    doInvoke(connectionconnectsObjName"stopMediaCasterStream"argumentssignature);
                }
                else if (
    args[argOffset].equalsIgnoreCase(CMD_RESETMEDIACASTERSTREAM))
                {
                    
    System.out.println(args[argOffset]+" "+args[argOffset+1]+" "+args[argOffset+2]);

                    
    AppConextName context = new AppConextName(args[argOffset+1], true);

                    
    String connectsName MBEANNAME+":vHosts=VHosts,vHostName="+context.vhostName+",applications=Applications,applicationName="+context.appName+",applicationInstances=ApplicationInstances,applicationInstanceName="+context.appInstName+",name=ApplicationInstance";
                    
    ObjectName connectsObjName = new ObjectName(connectsName);

                    
    Object[] arguments = {args[argOffset+2]};
                    
    String[] signature = {"java.lang.String"};
                    
    doInvoke(connectionconnectsObjName"resetMediaCasterStream"argumentssignature);
                }
                else if (
    args[argOffset].equalsIgnoreCase(CMD_GETCONNECTIONCOUNTS))
                {
                    
    StringBuffer outputBuf = new StringBuffer();

                    
    String streamNamesStr null;
                    
    AppConextName context null;
                    if (
    args.length > (argOffset+2))
                    {
                        
    context = new AppConextName(args[argOffset+1], true);
                        
    streamNamesStr args[argOffset+2];
                    }
                    else if (
    args.length > (argOffset+1))
                        
    context = new AppConextName(args[argOffset+1], false);
                    else
                        
    context = new AppConextName();

                    if (
    streamNamesStr != null)
                    {
                        
    String[] streamNames streamNamesStr.split("[|]");

                        
    String contextStr context.getObjName();
                        if (
    contextStr.length() > 0)
                            
    contextStr += ",";
                        
    String connectsName MBEANNAME+":"+contextStr+"name=ApplicationInstance";
                        
    ObjectName connectsObjName = new ObjectName(connectsName);

                        
    long total 0;
                        
    long cupertinoTotal 0;
                        
    long smoothTotal 0;
                        
    long rtspTotal 0;
                        
    long rtmpTotal 0;
                        for(
    int i=0;i<streamNames.length;i++)
                        {
                            
    String streamName streamNames[i].trim();

                            {
                                
    Object[] arguments = {SESSIONPROTOCOL_CUPERTINOSTREAMINGstreamName};
                                
    String[] signature = {"int""java.lang.String"};
                                
    Object attrObj doInvoke(connectionconnectsObjName"getHTTPStreamerSessionCount"argumentssignature);
                                
    cupertinoTotal += objToLong(attrObj);
                            }
                            {
                                
    Object[] arguments = {SESSIONPROTOCOL_SMOOTHSTREAMINGstreamName};
                                
    String[] signature = {"int""java.lang.String"};
                                
    Object attrObj doInvoke(connectionconnectsObjName"getHTTPStreamerSessionCount"argumentssignature);
                                
    smoothTotal += objToLong(attrObj);
                            }
                            {
                                
    Object[] arguments = {streamName};
                                
    String[] signature = {"java.lang.String"};
                                
    Object attrObj doInvoke(connectionconnectsObjName"getPlayStreamCount"argumentssignature);
                                
    rtmpTotal += objToLong(attrObj);
                            }
                            {
                                
    Object[] arguments = {streamName};
                                
    String[] signature = {"java.lang.String"};
                                
    Object attrObj doInvoke(connectionconnectsObjName"getRTPSessionCount"argumentssignature);
                                
    rtspTotal += objToLong(attrObj);
                            }
                        }

                        
    total cupertinoTotal+smoothTotal+rtmpTotal+rtspTotal;
                        
    System.out.println(STREAMINGTYPES_TOTAL+":"+total+" "+STREAMINGTYPES_CUPERTINO+":"+cupertinoTotal+" "+STREAMINGTYPES_SMOOTH+":"+smoothTotal+" "+STREAMINGTYPES_RTMP+":"+rtmpTotal+" "+STREAMINGTYPES_RTSP+":"+rtspTotal);

                    }
                    else
                    {
                        for(
    int i=0;i<countStrs.length;i++)
                        {
                            
    String contextStr context.getObjName();
                            if (
    contextStr.length() > 0)
                                
    contextStr += ",";
                            
    String connectsName MBEANNAME+":"+contextStr+"name="+countStrs[i][0];
                            
    ObjectName connectsObjName = new ObjectName(connectsName);

                            
    Object attrObj doGetAttribute(connectionconnectsObjName"current");

                            
    String valueStr attrObj==null?"0":attrObj.toString();
                            if (
    outputBuf.length() > 0)
                                
    outputBuf.append(" ");
                            
    outputBuf.append(countStrs[i][1]+":"+valueStr);
                        }
                    }

                    
    System.out.println(outputBuf.toString());
                }
                else if (
    args[argOffset].equalsIgnoreCase(CMD_GETIOOUTBYTERATE) ||
                        
    args[argOffset].equalsIgnoreCase(CMD_GETIOINBYTERATE))
                {
                    
    StringBuffer outputBuf = new StringBuffer();

                    
    AppConextName context null;
                    if (
    args.length > (argOffset+1))
                        
    context = new AppConextName(args[argOffset+1], false);
                    else
                        
    context = new AppConextName();

                    
    String attrValue args[argOffset].equalsIgnoreCase(CMD_GETIOOUTBYTERATE)?"messagesOutBytesRate":"messagesInBytesRate";

                    for(
    int i=0;i<ioStrs.length;i++)
                    {
                        
    String contextStr context.getObjName();
                        if (
    contextStr.length() > 0)
                            
    contextStr += ",";
                        
    String connectsName MBEANNAME+":"+contextStr+"name="+ioStrs[i][0];
                        
    ObjectName connectsObjName = new ObjectName(connectsName);

                        
    Object attrObj doGetAttribute(connectionconnectsObjNameattrValue);

                        
    String valueStr attrObj==null?"0":attrObj.toString();
                        if (
    outputBuf.length() > 0)
                            
    outputBuf.append(" ");
                        
    outputBuf.append(countStrs[i][1]+":"+valueStr);
                    }

                    
    System.out.println(outputBuf.toString());
                }
                else
                    
    System.out.println("ERROR: Command not recognized: "+args[argOffset]);
            }
            catch (
    Exception e)
            {
                
    System.out.println("ERROR: "+e.toString());
            }
        }

    Compile it :
    PHP Code:
    javac JMXCommandLine.java 
    And after that, a bunch of files will be generated :
    JMXCommandLine$AppConextName.class
    JMXCommandLine.class
    JMXCommandLine.java

    Let's try if the script works. Make sure you in /home/ubuntu/scripts to execute this command :
    PHP Code:
    java -cp JMXCommandLine 
    and it will return a lot of options that can be used. For example i want to know the wowza server version: ( username "admin" password "admin )

    PHP Code:
    java JMXCommandLine -jmx service:jmx:rmi://localhost:8084/jndi/rmi://localhost:8085/jmxrmi -user admin -pass admin getServerVersion 
    it will return
    PHP Code:
    Wowza Media Server 3 Perpetual Edition 3.5.0 build2989 
    Now the script is running find, lets try to get connection counts. Make sure you play vod using any player ( rtmp,hls,rtsp ) and try execute this command :

    PHP Code:
    java -cp /home/ubuntu/scripts JMXCommandLine -jmx service:jmx:rmi://localhost:8084/jndi/rmi://localhost:8085/jmxrmi -user admin -pass admin getConnectionCounts 
    it will return:
    PHP Code:
    total:0 cupertino:0 smooth:0 rtmp:0 rtsp:
    Now it is time to create a bash script:

    get_wowza_connections.sh
    ==================
    PHP Code:
    #!/bin/bash
    TOTALCONNS=`java -cp /home/ubuntu/scripts JMXCommandLine -jmx service:jmx:rmi://localhost:8084/jndi/rmi://localhost:8085/jmxrmi -user admin -pass admin getConnectionCounts`
    LIVECONNS=`java  -cp /home/ubuntu/scripts JMXCommandLine -jmx service:jmx:rmi://localhost:8084/jndi/rmi://localhost:8085/jmxrmi -user admin -pass admin getConnectionCounts _defaultVHost_:live`
    #echo "10"
    #echo "11"
    echo "$TOTALCONNS"
    echo "$LIVECONNS
    try run the script using full path :
    PHP Code:
    sh /home/ubuntu/scripts/get_wowza_connections.sh 
    Next install MRTG on UBUNTU
    =====================
    sudo apt-get install mrtg
    create a directory in /etc/mrtg and move /etc/mrtg.cfg into /etc/mrtg/mrtg.cfg

    Edit /etc/mrtg/mrtg.cfg
    PHP Code:
    ### Global Config Options
    RunAsDaemonYes
    Interval
    5
    Logdir
    : /var/log/
    EnableIPv6no
    #  webserver htdocs location
    WorkDir: /var/www/mrtg

    Target
    [edge1.conns]: `/home/ubuntu/scripts/get_wowza_connections.sh`
    Directory[edge1.conns]:    wowza
    Options
    [edge1.conns]: nopercent,growright,gauge,noinfo
    Title
    [edge1.conns]: Open Wowza connections  -- Wowza Master
    PageTop
    [edge1.conns]: <H1>Open Wowza connections  -- wowza master</H1>
    MaxBytes[edge1.conns]: 10000
    YLegend
    [edge1.conns]: # conns
    ShortLegend[edge1.conns]: connections
    LegendI
    [edge1.conns]:  Total Connections:
    LegendO[edge1.conns]:  Live Cons
    Legend1
    [edge1.conns]: Open Wowza connections  -- wowza 
    Create this folder :
    PHP Code:
     mkdir  /var/www/mrtg 
    Run mrtg :
    PHP Code:
    /etc/init.d/mrtg start 
    Check the folder after 5-10 minutes
    PHP Code:
    ls -/var/www/mrtg 
    Should be a wowza folder inside the folder

    Now, it's time to install a webserver and I'm using apache.
    PHP Code:
    sudo apt-get install apache 
    Time to tell apache to use /var/www/ as DocumentRoot in /etc/apache2/sites-enabled/000-default

    Start Apache :
    PHP Code:
     /etc/init.d/apache2 start 
    Using your browser, point to http://<ip-server>/wowza/*

    Your graph should be there


    Written for Wowza Community
    =====================

    Azril Nazli Alias
    Stream.my
    Skype: azrilnazli
    Last edited by azrilnazli; 01-10-2013 at 08:47 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •