<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;
        }

        Mbps = parseInt(rows[row]['sum_computed_bytes_sent_div_elapsed'] * 8.0 / 1024.0 / 1024.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&computed=@bytes_sent/@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>
