aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/bin/data/sim.html
blob: 82d4789caa443ee9eac4c85002ef5947f2c3dd4f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Simulator statistics</title>
<link rel="stylesheet" href="sim.css" type="text/css"/>
<!-- <script type="text/javascript" src="jquery.js"></script> -->
<!-- <script type="text/javascript" src="https://code.jquery.com/jquery-1.9.0.min.js"></script> -->
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
<!-- <script type="text/javascript" src="https://ajax.aspnetcdn.com/ajax/libs/jQuery/jquery-1.9.0.min.js"></script> -->
<noscript>
<p color="red">
Your browser does not support Javascript. This won't work for you.
</p>
</noscript>
<script type="text/javascript">
$(document).ready(function() {
    // Major divisions in the content accordioning
    $('.SimSection').show('slow');
    $('.SimSectionHeader').click(function() {
        $(this).next().slideToggle('slow');
        return false;
    });

    // Start the timed functions
    TimerDataStuff();
});

// One of the sections is viewer statistics. Poll for the data.
var statTimerHandle;
var graphFPS;
var lastFPS = 10;
var xxThru = 0;
function TimerDataStuff() {
    statTimerHandle = setInterval('TimerStatDisplay()', 5000);
}

// called by timer to fetch and display statistic information
var doingStatDisplay = false;
function TimerStatDisplay() {
    if (doingStatDisplay) return;
    doingStatDisplay = true;
    if ($('#SimSimStats').is(':visible')) {
        DisplaySimStats();
    }
    if ($('#SimRegionStats').is(':visible')) {
        DisplayPerRegionStats();
    }
    if ($('#SimSessionStats').is(':visible')) {
        DisplaySessionStats();
    }
    if ($('#SimLogFile').is(':visible')) {
        DisplayLogFile();
    }
    doingStatDisplay = false;
}

var simName = "127.0.0.1";
var simPort = "9000";
function DisplaySimStats() {
    var statURL = "http://" + simName + ":" + simPort + "/SStats/?json=1";
    $.ajax({
        type: "GET",
        url: statURL,
        dataType: 'json',
        timeout: 1000,
        success: function(data, status) {
            if (status == 'success') {
                DisplaySimStatDetails(data);
            }
        },
        error: function(xmlHTTPRequest, errorType) {
            // DebugLog('Failed fetch');
        }
    });
}

function DisplayPerRegionStats() {
    var statURL = "http://" + simName + ":" + simPort + "/SStats/simstatsajax.html?json=1";
    $.ajax({
        type: "GET",
        url: statURL,
        dataType: 'json',
        timeout: 1000,
        success: function(data, status) {
            if (status == 'success') {
                DisplayRegionStatDetails(data);
            }
        },
        error: function(xmlHTTPRequest, errorType) {
            // DebugLog('Failed fetch');
        }
    });
};

function DisplayLogFile() {
    var statURL = "http://" + simName + ":" + simPort + "/SStats/activelogajax.html?json=1";
    $.ajax({
        type: "GET",
        url: statURL,
        dataType: 'json',
        timeout: 1000,
        success: function(data, status) {
            if (status == 'success') {
                DisplayLogFileDetails(data);
            }
        },
        error: function(xmlHTTPRequest, errorType) {
            // DebugLog('Failed fetch');
        }
    });
};

function DisplaySessionStats() {
    var statURL = "http://" + simName + ":" + simPort + "/SStats/activeconnectionsajax.html?json=1";
    $.ajax({
        type: "GET",
        url: statURL,
        dataType: 'json',
        timeout: 1000,
        success: function(data, status) {
            if (status == 'success') {
                DisplaySessionStatsDetails(data);
            }
        },
        error: function(xmlHTTPRequest, errorType) {
            // DebugLog('Failed fetch');
        }
    });
};

function DisplaySimStatDetails(data) {
    var simInfo = new StringBuffer();
    simInfo.append('<table id="RegionStatsTable">');
    simInfo.append('<tr>');
    simInfo.append('<th>Total Users</th>');
    simInfo.append('<th>Total Sessions</th>');
    simInfo.append('<th>Avg client FPS</th>');
    simInfo.append('<th>Avg client Mem</th>');
    simInfo.append('<th>Avg ping time</th>');
    simInfo.append('<th>KB out</th>');
    simInfo.append('<th>KB in</th>');
    simInfo.append('</tr>');
    simInfo.append('<tr>');
    simInfo.append('<td>' + data.totalUsers + '</td>');
    simInfo.append('<td>' + data.totalSessions + '</td>');
    simInfo.append('<td>' + data.averageClientFPS + '</td>');
    simInfo.append('<td>' + data.averageClientMem + '</td>');
    simInfo.append('<td>' + data.averagePingTime + '</td>');
    simInfo.append('<td>' + data.totalKBOut + '</td>');
    simInfo.append('<td>' + data.totalKBIn + '</td>');
    simInfo.append('</tr>');
    simInfo.append('</table>');
    $('#SimSimStats').empty();
    $('#SimSimStats').append(simInfo.toString());
}

