Skip to content

Commit

Permalink
mysql frontend: fixed performance metrics
Browse files Browse the repository at this point in the history
Performance metrics graphs were broken since commit 3775cf6.

Besides fixing the performance metrics for mysql, this commit also:

- removed the ability to delete a node from the performance monitoring table, as removing a node by IP address is not supported at the moment (the application manager handles removing of nodes, but in this case this call goes only to the service manager, so the node will be removed from the list but not deleted, which is not desirable).

- fixed a bug in the  performance monitoring table (nodes sometimes appeared twice in that table)

- removed some inconsistencies and restructured the code a little.
  • Loading branch information
tcrivat committed Jul 16, 2016
1 parent 31f77d7 commit 6356848
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 82 deletions.
1 change: 1 addition & 0 deletions conpaas-frontend/www/ajax/getMysqlStats.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
$service_data = ServiceData::getServiceById($sid);
$service = ServiceFactory::create($service_data);
$json = $service->getMySqlStats();
$json = $json['result'];
} catch (Exception $e) {
$json = 'Stats not available';
}
Expand Down
1 change: 0 additions & 1 deletion conpaas-frontend/www/ajax/mysqlPerformance.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
$service = ServiceFactory::create($service_data);
$json = $service->getMeanLoad();
$load = json_decode($json, true);
// $load['result']['meanLoad'];
} catch (Exception $e) {
$load = 'Load not available';
}
Expand Down
123 changes: 77 additions & 46 deletions conpaas-frontend/www/js/mysql.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ conpaas.ui = (function (this_module) {
this.service = service;
this.setupPoller_();
this.monitor_interval = null;
this.monitor_timer = 5000;
this.monitor_timer = 1000;
this.stats = new Array(10);
this.statsPS = new Array(10);
this.chart = [];
},
/* methods */{
/**
Expand Down Expand Up @@ -70,14 +73,32 @@ conpaas.ui = (function (this_module) {
$('#loadform .loading').hide();this
$('#loadform .error').html('Error: <b>' + error + '</b>').show();
},
// handlers
toggleStats: function(event){

initStats: function(event) {
this.stats[0] = ['10s', 'Select%', 'Update%', 'Insert%', 'Delete%'];
for (var i = 1; i < 10; i++) {
this.stats[i] = [''+10-i+'s',0,0,0,0];
this.statsPS[i] = [''+10-i+'s',0,0,0,0];
}
this.drawStats();
},

initChart: function(event) {
this.coords = [['time', 'Misalignment' ]]
for (i = 10; i >= 0; i--)
this.coords.push([i+'s', 0])
this.drawChart();
},

toggleStats: function(event) {
var page = event.data
text = $(event.target).html();
if (text == 'show'){
$("#monitor_div").show(500);
$(event.target).html('hide');


page.initStats();
page.initChart();
page.monitor_interval = setInterval(page.updateMonitor.bind(page), page.monitor_timer);
}
else{
Expand All @@ -88,19 +109,17 @@ conpaas.ui = (function (this_module) {
},

updateMonitor: function(){
this.drawChart();
this.drawStats();
this.updateChart();
this.updateStats();
this.gangliaMonitor();
},

drawChart: function() {
//update table data
coords=[['time', 'Misalignment' ]]
for(i=10; i>=0;i--)
coords.push([i+'s', 0])
updateChart: function() {
var coords = this.coords;

for (i=1;i<coords.length-1;i++)
coords[i][1]=coords[i+1][1];
//update table data
for (i = 1; i < coords.length-1; i++)
coords[i][1] = coords[i+1][1];

this.server.req('ajax/mysqlPerformance.php', {sid: this.service.sid}, 'get',
function(data) {
Expand All @@ -109,39 +128,39 @@ conpaas.ui = (function (this_module) {
}
);

var data = google.visualization.arrayToDataTable(coords);
this.drawChart();
},

drawChart: function() {
var data = google.visualization.arrayToDataTable(this.coords);
var options = {
title: 'MySQL Mean Misalignment'
};
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
},

drawStats: function() {
var stats= new Array(10);
var statsPS= new Array(10);
stats[0]=['10s', 'Select%', 'Update%', 'Insert%', 'Delete%'];
for ( var i =1; i<10;i++){
stats[i]=[''+10-i+'s',0,0,0,0];
statsPS[i]=[''+10-i+'s',0,0,0,0];
}
updateStats: function() {
var stats = this.stats;
var statsPS = this.statsPS;
//chart time shifting
for ( var i =1; i<9;i++){
for (var j=1; j<stats[i].length;j++){
stats[i][j]=stats[i+1][j];
statsPS[i][j]=statsPS[i+1][j];
for (var i = 1; i < 9; i++) {
for (var j = 1; j < stats[i].length; j++) {
stats[i][j] = stats[i+1][j];
statsPS[i][j] = statsPS[i+1][j];
}
}
// get the last update usage data from the cluster
this.server.req('ajax/getMysqlStats.php', {sid: this.service.sid}, 'get',
function (data) {
statsPS[stats.length-1]=[ '0s',
data['result']['meanSelect'] ,
data['result']['meanUpdate'] ,
data['result']['meanInsert'],
data['result']['meanDelete'] ];

stats[stats.length-1]=[ '0s',
statsPS[stats.length-1]=[ '1s',
data['meanSelect'] ,
data['meanUpdate'] ,
data['meanInsert'],
data['meanDelete'] ];

stats[stats.length-1]=[ '1s',
statsPS[statsPS.length-1][1]-statsPS[statsPS.length-2][1] ,
statsPS[statsPS.length-1][2]-statsPS[statsPS.length-2][2] ,
statsPS[statsPS.length-1][3]-statsPS[statsPS.length-2][3] ,
Expand All @@ -152,7 +171,7 @@ conpaas.ui = (function (this_module) {
+stats[stats.length-1][3]
+stats[stats.length-1][4]
)/100; //normalization to get in percentage
stats[stats.length-1]=[ '0s',
stats[stats.length-1]=[ '1s',
stats[stats.length-1][1]/ tot_operation ,
stats[stats.length-1][2]/ tot_operation ,
stats[stats.length-1][3]/ tot_operation ,
Expand All @@ -161,8 +180,11 @@ conpaas.ui = (function (this_module) {
},
function () { console.log("Error"); }
);
this.drawStats();
},

var data = google.visualization.arrayToDataTable(stats);
drawStats: function() {
var data = google.visualization.arrayToDataTable(this.stats);
var options = {
title: 'Cluster Usage',
hAxis: {title: 'Time in Sec', titleTextStyle: {color: '#333'}},
Expand All @@ -187,7 +209,7 @@ conpaas.ui = (function (this_module) {
if ($(this).attr("IP") =="127.0.0.1" || $(this).attr("NAME") =="conpaas")
host["hostname"]="Manager";
else
host["hostname"]=$(this).attr("IP");
host["hostname"]=$(this).attr("IP");


$(this).find('METRIC[NAME="cpu_idle"]').each(function (){
Expand Down Expand Up @@ -228,8 +250,13 @@ conpaas.ui = (function (this_module) {

$(this).find('METRIC[NAME="bytes_in"]').each(function (){
host[$(this).attr("NAME")]=$(this).attr("VAL"); });

nodesStats.push(host);

// Make sure a node is not added twice
var sameNodes = nodesStats.filter(function (otherHost) {
return otherHost['hostname'] == host['hostname'];
});
if (sameNodes.length == 0)
nodesStats.push(host);
});

var found=false;
Expand Down Expand Up @@ -334,11 +361,21 @@ conpaas.ui = (function (this_module) {
var tx = document.createTextNode((z[index]["bytes_out"]/1024).toFixed(2));
td.appendChild(tx);
newtr.appendChild(td);
var td = document.createElement('td');
newtr.appendChild(td);

// if (cpuUsage>MAXCPUUSAGE || memUsage>MAXMEMUSAGE || diskUsage>MAXDISKUSAGE )
// newtr.style.backgroundColor="#fb4b4b";

// Deleting a specific node is not supported at the moment because
// the request will not go to the Application manager, so the node
// will not actually be deleted but only removed from the service
// manager's list.

// TODO: enable this again and fix the issue

/*
var td = document.createElement('td');
newtr.appendChild(td);
if (z[index]["hostname"]!="Manager"){
var a = document.createElement('input');
var sid = this.service.sid;
Expand All @@ -364,6 +401,7 @@ conpaas.ui = (function (this_module) {
td.appendChild(a);
}
*/
}
}
},
Expand Down Expand Up @@ -423,13 +461,6 @@ $(document).ready(function () {
page.pollState(function () {
window.location.reload();
});
}else
{
if(page.service.reachable && page.service.state == 'RUNNING'){
// google.load("visualization", "1", {packages:["corechart"]});

}

}
}, function () {
// error
Expand Down
68 changes: 34 additions & 34 deletions conpaas-frontend/www/lib/service/mysql/__init__.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function loadFile($file) {
));
}

