When worker is stopped, hosts realtime page will stop to fetch cpu and memory information.
This commit is contained in:
parent
ec5861d67c
commit
117cb718ff
|
@ -175,9 +175,6 @@ var host = window.location.host;
|
|||
var node_name = $("#node_name").html();
|
||||
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()
|
||||
{
|
||||
$.post(url+"/disk_use/",{},function(data){
|
||||
|
@ -212,3 +209,5 @@ function processBasicInfo()
|
|||
},"json");
|
||||
}
|
||||
setInterval(processBasicInfo,1000);
|
||||
plot_graph($("#mem-chart"),url + "/mem_use/",processMemData,getMemY);
|
||||
plot_graph($("#cpu-chart"),url + "/cpu_use/",processCpuData,getCpuY);
|
||||
|
|
|
@ -5,17 +5,28 @@ var idle = 0;
|
|||
var disk_usedp = 0;
|
||||
var count = 0;
|
||||
var Ki = 1024;
|
||||
var is_running = true;
|
||||
|
||||
function processMemData(data)
|
||||
{
|
||||
used = data.monitor.meminfo.used;
|
||||
total = data.monitor.meminfo.total;
|
||||
var used2 = ((data.monitor.meminfo.used)/Ki).toFixed(2);
|
||||
var total2 = ((data.monitor.meminfo.total)/Ki).toFixed(2);
|
||||
var free2 = ((data.monitor.meminfo.free)/Ki).toFixed(2);
|
||||
$("#mem_used").html(used2);
|
||||
$("#mem_total").html(total2);
|
||||
$("#mem_free").html(free2);
|
||||
if(is_running)
|
||||
{
|
||||
used = data.monitor.meminfo.used;
|
||||
total = data.monitor.meminfo.total;
|
||||
var used2 = ((data.monitor.meminfo.used)/Ki).toFixed(2);
|
||||
var total2 = ((data.monitor.meminfo.total)/Ki).toFixed(2);
|
||||
var free2 = ((data.monitor.meminfo.free)/Ki).toFixed(2);
|
||||
$("#mem_used").html(used2);
|
||||
$("#mem_total").html(total2);
|
||||
$("#mem_free").html(free2);
|
||||
}
|
||||
else
|
||||
{
|
||||
total = 0;
|
||||
$("#mem_used").html("--");
|
||||
$("#mem_total").html("--");
|
||||
$("#mem_free").html("--");
|
||||
}
|
||||
}
|
||||
function getMemY()
|
||||
{
|
||||
|
@ -26,14 +37,25 @@ function getMemY()
|
|||
}
|
||||
function processCpuData(data)
|
||||
{
|
||||
idle = data.monitor.cpuinfo.idle;
|
||||
var us = data.monitor.cpuinfo.user;
|
||||
var sy = data.monitor.cpuinfo.system;
|
||||
var wa = data.monitor.cpuinfo.iowait;
|
||||
$("#cpu_user").html(us);
|
||||
$("#cpu_system").html(sy);
|
||||
$("#cpu_iowait").html(wa);
|
||||
$("#cpu_idle").html(idle);
|
||||
if(is_running)
|
||||
{
|
||||
idle = data.monitor.cpuinfo.idle;
|
||||
var us = data.monitor.cpuinfo.user;
|
||||
var sy = data.monitor.cpuinfo.system;
|
||||
var wa = data.monitor.cpuinfo.iowait;
|
||||
$("#cpu_user").html(us);
|
||||
$("#cpu_system").html(sy);
|
||||
$("#cpu_iowait").html(wa);
|
||||
$("#cpu_idle").html(idle);
|
||||
}
|
||||
else
|
||||
{
|
||||
idle = 100;
|
||||
$("#cpu_user").html("--");
|
||||
$("#cpu_system").html("--");
|
||||
$("#cpu_iowait").html("--");
|
||||
$("#cpu_idle").html("--");
|
||||
}
|
||||
}
|
||||
function getCpuY()
|
||||
{
|
||||
|
@ -190,8 +212,20 @@ var host = window.location.host;
|
|||
var com_ip = $("#com_ip").html();
|
||||
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($("#cpu-chart"), url + "/cpuinfo/",processCpuData,getCpuY);
|
||||
//plot_graph($("#disk-chart"), url + "/diskinfo",processDiskData,getDiskY);
|
||||
$.post(url+"/diskinfo/",{user:"root",key:"unias"},processDiskData,"json");
|
||||
$.post(url+"/diskinfo/",{},processDiskData,"json");
|
||||
|
||||
|
|
Loading…
Reference in New Issue