function DisplayRegionStatDetails(data) {
    var regionInfo = new StringBuffer();
    regionInfo.append('<table id="RegionStatsTable">');
    regionInfo.append('<tr>');
    regionInfo.append('<th>Region</th>');
    regionInfo.append('<th>Agents</th>');
    regionInfo.append('<th>Child</th>');
    regionInfo.append('<th>FPS</th>');
    regionInfo.append('<th>Frame Time</th>');
    regionInfo.append('<th>Phys Time</th>');
    regionInfo.append('<th>Prims</th>');
    regionInfo.append('</tr>');
    for (region in data) {
        regionInfo.append('<tr>');
        regionInfo.append('<td>' + data[region].region + '</td>');
        regionInfo.append('<td>' + data[region].rootAgents + '</td>');
        regionInfo.append('<td>' + data[region].childAgents + '</td>');
        regionInfo.append('<td>' + data[region].simFPS + '</td>');
        regionInfo.append('<td>' + data[region].totalFrameTime + '</td>');
        regionInfo.append('<td>' + data[region].physicsFrameTime + '</td>');
        regionInfo.append('<td>' + data[region].totalPrims + '</td>');
        regionInfo.append('</tr>');
    }
    regionInfo.append('</table>');
    $('#SimRegionStats').empty();
    $('#SimRegionStats').append(regionInfo.toString());
}

function DisplayLogFileDetails(data) {
    var logInfo = new StringBuffer();
    var logPattern = /^(.+),\d\d\d .* \[(.+)\]: (.+)$/;
    for (logLine in data['logLines']) {
        logInfo.append('<div>');
        var logPieces = logPattern.exec(data['logLines'][logLine]);
        if (logPieces) {
            logInfo.append(logPieces[1] + ' [' + logPieces[2]
                    + '] ' + logPieces[3]);
        }
        else {
            logInfo.append(data['logLines'][logLine]);
        }

        logInfo.append('</div>');
    }
    $('#SimLogFile').empty();
    $('#SimLogFile').append(logInfo.toString());
}

function DisplaySessionStatsDetails(data) {
    var userInfo = new StringBuffer();
    userInfo.append('<table>');
    userInfo.append('<tr>');
    userInfo.append('<th>region</th>');
    userInfo.append('<th>user</th>');
    userInfo.append('<th></th>');
    userInfo.append('<th>position</th>');
    userInfo.append('</tr>');
    for (region in data) {
        for (user in data[region]) {
            if (user != 'queues') {
                userInfo.append('<tr>');
                userInfo.append('<td>' + region + '</td>');
                userInfo.append('<td>' + data[region][user].Name + '</td>');
                if (data[region][user].isRoot == 'true') {
                    userInfo.append('<td>root</td>');
                }
                else {
                    userInfo.append('<td>child</td>');
                }
                userInfo.append('<td>' + data[region][user].position + '</td>');
                userInfo.append('</tr>');
            }
        }
    }
    userInfo.append('</table>');
    $('#SimSessionStats').empty();
    $('#SimSessionStats').append(userInfo.toString());
}

function DebugLog(msg) {
    $("#DEBUG").append('<div>' + msg + '</div>');
    $("#DEBUG").show();
}

function StringBuffer() {
    this.__strings__ = new Array;
}
StringBuffer.prototype.append = function(str) {
    this.__strings__.push(str);
}
StringBuffer.prototype.toString = function() {
    return this.__strings__.join("");
}

</script>
</head>
<body id="SimBody">
<div id="SimHeader"></div>
<div id="SimContent">

<!-- ============================================== -->
<div class="SimSectionContainer">
<a class="SimSectionHeader" href="#">Simulator Stats</a>
<div id="SimSimStats" class="SimSection">
</div>  <!-- SimSimStats -->
</div>  <!-- SimSectionContainer -->

<!-- ============================================== -->
<div class="SimSectionContainer">
<a class="SimSectionHeader" href="#">Region Stats</a>
<div id="SimRegionStats" class="SimSection">
</div>  <!-- SimRegionStats -->
</div>  <!-- SimSectionContainer -->

<!-- ============================================== -->
<div class="SimSectionContainer">
<a class="SimSectionHeader" href="#">Sessions</a>
<div id="SimSessionStats" class="SimSection">
</div>  <!-- SimSessionStats -->
</div>  <!-- SimSectionContainer -->

<!-- ============================================== -->
<div class="SimSectionContainer">
<a class="SimSectionHeader" href="#">Log File</a>
<div id="SimLogFile" class="SimSection">
</div>  <!-- SimLogFile -->
</div>  <!-- SimSectionContainer -->

<!-- ============================================== -->
</div>  <!-- SimContent -->
<div id="DEBUG"></div>
<div id="SimFooter"></div>
</body>
</html>