public function getCPU(){
public function getCPU() {
$json_info = $this->managerRequest('get', 'get_service_performance',array() );
$info = json_decode($json_info, true);
if ($info == null) {
Expand All @@ -92,43 +92,43 @@ public function getCPU(){
//print_r($info);
return $info[ 'result' ]['throughput'];//var_export($info, true);
}
public function getMeanLoad(){
$json_info = $this->managerRequest('get', 'getMeanLoad',array() );
$info = json_decode($json_info, true);
if ($info == null)
return false;
return $info['result']['meanLoad'];
}

public function getMySqlStats(){
$json_info = $this->managerRequest('get', 'getMeanLoad',array() );
$info = json_decode($json_info, true);
if ($info == null) {
return false;
}
return $info;
}

public function getGangliaParams(){
$json_info = $this->managerRequest('get', 'getGangliaParams',array() );
$info = json_decode($json_info, true);
if ($info == null) {
return false;
}

return $info;

public function getMeanLoad() {
$json_info = $this->managerRequest('get', 'getMeanLoad',array() );
$info = json_decode($json_info, true);
if ($info == null)
return false;
return $info['result']['meanLoad'];
}

public function getMySqlStats() {
$json_info = $this->managerRequest('get', 'getMeanLoad',array() );
$info = json_decode($json_info, true);
if ($info == null) {
return false;
}
return $info;
}

public function remove_specific_node($ip){
$json_info = $this->managerRequest('get', 'remove_specific_nodes',array('ip' => $ip) );
$info = json_decode($json_info, true);
if ($info == null) {
return false;
}
public function getGangliaParams() {
$json_info = $this->managerRequest('get', 'getGangliaParams',array() );
$info = json_decode($json_info, true);
if ($info == null) {
return false;
}

return $info;
}
return $info;
}

public function remove_specific_node($ip) {
$json_info = $this->managerRequest('get', 'remove_specific_nodes',array('ip' => $ip) );
$info = json_decode($json_info, true);
if ($info == null) {
return false;
}

return $info;
}

}
?>
2 changes: 1 addition & 1 deletion conpaas-frontend/www/lib/ui/page/mysql/__init__.php
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ public function renderPerformanceForm() {
<td>Outgoing<br>Packets</td>
<td>Incoming<br>KBytes</td>
<td>Outgoing<br>KBytes</td>
<td>Delete</td>
<!--<td>Delete</td>-->
</tr>
</thead>
<tbody>
Expand Down

0 comments on commit 6356848

Please sign in to comment.