UXSimStatus

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
(Fix cross site)
Line 15: Line 15:
 
     Stats_URI = "jsonSimStats"
 
     Stats_URI = "jsonSimStats"
  
...the URI can be anything you want, and is case sensitive. You can query
+
The URI can be anything you want, and is case sensitive. You can query
 
the URI directly to return a json string to use in php, python, java, etc.
 
the URI directly to return a json string to use in php, python, java, etc.
 
or you may use one of the popular javascript toolkits to have OpenSimulator
 
or you may use one of the popular javascript toolkits to have OpenSimulator
 
generate a callback for jsonp. The json serialization carries the following
 
generate a callback for jsonp. The json serialization carries the following
data...
+
data.
 
+
{"AssetsInCache":5.0,"TimeAfterCacheMiss":0.0,"BlockedMissingTextureRequests":0.0,"AssetServiceRequestFailures":0.0,
  {"AssetsInCache":5.0,"TimeAfterCacheMiss":0.0,"BlockedMissingTextureRequests":0.0,"AssetServiceRequestFailures":0.0,
+
 
  "abnormalClientThreadTerminations":0.0,"InventoryServiceRetrievalFailures":0.0,"Dilatn":0.967380821704865,"SimFPS":55.0,
 
  "abnormalClientThreadTerminations":0.0,"InventoryServiceRetrievalFailures":0.0,"Dilatn":0.967380821704865,"SimFPS":55.0,
 
  "PhyFPS":47.1628913879395,"AgntUp":0.0,"RootAg":0.0,"ChldAg":0.0,"Prims":0.0,"AtvPrm":0.0,"AtvScr":0.0,"ScrLPS":0.0,
 
  "PhyFPS":47.1628913879395,"AgntUp":0.0,"RootAg":0.0,"ChldAg":0.0,"Prims":0.0,"AtvPrm":0.0,"AtvScr":0.0,"ScrLPS":0.0,
 
  "PktsIn":0.0,"PktOut":0.0,"PendDl":0.0,"PendUl":0.0,"UnackB":0.0,"TotlFt":0.0,"NetFt":0.0,"PhysFt":0.0,"OthrFt":0.0,
 
  "PktsIn":0.0,"PktOut":0.0,"PendDl":0.0,"PendUl":0.0,"UnackB":0.0,"TotlFt":0.0,"NetFt":0.0,"PhysFt":0.0,"OthrFt":0.0,
 
  "AgntFt":0.0,"ImgsFt":0.0,"Memory":"8","Uptime":"05:12:19.0365590","Version":"OpenSimulator Server  0.6.4.9533 "}
 
  "AgntFt":0.0,"ImgsFt":0.0,"Memory":"8","Uptime":"05:12:19.0365590","Version":"OpenSimulator Server  0.6.4.9533 "}
 
+
<source lang="html4strict">
 
+
<!doctype html>
<source lang="html4strict">
+
<html lang="en">
 
+
<!DOCTYPE HTML>
+
<html>
+
 
<head>
 
<head>
<title>JSON Test</title>
+
    <meta charset="utf-8">
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
+
    <title>jsonSimStats</title>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
+
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript" language="JavaScript">
+
    <script src="https://www.gstatic.com/charts/loader.js"></script>
 
+
</head>
 +
<body>
 +
<script>
 
SimFPS = 0;
 
SimFPS = 0;
 
PhyFPS = 0;
 
PhyFPS = 0;
Line 45: Line 43:
 
Uptime = "";
 
Uptime = "";
 
Version = "";
 
Version = "";
 +
 +
setInterval(function() {
 +
    $.getJSON("http://<IP_OR_DOMAIN>:<PORT>/jsonSimStats/?callback=?",
 +
    function(data){
 +
        SimFPS = Math.round(data.SimFPS);
 +
        PhyFPS = Math.round(data.PhyFPS);
 +
        Memory = Math.round(data.Memory);
 +
        ChldAg = data.ChldAg;
 +
        RootAg = data.RootAg;
 +
        Uptime = data.Uptime;
 +
        Version = data.Version;
 +
        drawChart();
 +
        setTags();
 +
    })
 +
}, 1000);
  
setInterval(function(){
+
google.charts.load('current', {'packages': ['gauge']});
$.getJSON(
+
  "http://ascent.bluewallgroup.com:9100/jsonSimStats/?callback=?",
+
  function(data){
+
  SimFPS = Math.round(data.SimFPS);
+
  PhyFPS = Math.round(data.PhyFPS);
+
  Memory = Math.round(data.Memory);
+
  ChldAg = data.ChldAg;
+
  RootAg = data.RootAg;
+
  Uptime = data.Uptime;
+
  Version = data.Version;
+
  drawChart();
+
  setTags();
+
  })}, 3000
+
);
+
  
 
google.load("visualization", "1", {packages:["gauge"]});
 
