From 63568483fa326750437fd1bbc1225f59205b8ec0 Mon Sep 17 00:00:00 2001 From: tcrivat Date: Sat, 16 Jul 2016 23:25:59 +0200 Subject: [PATCH] mysql frontend: fixed performance metrics Performance metrics graphs were broken since commit 3775cf6b7f4b44e899ebf72232463fd1ec0310fb. 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. --- conpaas-frontend/www/ajax/getMysqlStats.php | 1 + .../www/ajax/mysqlPerformance.php | 1 - conpaas-frontend/www/js/mysql.js | 123 +++++++++++------- .../www/lib/service/mysql/__init__.php | 68 +++++----- .../www/lib/ui/page/mysql/__init__.php | 2 +- 5 files changed, 113 insertions(+), 82 deletions(-) diff --git a/conpaas-frontend/www/ajax/getMysqlStats.php b/conpaas-frontend/www/ajax/getMysqlStats.php index e597d5b0..6dca9919 100644 --- a/conpaas-frontend/www/ajax/getMysqlStats.php +++ b/conpaas-frontend/www/ajax/getMysqlStats.php @@ -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'; } diff --git a/conpaas-frontend/www/ajax/mysqlPerformance.php b/conpaas-frontend/www/ajax/mysqlPerformance.php index 10b83252..9f7cf6e0 100644 --- a/conpaas-frontend/www/ajax/mysqlPerformance.php +++ b/conpaas-frontend/www/ajax/mysqlPerformance.php @@ -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'; } diff --git a/conpaas-frontend/www/js/mysql.js b/conpaas-frontend/www/js/mysql.js index e8b74a67..d45d6381 100644 --- a/conpaas-frontend/www/js/mysql.js +++ b/conpaas-frontend/www/js/mysql.js @@ -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 */{ /** @@ -70,14 +73,32 @@ conpaas.ui = (function (this_module) { $('#loadform .loading').hide();this $('#loadform .error').html('Error: ' + error + '').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{ @@ -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;iMAXCPUUSAGE || 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; @@ -364,6 +401,7 @@ conpaas.ui = (function (this_module) { td.appendChild(a); } + */ } } }, @@ -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 diff --git a/conpaas-frontend/www/lib/service/mysql/__init__.php b/conpaas-frontend/www/lib/service/mysql/__init__.php index bce6916e..acaaba8f 100644 --- a/conpaas-frontend/www/lib/service/mysql/__init__.php +++ b/conpaas-frontend/www/lib/service/mysql/__init__.php @@ -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) { @@ -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; + } } ?> diff --git a/conpaas-frontend/www/lib/ui/page/mysql/__init__.php b/conpaas-frontend/www/lib/ui/page/mysql/__init__.php index e6dd7839..ee949742 100644 --- a/conpaas-frontend/www/lib/ui/page/mysql/__init__.php +++ b/conpaas-frontend/www/lib/ui/page/mysql/__init__.php @@ -197,7 +197,7 @@ public function renderPerformanceForm() { Outgoing
Packets Incoming
KBytes Outgoing
KBytes - Delete +