Set quota in etcd and read from etcd for each container.
This commit is contained in:
parent
5bdf6f1404
commit
02cbccdd15
|
@ -342,8 +342,7 @@ 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])
|
||||
user_info = G_usermgr.selfQuery(cur_user = cur_user)
|
||||
self.response(200, {'success':'true', 'monitor':res, 'groupinfo':user_info['data']['groupinfo']})
|
||||
self.response(200, {'success':'true', 'monitor':res})
|
||||
elif cmds[1] == 'user':
|
||||
if not user == 'root':
|
||||
self.response(400, {'success':'false', 'message':'Root Required'})
|
||||
|
|
|
@ -67,6 +67,8 @@ class Container_Collector(threading.Thread):
|
|||
self.cpu_quota[container_name] = self.cores_num
|
||||
else:
|
||||
self.cpu_quota[container_name] = tmp/100000.0
|
||||
quota = {'cpu':self.cpu_quota[container_name],'memory':self.mem_quota[container_name]}
|
||||
self.etcdser.setkey('/vnodes/%s/quota'%(container_name),quota)
|
||||
else:
|
||||
logger.error("Cant't find config file %s"%(confpath))
|
||||
return False
|
||||
|
@ -241,6 +243,11 @@ class Container_Fetcher:
|
|||
[ret, ans] = self.etcdser.getkey('/%s/cpu_use'%(container_name))
|
||||
if ret == True :
|
||||
res = dict(eval(ans))
|
||||
[ret,quota] = self.etcdser.getkey('/%s/quota'%(container_name))
|
||||
if ret == False:
|
||||
res['quota'] = {'cpu':0}
|
||||
logger.warning(quota)
|
||||
res['quota'] = dict(eval(quota))
|
||||
return res
|
||||
else:
|
||||
logger.warning(ans)
|
||||
|
@ -251,6 +258,11 @@ class Container_Fetcher:
|
|||
[ret, ans] = self.etcdser.getkey('/%s/mem_use'%(container_name))
|
||||
if ret == True :
|
||||
res = dict(eval(ans))
|
||||
[ret,quota] = self.etcdser.getkey('/%s/quota'%(container_name))
|
||||
if ret == False:
|
||||
res['quota'] = {'memory':0}
|
||||
logger.warning(quota)
|
||||
res['quota'] = dict(eval(quota))
|
||||
return res
|
||||
else:
|
||||
logger.warning(ans)
|
||||
|
|
|
@ -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.groupinfo.memory;
|
||||
var quota = data.monitor.mem_use.quota.memory/1024.0;
|
||||
var val = data.monitor.mem_use.val;
|
||||
var out = "("+val+unit+"/"+quota+"MB)";
|
||||
var out = "("+val+unit+"/"+quota.toFixed(2)+"MiB)";
|
||||
$("#con_mem").html((usedp/0.01).toFixed(2)+"%<br/>"+out);
|
||||
}
|
||||
function getMemY()
|
||||
|
@ -21,10 +21,9 @@ 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;
|
||||
var quota = data.monitor.cpu_use.quota.cpu;
|
||||
$("#con_cpu").html(val +" "+ unit);
|
||||
$("#con_cpuquota").html(quota.toFixed(2)+"% Cores");
|
||||
$("#con_cpuquota").html(quota + " Cores");
|
||||
}
|
||||
function getCpuY()
|
||||
{
|
||||
|
|
|
@ -106,18 +106,17 @@
|
|||
|
||||
$.post(url+"/cpu_use",{},function(data){
|
||||
var usedp = data.monitor.cpu_use.usedp;
|
||||
var quota = data.groupinfo.cpu;
|
||||
quota = quota/100000.0;
|
||||
var quota = data.monitor.cpu_use.quota.cpu;
|
||||
$("#"+index+"_cpu").html((usedp/0.01).toFixed(2)+"%");
|
||||
$("#"+index+"_cpuquota").html((quota*100).toFixed(2)+"% Cores");
|
||||
$("#"+index+"_cpuquota").html(quota+" 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.groupinfo.memory;
|
||||
var quota = data.monitor.mem_use.quota.memory/1024.0;
|
||||
var val = data.monitor.mem_use.val;
|
||||
var out = "("+val+unit+"/"+quota+"MB)";
|
||||
var out = "("+val+unit+"/"+quota.toFixed(2)+"MiB)";
|
||||
$("#"+index+"_mem").html((usedp/0.01).toFixed(2)+"%<br/>"+out);
|
||||
},"json");
|
||||
|
||||
|
|
Loading…
Reference in New Issue