blob: 5f65fb2a7e92d6c63f7435c058a560695bfca385 [file] [log] [blame]
Scott Baker0fd787d2014-05-13 17:03:47 -07001function getPageKind() {
Scott Baker61aefcf2014-04-25 15:21:18 -07002 var parentNodeTxt = $('#selectedMainNav').text();
Scott Baker771819b2014-03-19 22:10:17 -07003 parentNodeTxt = parentNodeTxt.replace("/\n","");
4 parentNodeTxt = parentNodeTxt.replace("ยป","");
5 parentNodeTxt = parentNodeTxt.trim();
6 if (parentNodeTxt.length > 0 && parentNodeTxt.charAt(parentNodeTxt.length-1)=='s') {
7 parentNodeTxt = parentNodeTxt.substring(0, parentNodeTxt.length-1);
8 }
Scott Baker0fd787d2014-05-13 17:03:47 -07009 return parentNodeTxt;
10}
11
12function getObjectQuery() {
13 var selectedNodeTxt = $('#currentOriginalNode').text();
14 selectedNodeTxt = selectedNodeTxt.trim();
15 selectedNodeTxt = selectedNodeTxt.split(' ').join('');//selectedNodeTxt.replace(" ", "")
16 parentNodeTxt = getPageKind();
Scott Baker771819b2014-03-19 22:10:17 -070017
18 if (parentNodeTxt == "Slice") {
Scott Baker0fd787d2014-05-13 17:03:47 -070019 return "&slice=" + selectedNodeTxt;
Scott Baker771819b2014-03-19 22:10:17 -070020 } else if (parentNodeTxt == "Site") {
Scott Baker0fd787d2014-05-13 17:03:47 -070021 return "&site=" + selectedNodeTxt;
Scott Baker771819b2014-03-19 22:10:17 -070022 } else if (parentNodeTxt == "Node") {
Scott Baker0fd787d2014-05-13 17:03:47 -070023 return "&node=" + selectedNodeTxt;
Scott Baker771819b2014-03-19 22:10:17 -070024 } else {
Scott Baker0fd787d2014-05-13 17:03:47 -070025 return "";
Scott Baker771819b2014-03-19 22:10:17 -070026 }
27}
28
29
30function setPageStatInt(labelName, valueName, legend, units, value) {
Scott Baker8465c2b2014-03-27 09:11:14 -070031 $(labelName).text(legend).show();
32 $(valueName).text(Math.round(value)+units).show();
Scott Baker771819b2014-03-19 22:10:17 -070033}
34
35function setPageStatFloat(labelName, valueName, legend, units, value, dp) {
Scott Baker8465c2b2014-03-27 09:11:14 -070036 $(labelName).text(legend).show();
37 $(valueName).text(Number(value).toFixed(dp)+units).show();
Scott Baker771819b2014-03-19 22:10:17 -070038}
39
40// ----------------------------------------------------------------------------
41// node count and average cpu utilization
42
43function updatePageAnalyticsData(summaryData) {
Scott Baker8465c2b2014-03-27 09:11:14 -070044 window.pageAnalyticsUrl = summaryData["dataSourceUrl"];
Scott Baker771819b2014-03-19 22:10:17 -070045 lastRow = summaryData.rows.length-1;
Scott Baker8465c2b2014-03-27 09:11:14 -070046
47 setPageStatInt(".nodesLabel", ".nodesValue", "Node Count", "", summaryData.rows[lastRow]["count_hostname"]);
48 setPageStatInt(".cpuLabel", ".cpuValue", "Avg Load", "%", summaryData.rows[lastRow]["avg_cpu"]);
49
50 //New miniDashboard
51 setPageStatInt("#miniDashNodeCountLabel", "#miniDashNodeCount", "Node Count", "", summaryData.rows[lastRow]["count_hostname"]);
52 setPageStatInt("#miniDashAvgLoadLabel", "#miniDashAvgLoad", "Avg Load", "%", summaryData.rows[lastRow]["avg_cpu"]);
Scott Baker771819b2014-03-19 22:10:17 -070053}
54
55function updatePageAnalytics() {
Scott Baker0fd787d2014-05-13 17:03:47 -070056 var url= '/analytics/bigquery/?avg=%cpu&count=%hostname&cached=default' + getObjectQuery();
Scott Baker61aefcf2014-04-25 15:21:18 -070057 console.log(url);
Scott Baker771819b2014-03-19 22:10:17 -070058 $.ajax({
Scott Baker61aefcf2014-04-25 15:21:18 -070059 url: url,
Scott Baker771819b2014-03-19 22:10:17 -070060 dataType : 'json',
61 type : 'GET',
62 success: function(newData)
63 {
64 updatePageAnalyticsData(newData);
65 }
66});
67 setTimeout(updatePageAnalytics, 30000);
68}
69
70setTimeout(updatePageAnalytics, 5000);
71
72// ----------------------------------------------------------------------------
73// bandwidth
74
75function updatePageBandwidthData(summaryData) {
Scott Baker8465c2b2014-03-27 09:11:14 -070076 window.pageBandwidthUrl = summaryData["dataSourceUrl"];
Scott Baker771819b2014-03-19 22:10:17 -070077 lastRow = summaryData.rows.length-1;
Scott Baker8465c2b2014-03-27 09:11:14 -070078 setPageStatFloat(".bandwidthLabel", ".bandwidthValue", "Bandwidth", " Gbps", summaryData.rows[lastRow]["sum_computed_bytes_sent_div_elapsed"]*8.0/1024/1024/1024,2);
79 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 -070080}
81
82function updatePageBandwidth() {
Scott Baker0fd787d2014-05-13 17:03:47 -070083 var url='/analytics/bigquery/?computed=%bytes_sent/%elapsed&cached=default' + getObjectQuery();
84
85 if (getPageKind()!="Slice") {
86 url = url + "&event=node_heartbeat";
87 }
Scott Baker61aefcf2014-04-25 15:21:18 -070088
Scott Baker771819b2014-03-19 22:10:17 -070089 $.ajax({
Scott Baker61aefcf2014-04-25 15:21:18 -070090 url : url,
Scott Baker771819b2014-03-19 22:10:17 -070091 dataType : 'json',
92 type : 'GET',
93 success: function(newData)
94 {
95 updatePageBandwidthData(newData);
96 }
97});
98 setTimeout(updatePageBandwidth, 30000);
99}
100
101setTimeout(updatePageBandwidth, 5000);
102