Merge pull request #116 from FirmlyReality/logbug

Logbug
This commit is contained in:
leebaok 2016-05-22 10:05:22 -05:00
commit 6dad5d9f4d
5 changed files with 68 additions and 30 deletions

View File

@ -65,6 +65,9 @@ class Container_Collector(threading.Thread):
#if basic_exist: #if basic_exist:
# logger.info(workercinfo[container_name]['basic_info']) # logger.info(workercinfo[container_name]['basic_info'])
if(info['State'] == 'STOPPED'): 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 workercinfo[container_name]['basic_info'] = basic_info
logger.info(basic_info) logger.info(basic_info)
return False return False

View File

@ -121,7 +121,7 @@ class Worker(object):
logger.info ("initialize rpcserver %s:%d" % (self.addr, int(self.port))) logger.info ("initialize rpcserver %s:%d" % (self.addr, int(self.port)))
# logRequests=False : not print rpc log # logRequests=False : not print rpc log
#self.rpcserver = xmlrpc.server.SimpleXMLRPCServer((self.addr, self.port), logRequests=False) #self.rpcserver = xmlrpc.server.SimpleXMLRPCServer((self.addr, self.port), logRequests=False)
self.rpcserver = ThreadXMLRPCServer((self.addr, int(self.port)), allow_none=True) self.rpcserver = ThreadXMLRPCServer((self.addr, int(self.port)), allow_none=True, logRequests=False)
self.rpcserver.register_introspection_functions() self.rpcserver.register_introspection_functions()
self.rpcserver.register_instance(Containers) self.rpcserver.register_instance(Containers)
self.rpcserver.register_function(monitor.workerFetchInfo) self.rpcserver.register_function(monitor.workerFetchInfo)

View File

@ -175,9 +175,6 @@ var host = window.location.host;
var node_name = $("#node_name").html(); var node_name = $("#node_name").html();
var url = "http://" + host + "/monitor/vnodes/" + node_name; var url = "http://" + host + "/monitor/vnodes/" + node_name;
plot_graph($("#mem-chart"),url + "/mem_use/",processMemData,getMemY);
plot_graph($("#cpu-chart"),url + "/cpu_use/",processCpuData,getCpuY);
function processDiskData() function processDiskData()
{ {
$.post(url+"/disk_use/",{},function(data){ $.post(url+"/disk_use/",{},function(data){
@ -212,3 +209,5 @@ function processBasicInfo()
},"json"); },"json");
} }
setInterval(processBasicInfo,1000); setInterval(processBasicInfo,1000);
plot_graph($("#mem-chart"),url + "/mem_use/",processMemData,getMemY);
plot_graph($("#cpu-chart"),url + "/cpu_use/",processCpuData,getCpuY);

View File

@ -5,9 +5,12 @@ var idle = 0;
var disk_usedp = 0; var disk_usedp = 0;
var count = 0; var count = 0;
var Ki = 1024; var Ki = 1024;
var is_running = true;
function processMemData(data) function processMemData(data)
{ {
if(is_running)
{
used = data.monitor.meminfo.used; used = data.monitor.meminfo.used;
total = data.monitor.meminfo.total; total = data.monitor.meminfo.total;
var used2 = ((data.monitor.meminfo.used)/Ki).toFixed(2); var used2 = ((data.monitor.meminfo.used)/Ki).toFixed(2);
@ -16,6 +19,14 @@ function processMemData(data)
$("#mem_used").html(used2); $("#mem_used").html(used2);
$("#mem_total").html(total2); $("#mem_total").html(total2);
$("#mem_free").html(free2); $("#mem_free").html(free2);
}
else
{
total = 0;
$("#mem_used").html("--");
$("#mem_total").html("--");
$("#mem_free").html("--");
}
} }
function getMemY() function getMemY()
{ {
@ -26,6 +37,8 @@ function getMemY()
} }
function processCpuData(data) function processCpuData(data)
{ {
if(is_running)
{
idle = data.monitor.cpuinfo.idle; idle = data.monitor.cpuinfo.idle;
var us = data.monitor.cpuinfo.user; var us = data.monitor.cpuinfo.user;
var sy = data.monitor.cpuinfo.system; var sy = data.monitor.cpuinfo.system;
@ -34,6 +47,15 @@ function processCpuData(data)
$("#cpu_system").html(sy); $("#cpu_system").html(sy);
$("#cpu_iowait").html(wa); $("#cpu_iowait").html(wa);
$("#cpu_idle").html(idle); $("#cpu_idle").html(idle);
}
else
{
idle = 100;
$("#cpu_user").html("--");
$("#cpu_system").html("--");
$("#cpu_iowait").html("--");
$("#cpu_idle").html("--");
}
} }
function getCpuY() function getCpuY()
{ {
@ -190,8 +212,20 @@ var host = window.location.host;
var com_ip = $("#com_ip").html(); var com_ip = $("#com_ip").html();
var url = "http://" + host + "/monitor/hosts/"+com_ip; var url = "http://" + host + "/monitor/hosts/"+com_ip;
function processStatus()
{
$.post(url+"/status/",{},function(data){
var state = data.monitor.status;
if(state == 'RUNNING')
is_running = true;
else
is_running = false;
},"json");
}
setInterval(processStatus,1000);
plot_graph($("#mem-chart"), url + "/meminfo/",processMemData,getMemY); plot_graph($("#mem-chart"), url + "/meminfo/",processMemData,getMemY);
plot_graph($("#cpu-chart"), url + "/cpuinfo/",processCpuData,getCpuY); plot_graph($("#cpu-chart"), url + "/cpuinfo/",processCpuData,getCpuY);
//plot_graph($("#disk-chart"), url + "/diskinfo",processDiskData,getDiskY); //plot_graph($("#disk-chart"), url + "/diskinfo",processDiskData,getDiskY);
$.post(url+"/diskinfo/",{user:"root",key:"unias"},processDiskData,"json"); $.post(url+"/diskinfo/",{},processDiskData,"json");

View File

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