2013-10-30 10:23:46 +00:00
|
|
|
<div class="box-header">
|
|
|
|
<h2>
|
|
|
|
<i class="icons-book-2"></i>
|
|
|
|
<span class="break"></span>
|
2013-11-04 09:45:01 +00:00
|
|
|
<%= t(:server_usage) %>
|
2013-10-30 10:23:46 +00:00
|
|
|
</h2>
|
|
|
|
</div>
|
|
|
|
<div class="box-content" style='overflow: hidden;'>
|
2013-11-04 09:45:01 +00:00
|
|
|
<span id="cpu_usage" style="display:inline-block;margin: 0 auto"></span>
|
|
|
|
<span id="mem_usage" style="display:inline-block;margin: 0 auto"></span>
|
|
|
|
<span id="disk_usage" style="display:inline-block;margin: 0 auto"></span>
|
2013-10-30 10:23:46 +00:00
|
|
|
</div>
|
|
|
|
<script type="text/javascript">
|
2013-11-04 09:45:01 +00:00
|
|
|
google.load('visualization', '1', {packages:['gauge']});
|
2013-10-30 10:23:46 +00:00
|
|
|
|
2013-11-04 09:45:01 +00:00
|
|
|
var UsageTpye = {'CPU':{'fn':'get_cpu_usage','chart':null,'id':'cpu_usage','interval':2000},
|
|
|
|
'Mem':{'fn':'get_mem_usage','chart':null,'id':'mem_usage','interval':5000},
|
|
|
|
'Disk':{'fn':'get_disk_usage','chart':null,'id':'disk_usage','interval':30000}};
|
2013-10-30 10:23:46 +00:00
|
|
|
|
2013-11-04 09:45:01 +00:00
|
|
|
$(function () {
|
|
|
|
$.each(UsageTpye,function(type,option){
|
|
|
|
option['chart'] = new google.visualization.Gauge(document.getElementById(option['id']));
|
|
|
|
update_usage(type,option);
|
2013-10-30 10:23:46 +00:00
|
|
|
|
2013-11-04 09:45:01 +00:00
|
|
|
setInterval(function() { update_usage(type,option); }, option['interval']);
|
2013-10-30 10:23:46 +00:00
|
|
|
});
|
2013-11-04 09:45:01 +00:00
|
|
|
});
|
2013-10-30 10:23:46 +00:00
|
|
|
|
2013-11-04 09:45:01 +00:00
|
|
|
function update_usage(type,option){
|
|
|
|
$.get('/admin/dashboards/'+option['fn'],function(usage){
|
|
|
|
var data = google.visualization.arrayToDataTable([
|
|
|
|
['Label', 'Value'],
|
|
|
|
[type, parseInt(usage)]
|
|
|
|
]);
|
2013-10-30 10:23:46 +00:00
|
|
|
|
2013-11-04 09:45:01 +00:00
|
|
|
var options = {
|
|
|
|
width: 400, height: 180,
|
|
|
|
redFrom: 80, redTo: 100,
|
|
|
|
yellowFrom:60, yellowTo: 80,
|
|
|
|
minorTicks: 5
|
|
|
|
};
|
2013-10-30 10:23:46 +00:00
|
|
|
|
2013-11-04 09:45:01 +00:00
|
|
|
option['chart'].draw(data, options);
|
2013-10-30 10:23:46 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
</script>
|