diff --git a/chapter2/mysite/myapp/static/scripts/index.js b/chapter2/mysite/myapp/static/scripts/index.js index 5ec6d67..60abf9a 100755 --- a/chapter2/mysite/myapp/static/scripts/index.js +++ b/chapter2/mysite/myapp/static/scripts/index.js @@ -2,6 +2,10 @@ var symptomName = last_month_day(); $(function(){ + var to_g = function(v){ + return (parseInt(v)/1024/1024).toFixed(1); + } + //更新抓取信息 setInterval(function(){ @@ -18,8 +22,8 @@ $(function(){ $.ajax('/myapp/api/platform_info.json').done(function(data){ $('#disk_freed').html(data.disk_freed+'G'); $('#disk_used').html(data.disk_used+'G'); - $('#mem_free').html(data.mem_free+'G'); - $('#mem_used').html(data.mem_used+'G'); + $('#mem_free').html(to_g(data.mem_total-data.mem_used)+'G'); + $('#mem_used').html(to_g(data.mem_used)+'G'); $('#tasks_count').html(data.tasks); });