blob: 07abce006ca587b05b3749a0a3a520daa9d6e541 [file] [log] [blame]
<div id="tabs-6">
</div>
<script>
function domain_name_sort(a,b) {
parts_a = a.split(".");
parts_b = b.split(".");
parts_a = parts_a.reverse();
parts_b = parts_b.reverse();
a = parts_a.join(".");
b = parts_b.join(".");
return ((a < b) ? -1 : ((a > b) ? 1 : 0));
}
jQuery.fn.dataTableExt.oSort['domain-name-asc'] = function(a,b) {
return domain_name_sort(a,b);
};
jQuery.fn.dataTableExt.oSort['domain-name-desc'] = function(a,b) {
retuirn -domain_name_sort(a,b);
};
function updateCDNNodeData(data) {
$('#tabs-6').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="dynamic_cdn_nodes"></table>' );
var actualEntries = [];
var rows = data.rows;
for (row in rows) {
hostname = rows[row]['hostname'];
bytes_sent = rows[row]['sum_bytes_sent'];
bytes_hit = rows[row]['sum_bytes_hit'];
elapsed = rows[row]['sum_elapsed'];
healthy = rows[row]['sum_healthy'];
if (bytes_sent > 0) {
hit_ratio = parseInt( bytes_hit * 100.0 / bytes_sent );
} else {
hit_ratio = 0;
}
if (elapsed > 0) {
Mbps = parseInt( (bytes_sent * 8.0 / 1024.0 / 1024.0 ) / elapsed );
} else {
Mbps = 0;
}
if (healthy>0) {
healthyStr = "ok";
} else {
healthyStr = "bad";
}
actualEntries.push([hostname, healthyStr, Mbps, hit_ratio]);
}
oTable = $('#dynamic_cdn_nodes').dataTable( {
"bJQueryUI": true,
"aaData": actualEntries,
"bStateSave": true,
"aoColumns": [
{ "sTitle": "Hostname", sType: "domain-name" },
{ "sTitle": "Healthy" },
{ "sTitle": "Mbps" , sClass: "alignCenter"},
{ "sTitle": "Hit Ratio" , sClass: "alignCenter"},
],
} );
}
function updateCDNNodes() {
var url= '/analytics/bigquery/?event=hpc_heartbeat&sum=@bytes_sent,@bytes_hit,@healthy,@elapsed&groupBy=@hostname&cached=1&cachedGroupBy=@hostname';
console.log(url);
$.ajax({
url: url,
dataType : 'json',
type : 'GET',
success: function(newData)
{
updateCDNNodeData(newData);
}
});
setTimeout(updateCDNNodes, 30000);
}
setTimeout(updateCDNNodes, 5000);
</script>