From 8e63b80ed2992b20a423aed3286ee7a4ed27b0d7 Mon Sep 17 00:00:00 2001 From: Firmlyzhu Date: Tue, 5 Dec 2017 17:04:50 +0800 Subject: [PATCH] add rate graph --- web/static/js/plot_monitor.js | 29 ++++++++++++++++------- web/templates/monitor/statusRealtime.html | 4 ++-- 2 files changed, 22 insertions(+), 11 deletions(-) diff --git a/web/static/js/plot_monitor.js b/web/static/js/plot_monitor.js index 6cb6ac8..a89196b 100755 --- a/web/static/js/plot_monitor.js +++ b/web/static/js/plot_monitor.js @@ -1,8 +1,8 @@ var mem_usedp = 0; var cpu_usedp = 0; var is_running = true; -var ingress_rate_p = 0; -var egress_rate_p = 0; +var ingress_rate = 0; +var egress_rate = 0; var ingress_rate_limit = 0; var egress_rate_limit = 0; @@ -54,9 +54,17 @@ function getCpuY() return cpu_usedp*100; } -function processIngressRate(data) +function processRate(data) { - +} +function getIngressRateP() +{ + //alert(ingress_rate*8 / 1000.0); + return ingress_rate * 8 / 1000.0; +} +function getEgressRateP() +{ + return egress_rate * 8 / 1000.0; } function plot_graph(container,url,processData,getY,fetchdata=true, maxy=110) { @@ -100,7 +108,7 @@ function plot_graph(container,url,processData,getY,fetchdata=true, maxy=110) { if(fetchdata) $.post(url,{},processData,"json"); var y = getY(); - data.push(y < 0 ? 0 : y > 100 ? 100 : y); + data.push(y < 0 ? 0 : y > maxy ? maxy : y); } // zip the generated y values with the x values @@ -237,12 +245,14 @@ function processBasicInfo() var secs = Math.floor(total % 3600 % 60); $("#con_time").html(hour+"h "+min+"m "+secs+"s"); $("#con_billing").html(""+basic_info.billing+" "); - $("#con_billingthishour").html(""+basic_info.billing_this_hour+" "); + $("#con_billingthishour").html(""+basic_info.billing_this_hour.total+" "); },"json"); $.post(url+"/net_stats/",{},function(data){ var net_stats = data.monitor.net_stats; var in_rate = parseInt(net_stats.bytes_recv_per_sec); var out_rate = parseInt(net_stats.bytes_sent_per_sec); + ingress_rate = in_rate; + egress_rate = out_rate; $("#net_in_rate").html(num2human(in_rate)+"Bps"); $("#net_out_rate").html(num2human(out_rate)+"Bps"); $("#net_in_bytes").html(num2human(net_stats.bytes_recv)+"B"); @@ -261,9 +271,10 @@ function plot_net(host,monitorurl) var url = "http://" + host + "/user/selfQuery/"; $.post(url,{},function(data){ - var input_rate_limit = data.groupinfo.input_rate_limit; - var output_rate_limit = data.groupinfo.output_rate_limit; - plot_graph($("#ingress-chart"), monitorurl,) + ingress_rate_limit = parseInt(data.groupinfo.input_rate_limit); + egress_rate_limit = parseInt(data.groupinfo.output_rate_limit); + plot_graph($("#ingress-chart"), monitorurl, processRate, getIngressRateP,false,ingress_rate_limit*1.5); + plot_graph($("#egress-chart"), monitorurl, processRate, getEgressRateP,false,egress_rate_limit*1.5); },"json"); } diff --git a/web/templates/monitor/statusRealtime.html b/web/templates/monitor/statusRealtime.html index d1c5984..bc38855 100644 --- a/web/templates/monitor/statusRealtime.html +++ b/web/templates/monitor/statusRealtime.html @@ -63,8 +63,8 @@ -- -- -- - {{ container['billing'] }} - {{ container['billing_this_hour'] }} + -- + --