Skip to main content
Participating Frequently
February 23, 2010
Answered

How to make getServerStats() API call?

  • February 23, 2010
  • 1 reply
  • 1385 views

How to make getServerStats() API call?

    This topic has been closed for replies.
    Correct answer Janaki Lakshmikanthan

    Hi,
    Here you go..

    1. To make rtmp call use the code

    var admin_nc = new NetConnection();
    var callResponder = new Responder(result_callResponder, status_callResponder);

    admin_nc.addEventListener(NetStatusEvent.NET_STATUS, nc_status);
    admin_nc.connect("rtmp://10.192.22.92:1111/admin", "admin", "admin");


    function nc_status(event:NetStatusEvent):void{
    trace("nc status " + event.info.code);
    if(event.info.code=="NetConnection.Connect.Success"){
      admin_nc.call("getServerStats", callResponder);
           
    }

    }

    function result_callResponder(info:Object):void{
    trace("result_callResponder");
    for(var prop in info.data){
      trace("property:" + prop + " - " + info.data[prop]);
    }
    }

    function status_callResponder(eve:Event):void{
    trace("status_callResponder");
    }


    2. To make http call - enter "http://10.192.22.92:1111/admin/getServerStats?

    auser=admin&apswd=admin" in your browser and hit enter. Before that make sure you

    have enabled this command in your users.xml file. To do so, open <installed fms

    dir>/conf/users.xml. Edit the tag "Root > AdminServer > HTTPCommands > Allow" and

    enter the value "All" for it. Save and restart the server, then try the http

    command.

    Regards,
    Janaki L

    1 reply

    Janaki Lakshmikanthan
    Adobe Employee
    Janaki LakshmikanthanCorrect answer
    Adobe Employee
    February 23, 2010

    Hi,
    Here you go..

    1. To make rtmp call use the code

    var admin_nc = new NetConnection();
    var callResponder = new Responder(result_callResponder, status_callResponder);

    admin_nc.addEventListener(NetStatusEvent.NET_STATUS, nc_status);
    admin_nc.connect("rtmp://10.192.22.92:1111/admin", "admin", "admin");


    function nc_status(event:NetStatusEvent):void{
    trace("nc status " + event.info.code);
    if(event.info.code=="NetConnection.Connect.Success"){
      admin_nc.call("getServerStats", callResponder);
           
    }

    }

    function result_callResponder(info:Object):void{
    trace("result_callResponder");
    for(var prop in info.data){
      trace("property:" + prop + " - " + info.data[prop]);
    }
    }

    function status_callResponder(eve:Event):void{
    trace("status_callResponder");
    }


    2. To make http call - enter "http://10.192.22.92:1111/admin/getServerStats?

    auser=admin&apswd=admin" in your browser and hit enter. Before that make sure you

    have enabled this command in your users.xml file. To do so, open <installed fms

    dir>/conf/users.xml. Edit the tag "Root > AdminServer > HTTPCommands > Allow" and

    enter the value "All" for it. Save and restart the server, then try the http

    command.

    Regards,
    Janaki L

    vavoottyAuthor
    Participating Frequently
    February 24, 2010

    Can you please post the code in server side for getServerStats()?...thanks very much!!!!!!!!!!!!

    Janaki Lakshmikanthan
    Adobe Employee
    Adobe Employee
    March 4, 2010

    But how to embed that data in a datagrid instead of alert box? And also is it possible to acess each property individually?


    Hi,
    Definitely. You can load the properties and its value in to the data grid very well. Here is what you have to do.

    function result_callResponder(info:Object):void{
          trace("result_callResponder");
          var myDataProvider:DataProvider = new DataProvider();
          for(var prop in info.data){
                trace("property:" + prop + " - " + info.data[prop]);
                if(prop != "io"){
                      myDataProvider.addItem({Property:prop, Value:info.data[prop]});
                }
                else if(prop == "io"){
                      for(var ioProp in info.data[prop]){
                            trace("ioProp:" + ioProp + " - " + info.data[prop][ioProp]);
                            myDataProvider.addItem({Property:(prop + ":" + ioProp), Value:info.data[prop][ioProp]});
       
                      }
                }
          }
          myDataGrid.dataProvider = myDataProvider;
    }

    Just update the result_callResponder method which i have posted previously with this one. Here myDataGrid is the Data Grid

    which i have added to my stage from the components list.

    You can also access the properties individually by getting the value by calling
    info.data["cpus"]
    info.data["physical_Mem"]
    etc..

    Regards,
    Janaki L