Fold class list into general server stats

This commit is contained in:
Tony Garnock-Jones 2012-04-29 21:47:01 -04:00
parent 01e420ad97
commit 0f8efaf4cf
4 changed files with 18 additions and 13 deletions

View File

@ -63,12 +63,9 @@ let api_server_stats id r =
Json.resp_ok [] (Json.Rec
["connection_count", Json.Num (float_of_int !Connections.connection_count);
"boot_time", Json.Num boot_time;
"uptime", Json.Num (Unix.time () -. boot_time)])
let api_all_classes id r =
Json.resp_ok [] (Json.Arr (List.map Json.str (Factory.all_class_names ())))
"uptime", Json.Num (Unix.time () -. boot_time);
"classes", Json.Arr (List.map Json.str (Factory.all_class_names ()))])
let init () =
register_dispatcher ("/_/server_stats", api_server_stats);
register_dispatcher ("/_/all_classes", api_all_classes);
ignore (Util.create_thread "HTTP listener" None (Net.start_net "HTTP" 5678) start)

View File

@ -14,11 +14,14 @@
</tr>
<tr>
<th class="span6">Boot time</th>
<td class="span6" id="server_stats_boot_time"></td>
<td class="span6">
<span id="server_stats_boot_time"/>;
up <span id="server_stats_uptime"/> seconds
</td>
</tr>
<tr>
<th class="span6">Uptime</th>
<td class="span6" id="server_stats_uptime"></td>
<th class="span6">Available node classes</th>
<td class="span6" id="server_classes"></td>
</tr>
</table>

View File

@ -35,11 +35,14 @@
</tr>
<tr>
<th class="span6">Boot time</th>
<td class="span6" id="server_stats_boot_time"></td>
<td class="span6">
<span id="server_stats_boot_time"></span>;
up <span id="server_stats_uptime"></span> seconds
</td>
</tr>
<tr>
<th class="span6">Uptime</th>
<td class="span6" id="server_stats_uptime"></td>
<th class="span6">Available node classes</th>
<td class="span6" id="server_classes"></td>
</tr>
</table>

View File

@ -5,7 +5,8 @@ function server_disconnected() {
$("#server_ok").text("Disconnected");
$("#server_stats_connection_count").text("—");
$("#server_stats_boot_time").text("—");
$("#server_stats_uptime").text("— seconds");
$("#server_stats_uptime").text("—");
$("#server_classes").text("—");
}
function refresh_server_stats() {
@ -14,7 +15,8 @@ function refresh_server_stats() {
$("#server_ok").text("OK");
$("#server_stats_connection_count").text(data.connection_count);
$("#server_stats_boot_time").text(new Date(data.boot_time * 1000));
$("#server_stats_uptime").text(data.uptime + " seconds");
$("#server_stats_uptime").text(data.uptime);
$("#server_classes").text(data.classes.join(", "));
switch ($tap.readyState) {
case 0: // connecting
case 1: // open