-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
executable file
·254 lines (215 loc) · 9.92 KB
/
index.html
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
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>iperf3 stats</title>
<link href="css/main.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><script language="javascript" type="text/javascript" src="flot/excanvas.min.js"></script><![endif]-->
<script language="javascript" type="text/javascript" src="flot/jquery.js"></script>
<script language="javascript" type="text/javascript" src="flot/jquery.flot.js"></script>
<script language="javascript" type="text/javascript" src="flot/jquery.flot.time.js"></script>
<script language="javascript" type="text/javascript" src="flot/jquery.flot.crosshair.js"></script>
<script language="javascript" type="text/javascript" src="flot/jquery.flot.symbol.js"></script>
<script language="javascript" type="text/javascript" src="flot/jquery.flot.selection.js"></script>
<script>
function plothover(event, pos, item) {
var str = "(" + pos.x.toFixed(2) + ", " + pos.y.toFixed(2) + ")";
$("#hoverdata").text(str);
if (item) {
var x = item.datapoint[0],
y = item.datapoint[1];
$("#tooltip").html(y +" ("+item.series.label+")")
.css({top: item.pageY+5, left: item.pageX+5})
.fadeIn(200);
} else {
$("#tooltip").hide();
}
}
</script>
</head>
<body>
<div id="header">
<h2>iperf3 stats</h2>
</div>
<div id="content">
<h3>Individual Streams</h3>
<div class="demo-container">
<div id="streams" class="demo-placeholder"></div>
</div>
<div class="demo-container">
<div id="sum" class="demo-placeholder"></div>
</div>
</div>
<div id="footer">
</div>
<script type="text/javascript">
var VERSION = "300";
var PATH = "files/";
var streams = [[]];
var sum = [];
// iperf3
$.getJSON(PATH + 'iperf3-'+VERSION+'.json', function(data) {
var start = data.start;
var intervals = data.intervals;
var timestamp = data.start.timestamp.timesecs;
$.each(intervals, function(x, streamsObj) {
$.each(streamsObj.streams, function(key, streamObj) {
if(streams[key] == undefined){
streams[key] = [];
}
stream = streams[key]
if(streamObj.omitted != true){
var ts = (timestamp + streamObj.start);
stream.push([ts, streamObj.bits_per_second.toFixed(5) / 1000000]);
streams[key] = stream;
}
});
var sumObj = streamsObj.sum;
if(sumObj.omitted != true){
var sum_ts = (timestamp + sumObj.start);
sum.push([sum_ts, sumObj.bits_per_second.toFixed(5) / 1000000]);;
}
});
});
var cpu = [];
var mem = [];
var memPct = [];
// iostat
/*
jQuery.get(PATH+'iostat-'+VERSION+'.txt', function(data) {
var lines = data.split("\n");
var count = 0;
jQuery.each(lines , function(key, val){
count++;
if(count != 1){
var values = val.split(';');
if(values.length == 7){
var time = parseFloat(values[0]);
var user = parseFloat(values[1]);
var nice = parseFloat(values[2]);
var system = parseFloat(values[3]);
var iowait = parseFloat(values[4]);
var steal = parseFloat(values[5]);
var idle = parseFloat(values[6]);
cpu.push([time, (user + system)]);
}
}
});
}, 'text');
*/
// vmstat
jQuery.get(PATH+'vmstat-'+VERSION+'.txt', function(data) {
var lines = data.split("\n");
var count = 0;
jQuery.each(lines , function(key, val){
count++;
if(count != 1){
var values = val.split(';');
var time = parseFloat(values[0]);
var cpu_use = parseFloat(values[1]);
var mem_use = parseFloat(values[2]);
var mem_use_pct = parseFloat(values[3]);
cpu.push([time, (cpu_use)]);
memPct.push([time, mem_use_pct]);
mem.push([time, mem_use / 1000]);
}
});
}, 'text');
/*
jQuery.get(PATH+'vmstat-'+VERSION+'.txt', function(data) {
var lines = data.split("\n");
var count = 0;
jQuery.each(lines , function(key, val){
count++;
if(count != 1){
var values = val.split(';');
var time = parseFloat(values[0]);
var swpd = parseFloat(values[1]);
var free = parseFloat(values[2]);
var buff = parseFloat(values[3]);
var cache = parseFloat(values[4]);
var user = parseFloat(values[5]);
var system = parseFloat(values[6]);
var iowait = parseFloat(values[6]);
var idle = parseFloat(values[6]);
cpu.push([time, (user + system)]);
var used = swpd + buff + cache;
var mem_tot = used + free;
memPct.push([time, (used / mem_tot) * 100 ]);
mem.push([time, used / 1000]);
}
});
}, 'text');
*/
// graph
$(function() {
var streamData = [ { data : streams[0], label : "Stream 1", yaxis : 1},
{ data : streams[1], label : "Stream 2", yaxis : 1},
{ data : streams[2], label : "Stream 3", yaxis : 1},
{ data : streams[3], label : "Stream 4", yaxis : 1},
{ data : streams[4], label : "Stream 5", yaxis : 1},
{ data : cpu , label : "CPU", yaxis: 2, points: { symbol: "triangle" } },
{ data : memPct , label : "MEM", yaxis: 2, points: { symbol: "square" } },
];
var sumData = [
{ data : sum, label : "Sum" },
{ data : cpu , label : "CPU", yaxis: 2, points: { symbol: "triangle" } },
{ data : mem , label : "MEM", points: { symbol: "square" } },
]
var options = {
series: {
lines: {
show: true
},
points: {
show: true
}
},
crosshair: {
mode: "x"
},
grid: {
hoverable: true,
clickable: true,
autoHighlight: true
},
xaxis: {
mode: "time",
},
yaxes: [
{
min: 0,
alignTicksWithAxis: 1,
position: "left"
},
{
min: 0,
alignTicksWithAxis: 1,
position: "right"
}
],
selection: {
mode: "x"
}
};
$.plot("#streams", streamData, options);
$.plot("#sum", sumData, options);
var legends = $("#streams .legendLabel");
legends.each(function () {
// fix the widths so they don't jump around
$(this).css('width', $(this).width());
});
$("<div id='tooltip'></div>").css({
position: "absolute",
display: "none",
border: "1px solid #fdd",
padding: "2px",
"background-color": "#fee",
opacity: 0.80
}).appendTo("body");
$("#streams").bind("plothover", plothover);
$("#sum").bind("plothover", plothover);
});
</script>
</body>
</html>