Display quota in Status page.

This commit is contained in:
zhuyj17 2016-04-05 17:41:43 +08:00
parent 69e34f87b1
commit 3aa87cf858
4 changed files with 22 additions and 10 deletions

View File

@ -342,7 +342,8 @@ class DockletHttpHandler(http.server.BaseHTTPRequestHandler):
res['mem_use'] = fetcher.get_mem_use(cmds[2])
elif cmds[3] == 'basic_info':
res['basic_info'] = fetcher.get_basic_info(cmds[2])
self.response(200, {'success':'true', 'monitor':res})
user_info = G_usermgr.selfQuery(cur_user = cur_user)
self.response(200, {'success':'true', 'monitor':res, 'groupinfo':user_info['data']['groupinfo']})
elif cmds[1] == 'user':
if not user == 'root':
self.response(400, {'success':'false', 'message':'Root Required'})

View File

@ -7,9 +7,9 @@ function processMemData(data)
mem_usedp = data.monitor.mem_use.usedp;
var usedp = data.monitor.mem_use.usedp;
var unit = data.monitor.mem_use.unit;
var quota = data.monitor.mem_use.quota;
var quota = data.groupinfo.memory;
var val = data.monitor.mem_use.val;
var out = "("+val+unit+"/"+quota+unit+")";
var out = "("+val+unit+"/"+quota+"MB)";
$("#con_mem").html((usedp/0.01).toFixed(2)+"%<br/>"+out);
}
function getMemY()
@ -21,7 +21,10 @@ function processCpuData(data)
cpu_usedp = data.monitor.cpu_use.usedp;
var val = data.monitor.cpu_use.val;
var unit = data.monitor.cpu_use.unit;
var quota = data.groupinfo.cpu;
quota = quota/1000.0;
$("#con_cpu").html(val +" "+ unit);
$("#con_cpuquota").html(quota.toFixed(2)+"% Cores");
}
function getCpuY()
{

View File

@ -39,6 +39,7 @@
<th>IP Address</th>
<th>Status</th>
<th>Cpu used</th>
<th>Cpu quota</th>
<th>Mem used</th>
<th>Summary</th>
</tr>
@ -56,6 +57,7 @@
<td><div id='{{cluster}}_{{ loop.index }}_state' class="label label-primary">Running</div></td>
{% endif %}
<td id='{{cluster}}_{{ loop.index }}_cpu'>--</td>
<td id='{{cluster}}_{{ loop.index }}_cpuquota'>--</td>
<td id='{{cluster}}_{{ loop.index }}_mem'>--</td>
<td><a class="btn btn-info btn-xs" href='/vclusters/{{ cluster }}/{{ container['containername'] }}/'>Realtime</a></td>
@ -97,21 +99,25 @@
$("#"+index+"_pid").html('--');
$("#"+index+"_ip").html('--');
$("#"+index+"_cpu").html('--');
$("#"+index+"_cpuquota").html('--');
$("#"+index+"_mem").html('--');
return;
}
$.post(url+"/cpu_use",{},function(data){
var usedp = data.monitor.cpu_use.usedp;
var quota = data.groupinfo.cpu;
quota = quota/100000.0;
$("#"+index+"_cpu").html((usedp/0.01).toFixed(2)+"%");
$("#"+index+"_cpuquota").html((quota*100).toFixed(2)+"% Cores");
},"json");
$.post(url+"/mem_use",{},function(data){
var usedp = data.monitor.mem_use.usedp;
var unit = data.monitor.mem_use.unit;
var quota = data.monitor.mem_use.quota;
var quota = data.groupinfo.memory;
var val = data.monitor.mem_use.val;
var out = "("+val+unit+"/"+quota+unit+")";
var out = "("+val+unit+"/"+quota+"MB)";
$("#"+index+"_mem").html((usedp/0.01).toFixed(2)+"%<br/>"+out);
},"json");

View File

@ -43,6 +43,7 @@
<th>State</th>
<th>IP Address</th>
<th>CPU Use</th>
<th>CPU Quota</th>
<th>Mem Use</th>
</tr>
</thead>
@ -57,6 +58,7 @@
<td id='con_ip'>{{ container['IP'] }}</td>
{% endif %}
<td id='con_cpu'>--</td>
<td id='con_cpuquota'>--</td>
<td id='con_mem'>--</td>
</tr>
</tbody>