blob: 75221b7ce76b2a7d3460ebd786dff4bf8d6fa87a [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) {
Scott Baker8465c2b2014-03-27 09:11:14 -070026 $(labelName).text(legend).show();
27 $(valueName).text(Math.round(value)+units).show();
Scott Baker771819b2014-03-19 22:10:17 -070028}
29
30function setPageStatFloat(labelName, valueName, legend, units, value, dp) {
Scott Baker8465c2b2014-03-27 09:11:14 -070031 $(labelName).text(legend).show();
32 $(valueName).text(Number(value).toFixed(dp)+units).show();
Scott Baker771819b2014-03-19 22:10:17 -070033}
34
35// ----------------------------------------------------------------------------
36// node count and average cpu utilization
37
38function updatePageAnalyticsData(summaryData) {
Scott Baker8465c2b2014-03-27 09:11:14 -070039 window.pageAnalyticsUrl = summaryData["dataSourceUrl"];
Scott Baker771819b2014-03-19 22:10:17 -070040 lastRow = summaryData.rows.length-1;
Scott Baker8465c2b2014-03-27 09:11:14 -070041
42 setPageStatInt(".nodesLabel", ".nodesValue", "Node Count", "", summaryData.rows[lastRow]["count_hostname"]);
43 setPageStatInt(".cpuLabel", ".cpuValue", "Avg Load", "%", summaryData.rows[lastRow]["avg_cpu"]);
44
45 //New miniDashboard
46 setPageStatInt("#miniDashNodeCountLabel", "#miniDashNodeCount", "Node Count", "", summaryData.rows[lastRow]["count_hostname"]);
47 setPageStatInt("#miniDashAvgLoadLabel", "#miniDashAvgLoad", "Avg Load", "%", summaryData.rows[lastRow]["avg_cpu"]);
Scott Baker771819b2014-03-19 22:10:17 -070048}
49
50function updatePageAnalytics() {
51 $.ajax({
52 url : '/analytics/bigquery/?avg=%cpu&count=%hostname' + getObjectQuery(),
53 dataType : 'json',
54 type : 'GET',
55 success: function(newData)
56 {
57 updatePageAnalyticsData(newData);
58 }
59});
60 setTimeout(updatePageAnalytics, 30000);
61}
62
63setTimeout(updatePageAnalytics, 5000);
64
65// ----------------------------------------------------------------------------
66// bandwidth
67
68function updatePageBandwidthData(summaryData) {
Scott Baker8465c2b2014-03-27 09:11:14 -070069 window.pageBandwidthUrl = summaryData["dataSourceUrl"];
Scott Baker771819b2014-03-19 22:10:17 -070070 lastRow = summaryData.rows.length-1;
Scott Baker8465c2b2014-03-27 09:11:14 -070071 setPageStatFloat(".bandwidthLabel", ".bandwidthValue", "Bandwidth", " Gbps", summaryData.rows[lastRow]["sum_computed_bytes_sent_div_elapsed"]*8.0/1024/1024/1024,2);
72 setPageStatFloat("#miniDashBandwidthLabel", "#miniDashBandwidth", "Bandwidth", " Gbps", summaryData.rows[lastRow]["sum_computed_bytes_sent_div_elapsed"]*8.0/1024/1024/1024,2);
Scott Baker771819b2014-03-19 22:10:17 -070073}
74
75function updatePageBandwidth() {
76 $.ajax({
77 url : '/analytics/bigquery/?computed=%bytes_sent/%elapsed' + getObjectQuery(),
78 dataType : 'json',
79 type : 'GET',
80 success: function(newData)
81 {
82 updatePageBandwidthData(newData);
83 }
84});
85 setTimeout(updatePageBandwidth, 30000);
86}
87
88setTimeout(updatePageBandwidth, 5000);
89