-
Notifications
You must be signed in to change notification settings - Fork 50
Expand file tree
/
Copy pathindex.html
More file actions
executable file
·230 lines (207 loc) · 8.69 KB
/
index.html
File metadata and controls
executable file
·230 lines (207 loc) · 8.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
<!--
******************************************************************************
* Copyright 2017 IBM Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
******************************************************************************
-->
<!DOCTYPE html>
<meta charset="utf-8">
<link rel="stylesheet" href="graphmetrics/bootstrap-3.3.7-dist/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="graphmetrics/css/themes.css" title="Themes">
<head>
<title>Application Metrics for Swift (Tech Preview)</title>
</head>
<body>
<!-- load the d3.js library -->
<script src="graphmetrics/d3/d3.v3.min.js"></script>
<script src="graphmetrics/jquery/jquery-3.1.1.min.js"></script>
<script src="graphmetrics/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>
<script>
const queryStringValues = new URLSearchParams(window.location.search)
if (queryStringValues.get('theme')==='dark') {
$('body').addClass( "darkmode" )
} else {
$('body').addClass( "lightmode" )
}
</script>
<div class="headerDiv"><span class="rightHeader"></span><span class="leftHeader"></span></div>
<div id="tabs" class="container">
<ul class="nav nav-tabs">
<li class="active">
<a href="#dashboard" id="dashboard-tab" data-toggle="tab">Dashboard</a>
</li>
<li>
<a href="#summary" id="summary-tab" data-toggle="tab">Summary</a>
</li>
</ul>
<div class="tab-content ">
<div class="tab-pane active" id="dashboard">
<div class="container-fluid">
<div class="row">
<div class="col-md-6 hideable" id="cpuDiv1"></div>
<div class="col-md-6 hideable" id="httpDiv1"></div>
</div>
<div class="row">
<div class="col-md-6 hideable" id="memDiv1"></div>
<div class="col-md-6 hideable" id="httpDiv2"></div>
</div>
</div>
</div>
<div class="tab-pane" id="summary">
<div class="container-fluid">
<div class="row">
<div class="graph-container col-md-7">
<div class="col-md-12 height-fill hideable" id="httpSummaryDiv"></div>
</div>
<div class="graph-container col-md-5">
<div class="col-md-12 hideable" id="envDiv"></div>
<div class="col-md-12 hideable" id="summaryDiv"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<script type="text/javascript" src="graphmetrics/js/i18n.js"></script>
<script>
// Global variables
var localizedStrings = {};
var monitoringStartTime = new Date();
var maxTimeWindow = 900000; // 15 minutes
// Initialise graph and canvas dimensions
var margin = {
top: 50,
right: 20,
bottom: 50,
shortBottom: 30,
left: 60
},
canvasWidth = $("#cpuDiv1").width() - 8, // -8 for margins and borders
httpCanvasWidth = $("#httpDiv1").width() - 8,
graphWidth = canvasWidth - margin.left - margin.right,
httpGraphWidth = httpCanvasWidth - margin.left - margin.right,
canvasHeight = 250,
tallerGraphHeight = canvasHeight - margin.top - margin.shortBottom,
graphHeight = canvasHeight - margin.top - margin.bottom;
// set up http variables to hold data for top 5 and averages.
var httpRate = [];
var httpAverages = new Object;
function getTimeFormat() {
var currentTime = new Date()
if(currentTime.getMinutes() - monitoringStartTime.getMinutes() >= 3
|| currentTime.getHours() > monitoringStartTime.getHours()) {
return d3.time.format("%H:%M");
} else {
return d3.time.format("%H:%M:%S");
}
}
populateLocalizedStrings();
</script>
<script type="text/javascript" src="graphmetrics/js/header.js"></script>
<script type="text/javascript" src="graphmetrics/js/textTable.js"></script>
<script type="text/javascript" src="graphmetrics/js/cpuChart.js"></script>
<script type="text/javascript" src="graphmetrics/js/httpThroughPutChart.js"></script>
<script type="text/javascript" src="graphmetrics/js/httpRequestsChart.js"></script>
<script type="text/javascript" src="graphmetrics/js/httpSummary.js"></script>
<script type="text/javascript" src="graphmetrics/js/top5.js"></script>
<script type="text/javascript" src="graphmetrics/js/memChart.js"></script>
<script>
let hostname = location.host;
let pathname = location.pathname
// User may have requested appmetrics-dash/index.html
let dashboardRoot = "/" + pathname.split('/')[1];
var webSocketProtocol = "ws://"
if(location.protocol === "https:") {
webSocketProtocol = "wss://"
}
var client = new WebSocket(webSocketProtocol + hostname + dashboardRoot,"swiftmetrics-dash")
let summary = {cpu:{}, gc:{}, memory:{}};
let envTable = new TextTable('#envDiv', '#summary', localizedStrings.envTitle);
let summaryTable = new TextTable('#summaryDiv', '#summary', localizedStrings.summaryTitle);
let httpSummary = new HttpSummary('#httpSummaryDiv', '#summary', localizedStrings.httpSummaryTitle);
httpSummary.setHttpSummaryOptions({host: hostname, filteredPath: location.origin + dashboardRoot});
client.onmessage = function(message) {
received = JSON.parse(message.data);
topic = received.topic;
payload = JSON.stringify(received.payload);
switch (topic) {
case 'cpu':
updateCPUData(payload);
summary.cpu.systemMean = received.payload.systemMean;
summary.cpu.processMean = received.payload.processMean;
break;
case 'memory':
updateMemData(payload);
summary.memory.systemMean = received.payload.systemMean;
summary.memory.processMean = received.payload.processMean;
break;
case 'env':
envTable.populateTableJSON(payload);
break;
case 'http':
updateHttpData(payload);
break;
case 'httpURLs':
httpSummary.updateURLData(payload);
break;
case 'title' :
updateHeader(payload);
break;
}
let summaryData = [];
if( summary.cpu.processMean ) {
let value = new Number(summary.cpu.processMean);
let valueStr = value.toLocaleString([],{style: 'percent', minimumSignificantDigits: 4, maximumSignificantDigits: 4});
summaryData.push({Parameter: 'Average Process CPU', Value: valueStr});
}
if( summary.cpu.systemMean ) {
let value = new Number(summary.cpu.systemMean);
let valueStr = value.toLocaleString([],{style: 'percent', minimumSignificantDigits: 4, maximumSignificantDigits: 4});
summaryData.push({Parameter: 'Average System CPU', Value: valueStr});
}
if( summary.memory.processMean ) {
summaryData.push({Parameter: 'Average Process Memory', Value: `${summary.memory.processMean} bytes`});
}
if( summary.memory.systemMean ) {
summaryData.push({Parameter: 'Average System Memory', Value: `${summary.memory.systemMean} bytes`});
}
summaryTable.populateTable(summaryData);
}
let selected_tab = "dashboard-tab"
window.addEventListener('resize', resize);
// Also re-size when we change tabs in case we re-sized
// while the new tab wasn't visible.
$('.nav-tabs a').on('shown.bs.tab', function(event) {
selected_tab = event.target.id;
resize();
});
function resize() {
if (selected_tab == "dashboard-tab") {
canvasWidth = $("#cpuDiv1").width() - 8,
httpCanvasWidth = $("#httpDiv1").width() - 8,
graphWidth = canvasWidth - margin.left - margin.right,
httpGraphWidth = httpCanvasWidth - margin.left - margin.right;
resizeCPUChart();
resizeHttpChart();
resizeHttpThroughputChart();
resizeMemChart();
} else if(selected_tab == "summary-tab") {
envTable.resizeTable();
summaryTable.resizeTable();
httpSummary.resizeTable();
}
}
</script>
</body>
</html>