{% extends "base.html" %} {% block js %} var getters = []; (function() { RSgetter = function(shard, plotOptions) { this.shard = shard; this.last_time = {{ timestamp|make_timestamp }} - 60 * 11; this.first = true; } RSgetter.prototype = { update_resources_cb: function(response) { var table = $("#services_" + this.shard + "_table > tbody"); var msg = utils.standard_response(response); if (msg != "") { table.html(''+ msg + ''); return; } var l = response['data'].length; if (l == 0) return; this.last_time = response['data'][l-1][0]; if (this.first) { // Calculate a good spacing for y-axis labels. var tick_increment = function(max_val, max_ticks, min_inc) { var res = min_inc; while (max_val / res > max_ticks) res *= 2; return res; } // CPU this.cpu_graph = $.jqplot("cpu_" + this.shard, [[[-1, -1]], [[-1, -1]], [[-1, -1]]], plotOptions); this.cpu_graph.series[0].label = "User"; this.cpu_graph.series[1].label = "System"; this.cpu_graph.series[2].label = "I/O"; for (var i = 0; i < this.cpu_graph.series.length; i++) this.cpu_graph.series[i].data.length = 0; this.num_cpu = response['data'][0][1]['cpu']['num_cpu']; this.cpu_graph.axes.yaxis.min = 0; this.cpu_graph.axes.yaxis.max = this.num_cpu * 100; this.cpu_graph.axes.yaxis.ticks = []; var ytick = 0; var cpu_ytick_inc = tick_increment(this.num_cpu, 10, 0.25); while (ytick <= this.num_cpu * 100) { this.cpu_graph.axes.yaxis.ticks.push(ytick); ytick += 100 * cpu_ytick_inc; } // Memory this.memory_graph = $.jqplot("memory_" + this.shard, [[[-1, -1]], [[-1, -1]], [[-1, -1]]], plotOptions); this.memory_graph.series[0].label = "Used"; this.memory_graph.series[1].label = "Buffers"; this.memory_graph.series[2].label = "Cache"; for (var i = 0; i < this.memory_graph.series.length; i++) this.memory_graph.series[i].data.length = 0; this.ram_total = response['data'][0][1]['memory']['ram_total']; this.memory_graph.axes.yaxis.min = 0; this.memory_graph.axes.yaxis.max = this.ram_total; this.memory_graph.axes.yaxis.ticks = []; ytick = 0; var ram_ytick_inc = tick_increment(this.ram_total, 10, 1); while (ytick + 100 <= this.ram_total) { this.memory_graph.axes.yaxis.ticks.push(ytick); ytick += ram_ytick_inc; } this.memory_graph.axes.yaxis.ticks.push(this.ram_total); // Swap this.swap_graph = $.jqplot("swap_" + this.shard, [[[-1, -1]]], plotOptions); this.swap_graph.series[0].label = "Used"; for (var i = 0; i < this.swap_graph.series.length; i++) this.swap_graph.series[i].data.length = 0; this.swap_total = response['data'][0][1]['memory']['swap_total']; this.swap_graph.axes.yaxis.min = 0; this.swap_graph.axes.yaxis.max = this.ram_total; this.swap_graph.axes.yaxis.ticks = []; ytick = 0; var swap_ytick_inc = tick_increment(this.swap_total, 10, 1); while (ytick + 100 <= this.swap_total) { this.swap_graph.axes.yaxis.ticks.push(ytick); ytick += swap_ytick_inc; } this.swap_graph.axes.yaxis.ticks.push(this.swap_total); var tmp = []; for (var s in response['data'][l-1][1]['services']) tmp.push([[-1, -1]]); } var xmin = 1000 * (this.last_time - 60*10); var xmax = 1000 * this.last_time; var xticks = []; var xtick = this.last_time - 60*10; while (xtick + 60 <= this.last_time) { xticks.push(1000 * xtick); xtick = parseInt(xtick / 60) * 60 + 120; } xticks.push(1000 * this.last_time); this.cpu_graph.axes.xaxis.ticks = xticks; this.memory_graph.axes.xaxis.ticks = xticks; this.swap_graph.axes.xaxis.ticks = xticks; for (var i = 0; i < l; i++) { var t = 1000 * response['data'][i][0] // CPU this.cpu_graph.series[0].data.push( [t, response['data'][i][1]['cpu']['user']]); this.cpu_graph.series[1].data.push( [t, response['data'][i][1]['cpu']['system']]); this.cpu_graph.series[2].data.push( [t, response['data'][i][1]['cpu']['iowait']]); // Memory this.memory_graph.series[0].data.push( [t, response['data'][i][1]['memory']['ram_used']]); this.memory_graph.series[1].data.push( [t, response['data'][i][1]['memory']['ram_buffers']]); this.memory_graph.series[2].data.push( [t, response['data'][i][1]['memory']['ram_cached']]); // Swap this.swap_graph.series[0].data.push( [t, response['data'][i][1]['memory']['swap_used']]); } this.cpu_graph.replot(); this.memory_graph.replot(); this.swap_graph.replot(); this.first = false; // Services var strings = []; var services = []; for (var s in response['data'][l-1][1]['services']) services.push(s); services.sort(); for (var i = 0; i < services.length; i++) { var s = services[i]; strings.push(''); strings.push(s); if (response['data'][l-1][1]['services'][s]['running'] == false) strings.push('Not running'); else { strings.push(''); strings.push(utils.repr_time_ago_short((new Date()).getTime()/1000 - response['data'][l-1][1]['services'][s]['since'])); {% if admin.permission_all %} if (s.lastIndexOf("LogService,", 0) !== 0 && s.lastIndexOf("ResourceService,", 0) !== 0) strings.push(" [Kill]"); {% endif %} strings.push(''); strings.push(response['data'][l-1][1]['services'][s]['threads']); strings.push(''); strings.push(response['data'][l-1][1]['services'][s]['resident']); strings.push(''); strings.push(response['data'][l-1][1]['services'][s]['virtual']); strings.push(''); strings.push(response['data'][l-1][1]['services'][s]['user']); strings.push(''); strings.push(response['data'][l-1][1]['services'][s]['sys']); } strings.push(''); if (s.lastIndexOf("LogService,", 0) === 0 || s.lastIndexOf("ResourceService,", 0) === 0) { strings.push('N/A'); } else if (response['data'][l-1][1]['services'][s]['autorestart'] == true) { strings.push(" "); } else if (response['data'][l-1][1]['services'][s]['autorestart'] == false) { strings.push(" "); } else { strings.push('N/A'); } strings.push(''); } table.html(strings.join("")); }, update_resources: function() { var f = utils.bind_func(this, this.update_resources_cb); cmsrpc_request("ResourceService", this.shard, "get_resources", {"last_time": this.last_time}, f); }, kill_service: function(s, link) { link.parentNode.innerHTML = 'loading...'; cmsrpc_request("ResourceService", this.shard, "kill_service", {"service": s}); }, toggle_autorestart: function(s, checkbox) { cmsrpc_request("ResourceService", this.shard, "toggle_autorestart", {"service": s}); } } })(); var plotOptions = { gridPadding: {top: 1}, grid: { shadow: false, borderWidth:1.0 }, stackSeries: true, axes: { xaxis: { renderer:$.jqplot.DateAxisRenderer, tickOptions: {formatString: '%H:%M'}, min: 0, max: 600000 }, yaxis: { min: 0, max: 100 } }, seriesDefaults: { showMarker: false, fill: true, shadow: false }, legend: { renderer: $.jqplot.EnhancedLegendRenderer, show: true, location: 'e', rowSpacing: 0, placement: 'outside', rendererOptions: { numberColumns:1 } } }; {% endblock js %} {% block js_init %} var shards = {{ resource_addresses|tojson }}; for (var i in shards) { getters[i] = new RSgetter(i, plotOptions); var f = utils.bind_func(getters[i], getters[i].update_resources); setInterval(f, 10000); getters[i].update_resources() } {% endblock js_init %} {% block core %}

Resource usage

{% for i in resource_addresses %}

Machine {{ i }} ({{ resource_addresses[i] }})

Service Uptime (s) Threads Resident (MB) Virtual (MB) User (%) System (%) Autorestart
loading...
CPU
Memory
Swap
{% endfor %} {% endblock core %}