UXSimStatus/fr

From OpenSimulator

(Difference between revisions)
Jump to: navigation, search
Line 19: Line 19:
  
 
  <source lang="html4strict">
 
  <source lang="html4strict">
 +
 
<!DOCTYPE HTML>
 
<!DOCTYPE HTML>
 
<html>
 
<html>
Line 24: Line 25:
 
<title>JSON Test</title>
 
<title>JSON Test</title>
 
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
 
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="http://husa.github.io/timer.js/dist/timer.js"></script>
 
 
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
 
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
 
<script type="text/javascript" language="JavaScript">
 
<script type="text/javascript" language="JavaScript">
 +
 
SimFPS = 0;
 
SimFPS = 0;
 
PhyFPS = 0;
 
PhyFPS = 0;
Line 34: Line 35:
 
Uptime = "";
 
Uptime = "";
 
Version = "";
 
Version = "";
+
 
var timer = new Timer({
+
setInterval(function(){
tick : 1,
+
ontick : function (sec) {
+
 
$.getJSON(
 
$.getJSON(
 
   "http://ascent.bluewallgroup.com:9100/jsonSimStats/?callback=?",   
 
   "http://ascent.bluewallgroup.com:9100/jsonSimStats/?callback=?",   
Line 50: Line 49:
 
   drawChart();
 
   drawChart();
 
   setTags();
 
   setTags();
   });
+
   })}, 3000
},
+
);
onstart : function() {
+
 
console.log('timer started');
+
 
},
+
onend : function() {
+
          console.log("Timer stopped");
+
          this.start(100);
+
        }
+
});
+
+
 
google.load("visualization", "1", {packages:["gauge"]});
 
google.load("visualization", "1", {packages:["gauge"]});
 
google.setOnLoadCallback(drawChart);
 
google.setOnLoadCallback(drawChart);
Line 74: Line 66:
 
   cdata.setValue(2, 0, 'Memory');
 
   cdata.setValue(2, 0, 'Memory');
 
   cdata.setValue(2, 1, Memory);
 
   cdata.setValue(2, 1, Memory);
+
 
 
   var chart = new
 
   var chart = new
 
     google.visualization.Gauge(document.getElementById('chart_div'));
 
     google.visualization.Gauge(document.getElementById('chart_div'));
Line 81: Line 73:
 
   chart.draw(cdata, options);
 
   chart.draw(cdata, options);
 
}
 
}
+
 
 
$(function() {
 
$(function() {
 
     timer.start(100);
 
     timer.start(100);
 
     });
 
     });
+
 
 
function setTags() {
 
function setTags() {
 
   $("#par-uptime").text("Uptime: "  + Uptime);
 
   $("#par-uptime").text("Uptime: "  + Uptime);
Line 93: Line 85:
 
}
 
}
 
</script>
 
</script>
+
 
 
</head>
 
</head>
 
<body>
 
<body>
Line 111: Line 103:
 
</body>
 
</body>
 
</html>
 
</html>
 +
 
  </source>
 
  </source>
  

Revision as of 18:22, 1 January 2015

Depuis OpenSimulator svn 9529 les statistiques étendues retournent un appel jsonp pour autoriser les outils javascript populaires à utiliser les données retournées pour créer une application de monitoring AJAX dans le navigateur. Ceci est un avantage car une fois que la page est chargée le navigateur va inter agir directement avec la région en éliminant le trafic par le site web (en sondant la région et nourissant le navigateur). Elles permettent aussi la création d'outils permettant de créer des applications dans d'autres pages.

Pour activer vos reports de données, définissez ceci dans votre OpenSim.ini...

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

...l'URI peut être ce que vous voulez et est sensible à la casse. Vous pouvez questionner directement l'URI pour retourner une chaîne JSON à utiliser dans php, python, java, etc ou bien vous pouvez utiliser un des outils populaires javascript afin qu'OpenSimulator génère un callback pour jsonp. La sérialisation JSON transporte les données suivantes...

 {"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>
<head>
<title>JSON Test</title>
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
<script type="text/javascript" language="JavaScript">
 
SimFPS = 0;
PhyFPS = 0;
Memory = 0;
RootAg = 0;
ChldAg = 0;
Uptime = "";
Version = "";
 
setInterval(function(){
$.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() {
  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() {
    timer.start(100);
    });
 
function setTags() {
  $("#par-uptime").text("Uptime: "  + Uptime);
  $("#par-ragent").text("Root Agent: " + RootAg);
  $("#par-version").text("Version: " + Version);
  $("#par-cagent").text("Child Agent: " + ChldAg);
}
</script>
 
</head>
<body>
= BlueWall Development Region =
<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>

JSON Grid Simstats

Exemple python pour obtenir les données de région depuis un service de grille - devrait fonctionner mais cette version n'a pas été testée -

        *reference material* 
import hashlib
 import urllib2
 
 ''' la valeur montrée est un exemple, récupérez ceci depuis votre base de donnée de la grille à chaque fois - regions.regionSecret '''
 regionsecret = 'fe21314b-6267-44f7-aa1e-6047e1c3f94a'
 
 ''' Ma region host '''
 hostName =  myregion.host.net
 
 ''' Ma region port '''
 hostPort = 9000
 
 ''' crée un SHA1 en majuscules depuis le regionSecret '''
 resourceName = str(hashlib.sha1(regionsecret).hexdigest()).upper()
 
 regionuri = hostName + ":" + hostPort + "/" + resourceName + "/"
 
 ''' les données incluent TimeZoneName , TimeZoneOffs, UxTime, Memory, Version et OSStatsURI '''
 regiondata = simplejson.load(urllib2.urlopen(regionuri))
 
 ''' OSStatsURI est l'uri de requete de l'instance OpenSimulator. Retourne les même données avec l'uri fournie par l'utilisateur '''
 simuri = regiondata['OSStatsURI']
 
 simdata = simplejson.load(urllib2.urlopen(simuri))
Personal tools
General
About This Wiki