blob: 017b403c4011a5037197f52128c9eec3565e56f9 [file] [log] [blame]
Scott Baker771819b2014-03-19 22:10:17 -07001function getObjectQuery() {
2 var selectedNodeTxt = $('.currentOriginalNode').text();
3 selectedNodeTxt = selectedNodeTxt.trim();
4 selectedNodeTxt = selectedNodeTxt.split(' ').join('');//selectedNodeTxt.replace(" ", "")
5 var parentNodeTxt = $('.selectedMainNav').text();
6 parentNodeTxt = parentNodeTxt.replace("/\n","");
7 parentNodeTxt = parentNodeTxt.replace("ยป","");
8 parentNodeTxt = parentNodeTxt.trim();
9 if (parentNodeTxt.length > 0 && parentNodeTxt.charAt(parentNodeTxt.length-1)=='s') {
10 parentNodeTxt = parentNodeTxt.substring(0, parentNodeTxt.length-1);
11 }
12
13 if (parentNodeTxt == "Slice") {
14 return "&slice=" + selectedNodeTxt;
15 } else if (parentNodeTxt == "Site") {
16 return "&site=" + selectedNodeTxt;
17 } else if (parentNodeTxt == "Node") {
18 return "&node=" + selectedNodeTxt;
19 } else {
20 return "";
21 }
22}
23
24
25function setPageStatInt(labelName, valueName, legend, units, value) {
26 $('.'+labelName).text(legend).show();
27 $('.'+valueName).text(Math.round(value)+units).show();
28}
29
30function setPageStatFloat(labelName, valueName, legend, units, value, dp) {
31 $('.'+labelName).text(legend).show();
32 $('.'+valueName).text(Number(value).toFixed(dp)+units).show();
33}
34
35// ----------------------------------------------------------------------------
36// node count and average cpu utilization
37
38function updatePageAnalyticsData(summaryData) {
39 window.pageAnalyticsData = summaryData;
40 lastRow = summaryData.rows.length-1;
41 setPageStatInt("nodesLabel", "nodesValue", "Node Count", "", summaryData.rows[lastRow]["count_hostname"]);
42 setPageStatInt("cpuLabel", "cpuValue", "Avg Load", "%", summaryData.rows[lastRow]["avg_cpu"]);
43}
44
45function updatePageAnalytics() {
46 $.ajax({
47 url : '/analytics/bigquery/?avg=%cpu&count=%hostname' + getObjectQuery(),
48 dataType : 'json',
49 type : 'GET',
50 success: function(newData)
51 {
52 updatePageAnalyticsData(newData);
53 }
54});
55 setTimeout(updatePageAnalytics, 30000);
56}
57
58setTimeout(updatePageAnalytics, 5000);
59
60// ----------------------------------------------------------------------------
61// bandwidth
62
63function updatePageBandwidthData(summaryData) {
64 window.pageBandData = summaryData;
65 lastRow = summaryData.rows.length-1;
66 setPageStatFloat("bandwidthLabel", "bandwidthValue", "Bandwidth", "Gbps", summaryData.rows[lastRow]["sum_computed_bytes_sent_div_elapsed"]*8.0/1024/1024/1024,2);
67}
68
69function updatePageBandwidth() {
70 $.ajax({
71 url : '/analytics/bigquery/?computed=%bytes_sent/%elapsed' + getObjectQuery(),
72 dataType : 'json',
73 type : 'GET',
74 success: function(newData)
75 {
76 updatePageBandwidthData(newData);
77 }
78});
79 setTimeout(updatePageBandwidth, 30000);
80}
81
82setTimeout(updatePageBandwidth, 5000);
83