From OpenSimulator

Revision as of 00:55, 12 October 2018 by Manni (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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.

"AgntFt":0.0,"ImgsFt":0.0,"Memory":"8","Uptime":"05:12:19.0365590","Version":"OpenSimulator Server "}
<source lang="html4strict">
<title>JSON Test</title>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script src="http://www.google.com/jsapi"></script>
SimFPS = 0;
PhyFPS = 0;
Memory = 0;
RootAg = 0;
ChldAg = 0;
Uptime = "";
Version = "";
var url = "http://<IP_OR_DOMAIN>:<PORT>/jsonSimStats/?callback=?";
setInterval(function() {$.getJSON(url, 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;
})}, 3000);
google.load("visualization", "1.0", {packages:["gauge"]});
function drawChart() {
    var cdata = new google.visualization.DataTable();
    cdata.addColumn('string', 'Label');
    cdata.addColumn('number', 'Value');
    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-uptime").text("Uptime: "  + Uptime);
    $("#par-ragent").text("Root Agent: " + RootAg);
    $("#par-version").text("Version: " + Version);
    $("#par-cagent").text("Child Agent: " + ChldAg);
= BlueWall Development Region =
        <td><div id="par-version">Version:</div></td>
        <td><div id="par-ragent">Root Agent:</div></td>
        <td><div id="par-uptime">Uptime:</div></td>
        <td><div id="par-cagent">Child Agent:</div></td>
<div id="chart_div"></div>

Note: If you are having problems with cross-origin, you can try this script UXSimStatus_Aternatif.

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))

See too SSL in OpenSim

Personal tools
About This Wiki