When container is stopped, running time and disk usage will also be displayed.

This commit is contained in:
zhuyj17 2016-05-21 15:48:37 +08:00
parent cd43e0889d
commit ec5861d67c
2 changed files with 14 additions and 9 deletions

View File

@ -65,6 +65,9 @@ class Container_Collector(threading.Thread):
#if basic_exist:
# logger.info(workercinfo[container_name]['basic_info'])
if(info['State'] == 'STOPPED'):
if not 'RunningTime' in basic_info.keys():
basic_info['RunningTime'] = 0
basic_info['LastTime'] = 0
workercinfo[container_name]['basic_info'] = basic_info
logger.info(basic_info)
return False

View File

@ -125,6 +125,17 @@
{
$.post(url+"/basic_info/",{},function(data){
$.post(url+"/disk_use/",{},function(data){
var diskuse = data.monitor.disk_use;
var usedp = diskuse.percent;
var total = diskuse.total/1024.0/1024.0;
var used = diskuse.used/1024.0/1024.0;
var detail = "("+used.toFixed(2)+"MiB/"+total.toFixed(2)+"MiB)";
$("#"+index+"_disk").html(usedp+"%<br/>"+detail);
},"json");
$("#"+index+"_time").html(data.monitor.basic_info.RunningTime+"s")
var state = data.monitor.basic_info.State;
if(state == 'RUNNING')
{
@ -147,7 +158,6 @@
$("#"+index+"_mem").html('--');
return;
}
$("#"+index+"_time").html(data.monitor.basic_info.RunningTime+"s")
$.post(url+"/cpu_use/",{},function(data){
var usedp = data.monitor.cpu_use.usedp;
@ -169,14 +179,6 @@
$("#"+index+"_mem").html((usedp/0.01).toFixed(2)+"%<br/>"+out);
},"json");
$.post(url+"/disk_use/",{},function(data){
var diskuse = data.monitor.disk_use;
var usedp = diskuse.percent;
var total = diskuse.total/1024.0/1024.0;
var used = diskuse.used/1024.0/1024.0;
var detail = "("+used.toFixed(2)+"MiB/"+total.toFixed(2)+"MiB)";
$("#"+index+"_disk").html(usedp+"%<br/>"+detail);
},"json");
},"json");
}