google.setOnLoadCallback(drawChart);
 
 
function drawChart() {
 
function drawChart() {
  var cdata = new google.visualization.DataTable();
+
    var cdata = new google.visualization.DataTable();
  cdata.addColumn('string', 'Label');
+
    cdata.addColumn('string', 'Label');
  cdata.addColumn('number', 'Value');
+
    cdata.addColumn('number', 'Value');
  cdata.addRows(3);
+
    cdata.addRows(3);
  cdata.setValue(0, 0, 'SimFPS');
+
    cdata.setValue(0, 0, 'SimFPS');
  cdata.setValue(0, 1, SimFPS);
+
    cdata.setValue(0, 1, SimFPS);
  cdata.setValue(1, 0, 'PhyFPS');
+
    cdata.setValue(1, 0, 'PhyFPS');
  cdata.setValue(1, 1, PhyFPS);
+
    cdata.setValue(1, 1, PhyFPS);
  cdata.setValue(2, 0, 'Memory');
+
    cdata.setValue(2, 0, 'Memory');
  cdata.setValue(2, 1, Memory);
+
    cdata.setValue(2, 1, Memory);
 
+
    var chart = new google.visualization.Gauge(document.getElementById('chart_div'));
  var chart = new
+
    var options = {width: 400, height: 120, redFrom: 90, redTo: 100, yellowFrom:75, yellowTo: 90, minorTicks: 5};
    google.visualization.Gauge(document.getElementById('chart_div'));
+
    chart.draw(cdata, options);
  var options = {width: 400, height: 120, redFrom: 90, redTo: 100,
+
    yellowFrom:75, yellowTo: 90, minorTicks: 5};
+
  chart.draw(cdata, options);
+
 
}
 
}
 
+
$(function() {
+
    timer.start(100);
+
    });
+
 
+
 
function setTags() {
 
function setTags() {
  $("#par-uptime").text("Uptime: " + Uptime);
+
    $("#par-version").text("Version: " + Version);
  $("#par-ragent").text("Root Agent: " + RootAg);
+
    $("#par-ragent").text("Root Agent: " + RootAg);
  $("#par-version").text("Version: " + Version);
+
    $("#par-uptime").text("Uptime: " + Uptime);
  $("#par-cagent").text("Child Agent: " + ChldAg);
+
    $("#par-cagent").text("Child Agent: " + ChldAg);
 
}
 
}
 
</script>
 
</script>
 +
</head>
  
</head>
 
 
<body>
 
<body>
= BlueWall Development Region =
+
= jsonSimStats =
 
<table>
 
<table>
  <tr><td>
+
    <tr>
      <div id="par-version">version</div>
+
        <td><div id="par-version">Version:</div></td>
    </td><td>
+
        <td><div id="par-ragent">Root Agent:</div></td>
      <div id="par-ragent">root agent</div>
+
    </tr>
  </td></tr><tr><td>
+
    <tr>
      <div id="par-uptime">uptime</div>
+
        <td><div id="par-uptime">Uptime:</div></td>
    </td><td>
+
        <td><div id="par-cagent">Child Agent:</div></td>
      <div id="par-cagent">child agent</div>
+
    </tr>
  </td></tr>
+
 
</table>
 
</table>
 
<div id="chart_div"></div>
 
<div id="chart_div"></div>
 
</body>
 
</body>
 
</html>
 
</html>
 
+
</source>
</source>
+
 
+
 
[[SSL in OpenSim]]
 
[[SSL in OpenSim]]
 
 
== JSON Grid Simstats ==
 
== JSON Grid Simstats ==
 
 
Python example to gain the region data from a grid service
 
Python example to gain the region data from a grid service
 
  - should work but this version not tested -
 
  - should work but this version not tested -
 
         *reference material*  
 
         *reference material*  
  
<source lang="python">
+
<source lang="python">
 
+
 
  import hashlib
 
  import hashlib
 
  import urllib2
 
  import urllib2
Line 150: Line 133:
  
 
  simdata = simplejson.load(urllib2.urlopen(simuri))
 
  simdata = simplejson.load(urllib2.urlopen(simuri))
 
+
</source>
</source>
+

Revision as of 22:02, 4 October 2018

As of OpenSimulator svn 9529 the xtended stats reporting will return a jsonp callback to allow popular javascript toolkits to use the returned data to create ajax monitoring applications in the browser. This is an advantage because after the page is loaded, the browser will interact directly with the region, eliminating traffic through the website (polling the region and servicing the browser). It also allows the creation of mashups to create mini-monitor apps in other pages.

To enable your stats reporting, set the following in your OpenSim.ini...

   ; Simulator Stats URI
   ; Enable JSON simulator data by setting a URI name (case sensitive)
   Stats_URI = "jsonSimStats"

