From 7cf834b164febb360a534158d2dfa48f3610345f Mon Sep 17 00:00:00 2001 From: Anders Kvist Date: Fri, 1 Sep 2017 11:51:50 +0200 Subject: [PATCH 1/5] Moved explain plugin config to seperate file to allow for automated generation of plugin config. --- conf/sample.config.inc.php | 46 ++++---------------------------------- 1 file changed, 4 insertions(+), 42 deletions(-) diff --git a/conf/sample.config.inc.php b/conf/sample.config.inc.php index fe51fbb4..2c6cbb85 100644 --- a/conf/sample.config.inc.php +++ b/conf/sample.config.inc.php @@ -37,6 +37,10 @@ require_once($datasource); } +foreach(glob("conf/plugins_*.inc.php") as $plugin) { + require_once($plugin); +} + /** * If you're using Anemometer with MySQL 5.6's performance schema, * then use this datasource @@ -246,48 +250,6 @@ * explain plugin, then these sections will not be displayed. * */ -$conf['plugins'] = array( - - 'visual_explain' => '/usr/bin/pt-visual-explain', -# percona toolkit has removed query advisor -# 'query_advisor' => '/usr/bin/pt-query-advisor', - - 'show_create' => true, - 'show_status' => true, - - 'explain' => function ($sample) { - $conn = array(); - - if (!array_key_exists('hostname_max',$sample) or strlen($sample['hostname_max']) < 5) - { - return; - } - - $pos = strpos($sample['hostname_max'], ':'); - if ($pos === false) - { - $conn['port'] = 3306; - $conn['host'] = $sample['hostname_max']; - } - else - { - $parts = preg_split("/:/", $sample['hostname_max']); - $conn['host'] = $parts[0]; - $conn['port'] = $parts[1]; - } - - $conn['db'] = 'mysql'; - if ($sample['db_max'] != '') - { - $conn['db'] = $sample['db_max']; - } - - $conn['user'] = 'root'; - $conn['password'] = ''; - - return $conn; - }, -); /** * This is configuration information for how the actual sql queries are built From 95e1ba06d4ee66a1ac821ad31d50088ab49a02d3 Mon Sep 17 00:00:00 2001 From: Anders Kvist Date: Fri, 1 Sep 2017 11:54:12 +0200 Subject: [PATCH 2/5] Moved explain plugin config to seperate file to allow for automated generation of plugin config. --- conf/plugin_explain.inc.php | 43 +++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 conf/plugin_explain.inc.php diff --git a/conf/plugin_explain.inc.php b/conf/plugin_explain.inc.php new file mode 100644 index 00000000..59fdda8b --- /dev/null +++ b/conf/plugin_explain.inc.php @@ -0,0 +1,43 @@ + '/usr/bin/pt-visual-explain', +# percona toolkit has removed query advisor +# 'query_advisor' => '/usr/bin/pt-query-advisor', + + 'show_create' => true, + 'show_status' => true, + + 'explain' => function ($sample) { + $conn = array(); + + if (!array_key_exists('hostname_max',$sample) or strlen($sample['hostname_max']) < 5) + { + return; + } + + $pos = strpos($sample['hostname_max'], ':'); + if ($pos === false) + { + $conn['port'] = 3306; + $conn['host'] = $sample['hostname_max']; + } + else + { + $parts = preg_split("/:/", $sample['hostname_max']); + $conn['host'] = $parts[0]; + $conn['port'] = $parts[1]; + } + + $conn['db'] = 'mysql'; + if ($sample['db_max'] != '') + { + $conn['db'] = $sample['db_max']; + } + + $conn['user'] = 'root'; + $conn['password'] = ''; + + return $conn; + }, +); From 27b08523177f4f05f12f8edb4f9a10258532a412 Mon Sep 17 00:00:00 2001 From: Anders Kvist Date: Fri, 1 Sep 2017 12:46:40 +0200 Subject: [PATCH 3/5] Fixed typo --- conf/sample.config.inc.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/sample.config.inc.php b/conf/sample.config.inc.php index 2c6cbb85..30e4de71 100644 --- a/conf/sample.config.inc.php +++ b/conf/sample.config.inc.php @@ -37,7 +37,7 @@ require_once($datasource); } -foreach(glob("conf/plugins_*.inc.php") as $plugin) { +foreach(glob("conf/plugin_*.inc.php") as $plugin) { require_once($plugin); } From 9c36000758c2483bf2806c2c54fa0799b512509b Mon Sep 17 00:00:00 2001 From: Anders Kvist Date: Fri, 1 Sep 2017 13:21:18 +0200 Subject: [PATCH 4/5] Using plugins instead of plugin for name as the internal variables also are called plugins. --- conf/plugins_explain.inc.php | 43 ++++++++++++++++++++++++++++++++++++ conf/sample.config.inc.php | 2 +- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 conf/plugins_explain.inc.php diff --git a/conf/plugins_explain.inc.php b/conf/plugins_explain.inc.php new file mode 100644 index 00000000..59fdda8b --- /dev/null +++ b/conf/plugins_explain.inc.php @@ -0,0 +1,43 @@ + '/usr/bin/pt-visual-explain', +# percona toolkit has removed query advisor +# 'query_advisor' => '/usr/bin/pt-query-advisor', + + 'show_create' => true, + 'show_status' => true, + + 'explain' => function ($sample) { + $conn = array(); + + if (!array_key_exists('hostname_max',$sample) or strlen($sample['hostname_max']) < 5) + { + return; + } + + $pos = strpos($sample['hostname_max'], ':'); + if ($pos === false) + { + $conn['port'] = 3306; + $conn['host'] = $sample['hostname_max']; + } + else + { + $parts = preg_split("/:/", $sample['hostname_max']); + $conn['host'] = $parts[0]; + $conn['port'] = $parts[1]; + } + + $conn['db'] = 'mysql'; + if ($sample['db_max'] != '') + { + $conn['db'] = $sample['db_max']; + } + + $conn['user'] = 'root'; + $conn['password'] = ''; + + return $conn; + }, +); diff --git a/conf/sample.config.inc.php b/conf/sample.config.inc.php index 30e4de71..2c6cbb85 100644 --- a/conf/sample.config.inc.php +++ b/conf/sample.config.inc.php @@ -37,7 +37,7 @@ require_once($datasource); } -foreach(glob("conf/plugin_*.inc.php") as $plugin) { +foreach(glob("conf/plugins_*.inc.php") as $plugin) { require_once($plugin); } From 186ffe65d6e365502553c8834a1fe698f05e0889 Mon Sep 17 00:00:00 2001 From: Anders Kvist Date: Fri, 1 Sep 2017 13:34:27 +0200 Subject: [PATCH 5/5] Removing old plugin file. --- conf/plugin_explain.inc.php | 43 ------------------------------------- 1 file changed, 43 deletions(-) delete mode 100644 conf/plugin_explain.inc.php diff --git a/conf/plugin_explain.inc.php b/conf/plugin_explain.inc.php deleted file mode 100644 index 59fdda8b..00000000 --- a/conf/plugin_explain.inc.php +++ /dev/null @@ -1,43 +0,0 @@ - '/usr/bin/pt-visual-explain', -# percona toolkit has removed query advisor -# 'query_advisor' => '/usr/bin/pt-query-advisor', - - 'show_create' => true, - 'show_status' => true, - - 'explain' => function ($sample) { - $conn = array(); - - if (!array_key_exists('hostname_max',$sample) or strlen($sample['hostname_max']) < 5) - { - return; - } - - $pos = strpos($sample['hostname_max'], ':'); - if ($pos === false) - { - $conn['port'] = 3306; - $conn['host'] = $sample['hostname_max']; - } - else - { - $parts = preg_split("/:/", $sample['hostname_max']); - $conn['host'] = $parts[0]; - $conn['port'] = $parts[1]; - } - - $conn['db'] = 'mysql'; - if ($sample['db_max'] != '') - { - $conn['db'] = $sample['db_max']; - } - - $conn['user'] = 'root'; - $conn['password'] = ''; - - return $conn; - }, -);