Skip to content

Commit

Permalink
better querying of stats db for rss and cpu, improved plotting
Browse files Browse the repository at this point in the history
  • Loading branch information
spennihana committed Jun 28, 2014
1 parent fa5a7b2 commit 4588bff
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 12 deletions.
4 changes: 3 additions & 1 deletion h2o-perf/web/perflink.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ <h1>CPU and RSS Over Time</h1>
</div>
</div>
</div>
<h3>NB: Graphs cover the <u><em>entire test run!</em></u></h3>
<div id="header_div"></div>
<div id="cpu_svg">
<div id="cpu_svg1"></div>
Expand All @@ -99,6 +100,7 @@ <h1>CPU and RSS Over Time</h1>
var test_run_id = params[0].split('=')[1];
var test_name = params[1].split('=')[1];
var num_hosts = params[2].split('=')[1];
var run_date = params[3].split('=')[1];

var h2 = document.createElement("H5");
var h = document.createElement("H5");
Expand All @@ -120,7 +122,7 @@ <h1>CPU and RSS Over Time</h1>
document.getElementById("cpu_svg").appendChild(h4);

$(document).ready(function() {
showPerfGraphs(test_run_id, num_hosts)
showPerfGraphs(test_name, num_hosts, run_date)
});
</script>
<br />
Expand Down
29 changes: 22 additions & 7 deletions h2o-perf/web/prototype/js/customQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,26 @@ function doQuery(phpQueryPage) {
});
}

function showPerfGraphs(test_run_id, total_hosts) {
function showPerfGraphs(test_name, total_hosts, dt) {
if (total_hosts == 1) {
// Just looks at node 192.168.1.164

$.ajax({
url: '../prototype/php/post2.php',
type: 'POST',
dataType: 'JSON',
data: 'test_run_id=' + test_run_id + '&ip=192.168.1.164',
data: 'test_name=' + test_name + '&ip=192.168.1.164&dt='+dt,
success: function(data) {
nodePerfGraph(data, '#cpu_svg1', '#rss_svg1');
console.log(data)
if(data.data.length == 0) {
d3.select("#cpu_svg1").append("text").text("No CPU Data Captured!");
d3.select("#rss_svg1").append("text").text("No RSS Data Captured!");
} else {
nodePerfGraph(data, '#cpu_svg', '#rss_svg');
}
},
error: function(request, status, error) {
console.log(request.responseText);
}
});
} else {
Expand All @@ -64,11 +73,17 @@ function showPerfGraphs(test_run_id, total_hosts) {
url: '../prototype/php/post2.php',
type: 'POST',
dataType: 'JSON',
data: 'test_run_id=' + test_run_id + '&ip=192.168.1.16' + (i+1),
data: 'test_name=' + test_name + '&ip=192.168.1.16' + (i+1) + '&dt='+dt,
async: false,
success: function(data) {
console.log(data)
nodePerfGraph(data, '#cpu_svg'+(i+1), '#rss_svg'+(i+1));
console.log("FINISHED RUNNING nodePerfGraph...")
if(data.data.length == 0) {
if (i < 1) {
d3.select("#cpu_svg1").append("text").text("No CPU Data Captured!");
d3.select("#rss_svg1").append("text").text("No RSS Data Captured!");
}
} else {
nodePerfGraph(data, '#cpu_svg'+(i+1), '#rss_svg'+(i+1));
}
},
error: function (request, status, error) {
console.log(request.responseText);
Expand Down
4 changes: 2 additions & 2 deletions h2o-perf/web/prototype/js/perf.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function makeTable(json, svg) {
datas[0] = header;
for(i = 0; i < json.data.length; i++) {
datas[i+1] = d3.values(json.data[i]);
link = "http://192.168.1.171:4040/perflink.html?test_run_id=" + datas[i+1][0] + "&test_name=" + datas[i+1][2] + "&num_hosts=" + datas[i+1][10];
link = "http://192.168.1.171:4040/perflink.html?test_run_id=" + datas[i+1][0] + "&test_name=" + datas[i+1][2] + "&num_hosts=" + datas[i+1][10] + "&rundate=" + datas[i+1][1].split('-').join('');
datas[i+1].push(link)
}

Expand Down Expand Up @@ -336,7 +336,7 @@ function nodePerfGraph(json, svgCPU, svgRSS) {
var node_name = json.data[0]['node_ip'];
var ts_raw = json.data.map(function(d) { return d['ts'] });
var max_time = d3.max(ts_raw);
var ts = (ts_raw.map(function(d) { return max_time - d })).sort();
var ts = (ts_raw.map(function(d) { return max_time - d })).sort(function(a,b) {return a - b; });
var sys_cpu = zip(ts, json.data.map(function(d) { return d['cum_cpu_sys'] }));
var user_cpu = zip(ts, json.data.map(function(d) { return d['cum_cpu_proc'] }));
var rss = zip(ts, json.data.map(function(d) { return d['rss'] / (1.0 * 1024 * 1024) }));
Expand Down
6 changes: 4 additions & 2 deletions h2o-perf/web/prototype/php/post2.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?php
include 'DB2.php';

$test = $_POST['test_run_id'];
$test = $_POST['test_name'];
$ip = $_POST['ip'];
$dt = $_POST['dt'];

$query = "SELECT * FROM stats WHERE test_name ='" . $test . "' AND node_ip = '" . $ip . "' AND from_unixtime(ts, '%Y%m%d') = '" . $dt . "' AND test_run_id IN (SELECT MAX(test_run_id) FROM stats WHERE test_name ='" . $test . "' AND node_ip = '" . $ip . "' AND from_unixtime(ts, '%Y%m%d') = '" . $dt . "');";

$query = "SELECT * FROM stats WHERE test_run_id =" . $test . " AND node_ip = '" . $ip . "';";

$result = mysqli_prepare($con, $query);
if ( !$result ) {
Expand Down

0 comments on commit 4588bff

Please sign in to comment.