The URI can be anything you want, and is case sensitive. You can query the URI directly to return a json string to use in php, python, java, etc. or you may use one of the popular javascript toolkits to have OpenSimulator generate a callback for jsonp. The json serialization carries the following data.

{"AssetsInCache":5.0,"TimeAfterCacheMiss":0.0,"BlockedMissingTextureRequests":0.0,"AssetServiceRequestFailures":0.0,
"abnormalClientThreadTerminations":0.0,"InventoryServiceRetrievalFailures":0.0,"Dilatn":0.967380821704865,"SimFPS":55.0,
"PhyFPS":47.1628913879395,"AgntUp":0.0,"RootAg":0.0,"ChldAg":0.0,"Prims":0.0,"AtvPrm":0.0,"AtvScr":0.0,"ScrLPS":0.0,
"PktsIn":0.0,"PktOut":0.0,"PendDl":0.0,"PendUl":0.0,"UnackB":0.0,"TotlFt":0.0,"NetFt":0.0,"PhysFt":0.0,"OthrFt":0.0,
"AgntFt":0.0,"ImgsFt":0.0,"Memory":"8","Uptime":"05:12:19.0365590","Version":"OpenSimulator Server  0.6.4.9533 "}
<!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>jsonSimStats</title>
    <script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
    <script src="https://www.gstatic.com/charts/loader.js"></script>
</head>
<body>
<script>
SimFPS = 0;
PhyFPS = 0;
Memory = 0;
RootAg = 0;
ChldAg = 0;
Uptime = "";
Version = "";
 
setInterval(function() {
    $.getJSON("http://<IP_OR_DOMAIN>:<PORT>/jsonSimStats/?callback=?",
    function(data){
        SimFPS = Math.round(data.SimFPS);
        PhyFPS = Math.round(data.PhyFPS);
        Memory = Math.round(data.Memory);
        ChldAg = data.ChldAg;
        RootAg = data.RootAg;
        Uptime = data.Uptime;
        Version = data.Version;
        drawChart();
        setTags();
    })
}, 1000);
 
google.charts.load('current', {'packages': ['gauge']});
 
function drawChart() {
    var cdata = new google.visualization.DataTable();
    cdata.addColumn('string', 'Label');
    cdata.addColumn('number', 'Value');
    cdata.addRows(3);
    cdata.setValue(0, 0, 'SimFPS');
    cdata.setValue(0, 1, SimFPS);
    cdata.setValue(1, 0, 'PhyFPS');
    cdata.setValue(1, 1, PhyFPS);
    cdata.setValue(2, 0, 'Memory');
    cdata.setValue(2, 1, Memory);
    var chart = new google.visualization.Gauge(document.getElementById('chart_div'));
    var options = {width: 400, height: 120, redFrom: 90, redTo: 100, yellowFrom:75, yellowTo: 90, minorTicks: 5};
    chart.draw(cdata, options);
}
 
function setTags() {
    $("#par-version").text("Version: " + Version);
    $("#par-ragent").text("Root Agent: " + RootAg);
    $("#par-uptime").text("Uptime: "  + Uptime);
    $("#par-cagent").text("Child Agent: " + ChldAg);
}
</script>
</head>
 
<body>
= jsonSimStats =
<table>
    <tr>
        <td><div id="par-version">Version:</div></td>
        <td><div id="par-ragent">Root Agent:</div></td>
    </tr>
    <tr>
        <td><div id="par-uptime">Uptime:</div></td>
        <td><div id="par-cagent">Child Agent:</div></td>
    </tr>
</table>
<div id="chart_div"></div>
</body>
</html>

SSL in OpenSim

JSON Grid Simstats

Python example to gain the region data from a grid service

- should work but this version not tested -
        *reference material* 
import hashlib
 import urllib2
 
 ''' value shown is an example, get this from your grid database each time - regions.regionSecret '''
 regionsecret = 'fe21314b-6267-44f7-aa1e-6047e1c3f94a'
 
 ''' My region host '''
 hostName =  myregion.host.net
 
 ''' My region port '''
 hostPort = 9000
 
 ''' create an *UPPERCASE* SHA1 hash from the regionSecret '''
 resourceName = str(hashlib.sha1(regionsecret).hexdigest()).upper()
 
 regionuri = hostName + ":" + hostPort + "/" + resourceName + "/"
 
 ''' data includes TimeZoneName , TimeZoneOffs, UxTime, Memory, Version and OSStatsURI '''
 regiondata = simplejson.load(urllib2.urlopen(regionuri))
 
 ''' OSStatsURI is the uri to query the OpenSimulator instance. return same data as the user set uri '''
 simuri = regiondata['OSStatsURI']
 
 simdata = simplejson.load(urllib2.urlopen(simuri))
Personal tools
General
About This Wiki