/*! * Pi Dashboard (http://www.nxez.com) * Copyright 2017 NXEZ.com. * Licensed under the GPL v3.0 license. */ $(document).ready(function(){Highcharts.setOptions({global:{useUTC:false},credits:{enabled:false},navigation:{buttonOptions:{enabled:false}}});var j={chart:{type:"solidgauge"},title:null,pane:{center:["50%","85%"],size:"140%",startAngle:-90,endAngle:90,background:{backgroundColor:(Highcharts.theme&&Highcharts.theme.background2)||"#FFFFFF",innerRadius:"60%",outerRadius:"100%",shape:"arc"}},tooltip:{enabled:false},yAxis:{stops:[[0.1,"#55BF3B"],[0.5,"#DDDF0D"],[0.9,"#DF5353"]],lineWidth:0,minorTickInterval:null,tickAmount:2,title:{y:-70},labels:{y:16}},plotOptions:{solidgauge:{dataLabels:{y:5,borderWidth:0,useHTML:true}}}};var f=Highcharts.chart("container-cpu",Highcharts.merge(j,{yAxis:{min:0,max:100,title:{text:""}},series:[{name:"CPU",data:[0],dataLabels:{format:'
{y}'+'%
'},tooltip:{valueSuffix:" %"}}]}));var c=Highcharts.chart("container-mem",Highcharts.merge(j,{yAxis:{min:0,max:init_vals.mem.total,title:{text:""}},series:[{name:"MEMORY",data:[0],dataLabels:{format:'
{y:.1f}
'+'MB
'},tooltip:{valueSuffix:" MB"}}]}));var g=Highcharts.chart("container-cache",Highcharts.merge(j,{yAxis:{min:0,max:init_vals.mem.total,title:{text:""}},series:[{name:"CACHE",data:[0],dataLabels:{format:'
{y:.1f}
'+'MB
'},tooltip:{valueSuffix:" MB"}}]}));var a=Highcharts.chart("container-mem-real",Highcharts.merge(j,{yAxis:{min:0,max:init_vals.mem.total,title:{text:""}},series:[{name:"REAL MEMORY",data:[0],dataLabels:{format:'
{y:.1f}
'+'MB
'},tooltip:{valueSuffix:" MB"}}]}));var h=Highcharts.chart("container-swap",Highcharts.merge(j,{yAxis:{min:0,max:init_vals.mem.swap.total,title:{text:""}},series:[{name:"SWAP",data:[0],dataLabels:{format:'
{y:.1f}
'+'MB
'},tooltip:{valueSuffix:" MB"}}]}));var b=Highcharts.chart("container-disk",Highcharts.merge(j,{yAxis:{min:0,max:init_vals.disk.total,title:{text:""}},series:[{name:"DISK",data:[0],dataLabels:{format:'
{y:.1f}
'+'GB
'},tooltip:{valueSuffix:" GB"}}]}));var k=new Array();var e=new Array();var d=new Array();for(i=0;i0){for(i=0;i=30){k[i].series[0].addPoint(parseInt(window.dashboard.net.interfaces[i].total_in)-parseInt(window.dashboard_old.net.interfaces[i].total_in),true,true)}else{k[i].series[0].addPoint(parseInt(window.dashboard.net.interfaces[i].total_in)-parseInt(window.dashboard_old.net.interfaces[i].total_in))}if(k[i].series[1].data.length>=30){k[i].series[1].addPoint(parseInt(window.dashboard.net.interfaces[i].total_out)-parseInt(window.dashboard_old.net.interfaces[i].total_out),true,true)}else{k[i].series[1].addPoint(parseInt(window.dashboard.net.interfaces[i].total_out)-parseInt(window.dashboard_old.net.interfaces[i].total_out))}}}idle_diff=parseInt(window.dashboard.cpu.stat.idle)-parseInt(window.dashboard_old.cpu.stat.idle);used_total=parseInt(window.dashboard.cpu.stat.idle)+parseInt(window.dashboard.cpu.stat.user)+parseInt(window.dashboard.cpu.stat.sys)+parseInt(window.dashboard.cpu.stat.nice)+parseInt(window.dashboard.cpu.stat.iowait)+parseInt(window.dashboard.cpu.stat.irq)+parseInt(window.dashboard.cpu.stat.softirq)-parseInt(window.dashboard_old.cpu.stat.idle)-parseInt(window.dashboard_old.cpu.stat.user)-parseInt(window.dashboard_old.cpu.stat.sys)-parseInt(window.dashboard_old.cpu.stat.nice)-parseInt(window.dashboard_old.cpu.stat.iowait)-parseInt(window.dashboard_old.cpu.stat.irq)-parseInt(window.dashboard_old.cpu.stat.softirq);if(f){m=f.series[0].points[0];m.update(Math.round((1-(idle_diff/used_total))*100*Math.pow(10,1))/Math.pow(10,1))}$("#cpu-stat-idl").text(Math.round(((parseInt(window.dashboard.cpu.stat.idle)-parseInt(window.dashboard_old.cpu.stat.idle))/used_total)*100*Math.pow(10,1))/Math.pow(10,1));$("#cpu-stat-use").text(Math.round(((parseInt(window.dashboard.cpu.stat.user)-parseInt(window.dashboard_old.cpu.stat.user))/used_total)*100*Math.pow(10,1))/Math.pow(10,1));$("#cpu-stat-sys").text(Math.round(((parseInt(window.dashboard.cpu.stat.sys)-parseInt(window.dashboard_old.cpu.stat.sys))/used_total)*100*Math.pow(10,1))/Math.pow(10,1));$("#cpu-stat-nic").text(Math.round(((parseInt(window.dashboard.cpu.stat.nice)-parseInt(window.dashboard_old.cpu.stat.nice))/used_total)*100*Math.pow(10,1))/Math.pow(10,1));$("#cpu-stat-iow").text(Math.round(((parseInt(window.dashboard.cpu.stat.iowait)-parseInt(window.dashboard_old.cpu.stat.iowait))/used_total)*100*Math.pow(10,1))/Math.pow(10,1));$("#cpu-stat-irq").text(Math.round(((parseInt(window.dashboard.cpu.stat.irq)-parseInt(window.dashboard_old.cpu.stat.irq))/used_total)*100*Math.pow(10,1))/Math.pow(10,1));$("#cpu-stat-sirq").text(Math.round(((parseInt(window.dashboard.cpu.stat.softirq)-parseInt(window.dashboard_old.cpu.stat.softirq))/used_total)*100*Math.pow(10,1))/Math.pow(10,1))}}},1000)});function bytesRound(c,a){if(c<0){var b=0+"B"}else{if(c<1024){var b=c+"B"}else{if(c<1048576){c=c/1024;var b=Math.round(c*Math.pow(10,a))/Math.pow(10,a)+"K"}else{if(c<1048576000){c=c/1048576;var b=Math.round(c*Math.pow(10,a))/Math.pow(10,a)+"M"}else{c=c/1048576000;var b=Math.round(c*Math.pow(10,a))/Math.pow(10,a)+"G"}}}}return b}Date.prototype.format=function(c){var b={"M+":this.getMonth()+1,"d+":this.getDate(),"h+":this.getHours(),"m+":this.getMinutes(),"s+":this.getSeconds(),"q+":Math.floor((this.getMonth()+3)/3),"S+":this.getMilliseconds()};if(/(y+)/i.test(c)){c=c.replace(RegExp.$1,(this.getFullYear()+"").substr(4-RegExp.$1.length))}for(var a in b){if(new RegExp("("+a+")").test(c)){c=c.replace(RegExp.$1,RegExp.$1.length==1?b[a]:("00"+b[a]).substr((""+b[a]).length))}}return c};function uptimeFormat(d){var c="";var b=parseInt(d)/60;var a=b/60;var e=Math.floor(a/24);var a=Math.floor(a-(e*24));b=Math.floor(b-(e*60*24)-(a*60));if(e!==0){if(e==1){c=e+" day "}else{c=e+" days "}}if(a!==0){c=c+a+":"}return c=c+b};