blob: cea2f7e5b4cee55507d1789a4dee8515b252a2c6 [file] [log] [blame]
Scott Baker19244ec2014-04-28 23:30:04 -07001<div id="tabs-6">
Scott Baker7cc6c7f2014-04-29 11:30:08 -07002<div class="row">
3 <span><b>Content Provider:</b></span>
4 <span><select id="cdn-node-data-slicename">
5 <option value="all">all</option>
6 {% for cp in cdnContentProviders %}
7 <option value="{{ cp.account }}">{{ cp.name }}</option>
8 {% endfor %}
9 </select></span>
Scott Baker19244ec2014-04-28 23:30:04 -070010</div>
Scott Baker7cc6c7f2014-04-29 11:30:08 -070011<div id="cdn-node-table"></div>
12</div>
Scott Baker19244ec2014-04-28 23:30:04 -070013<script>
14
15function domain_name_sort(a,b) {
16 parts_a = a.split(".");
17 parts_b = b.split(".");
18 parts_a = parts_a.reverse();
19 parts_b = parts_b.reverse();
20 a = parts_a.join(".");
21 b = parts_b.join(".");
22 return ((a < b) ? -1 : ((a > b) ? 1 : 0));
23}
24
25jQuery.fn.dataTableExt.oSort['domain-name-asc'] = function(a,b) {
26 return domain_name_sort(a,b);
27};
28
29jQuery.fn.dataTableExt.oSort['domain-name-desc'] = function(a,b) {
30 retuirn -domain_name_sort(a,b);
31};
32
33function updateCDNNodeData(data) {
Scott Baker7cc6c7f2014-04-29 11:30:08 -070034 $('#cdn-node-table').html( '<table cellpadding="0" cellspacing="0" border="0" class="display" id="dynamic_cdn_nodes"></table>' );
Scott Baker19244ec2014-04-28 23:30:04 -070035 var actualEntries = [];
36
37 var rows = data.rows;
38 for (row in rows) {
39 hostname = rows[row]['hostname'];
40 bytes_sent = rows[row]['sum_bytes_sent'];
41 bytes_hit = rows[row]['sum_bytes_hit'];
42 elapsed = rows[row]['sum_elapsed'];
43 healthy = rows[row]['sum_healthy'];
44
45 if (bytes_sent > 0) {
46 hit_ratio = parseInt( bytes_hit * 100.0 / bytes_sent );
47 } else {
48 hit_ratio = 0;
49 }
50
Scott Bakerb214c2a2014-04-29 09:58:17 -070051 Mbps = parseInt(rows[row]['sum_computed_bytes_sent_div_elapsed'] * 8.0 / 1024.0 / 1024.0);
Scott Baker19244ec2014-04-28 23:30:04 -070052
53 if (healthy>0) {
54 healthyStr = "ok";
55 } else {
56 healthyStr = "bad";
57 }
58
59 actualEntries.push([hostname, healthyStr, Mbps, hit_ratio]);
60 }
61 oTable = $('#dynamic_cdn_nodes').dataTable( {
62 "bJQueryUI": true,
63 "aaData": actualEntries,
64 "bStateSave": true,
65 "aoColumns": [
66 { "sTitle": "Hostname", sType: "domain-name" },
67 { "sTitle": "Healthy" },
68 { "sTitle": "Mbps" , sClass: "alignCenter"},
69 { "sTitle": "Hit Ratio" , sClass: "alignCenter"},
70 ],
71 } );
72}
73
74function updateCDNNodes() {
Scott Bakerb214c2a2014-04-29 09:58:17 -070075 var url= '/analytics/bigquery/?event=hpc_heartbeat&sum=@bytes_sent,@bytes_hit,@healthy,@elapsed&computed=@bytes_sent/@elapsed&groupBy=@hostname&cached=1&cachedGroupBy=@hostname';
Scott Baker19244ec2014-04-28 23:30:04 -070076 console.log(url);
77 $.ajax({
78 url: url,
79 dataType : 'json',
80 type : 'GET',
81 success: function(newData)
82 {
83 updateCDNNodeData(newData);
84 }
85});
86 setTimeout(updateCDNNodes, 30000);
87}
88
89setTimeout(updateCDNNodes, 5000);
90</script>