forked from saurabh/orbit4-5
92 lines
2.5 KiB
Plaintext
92 lines
2.5 KiB
Plaintext
<div class="box-header">
|
|
<h2>
|
|
<i class="icons-gauge"></i>
|
|
<span class="break"></span>
|
|
<%= t(:server_usage) %>
|
|
</h2>
|
|
</div>
|
|
<div class="box-content" style='overflow: hidden; text-align:center;'>
|
|
<div style="row-fluid">
|
|
<div id="cpu_usage" class="usages pull-left span4" style=""></div>
|
|
<div id="mem_usage" class="usages span4" style=""></div>
|
|
<div id="disk_usage" class="usages pull-right span4" style=""></div>
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
var Gages = { 'CPU':{
|
|
'JustGage': null,
|
|
'container': 'cpu_usage',
|
|
'title': 'CPU Usage',
|
|
'fn': 'get_cpu_usage',
|
|
'update_interval': 3000,
|
|
'initialized': false
|
|
},
|
|
'Mem':{
|
|
'JustGage': null,
|
|
'container': 'mem_usage',
|
|
'title': 'Memory Usage',
|
|
'fn': 'get_mem_usage',
|
|
'update_interval': 30000,
|
|
'initialized': false
|
|
},
|
|
'Disk':{
|
|
'JustGage': null,
|
|
'container': 'disk_usage',
|
|
'title': 'Disk Usage',
|
|
'fn': 'get_disk_usage',
|
|
'update_interval': 180000,
|
|
'initialized': false
|
|
}
|
|
};
|
|
|
|
$(function () {
|
|
initialize_usage();
|
|
|
|
$(window).resize(function() {
|
|
$("#cpu_usage").html("");
|
|
$("#mem_usage").html("");
|
|
$("#disk_usage").html("");
|
|
initialize_usage();
|
|
});
|
|
});
|
|
|
|
function initialize_usage(){
|
|
var h
|
|
if(window.outerWidth > 768) {
|
|
h = parseInt($('#server_loading').width()/3*0.75);
|
|
} else {
|
|
h = parseInt($('#server_loading').width()*0.3);
|
|
}
|
|
$.each($(".usages"),function(){$(this).height(h);});
|
|
|
|
$.each(Gages,function(id,Gage){
|
|
Gage['JustGage'] = new JustGage({
|
|
id: Gage['container'],
|
|
value: 0,
|
|
min: 0,
|
|
max: 100,
|
|
title: Gage['title'],
|
|
showInnerShadow: false,
|
|
shadowVerticalOffset: 10,
|
|
levelColors: ['#39D824','#FFC33F','#F51F1F'],
|
|
titleFontColor: '#666',
|
|
valueFontColor: '#666',
|
|
labelFontColor: '#666',
|
|
label: '%',
|
|
refreshAnimationTime: 800
|
|
});
|
|
update_usage(Gage);
|
|
});
|
|
}
|
|
|
|
function update_usage(Gage, Loop){
|
|
$.get('/admin/dashboards/'+Gage['fn'],function(usage){
|
|
Gage['JustGage'].refresh(parseInt(usage));
|
|
});
|
|
if(!Gage['initialized'] || Loop){
|
|
setTimeout(function(){update_usage(Gage,true);},Gage['update_interval']);
|
|
Gage['initialized'] = true;
|
|
}
|
|
}
|
|
|
|
</script> |