diff --git a/.gitignore b/.gitignore
index 64932d7..c8b3039 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,4 @@
+.gitignore
src/app/etc/mothership/environments/environment_vm.php
-src/app/etc/mothership/environments/environment_live.php
\ No newline at end of file
+src/app/etc/mothership/environments/environment_live.php
+/vendor/
diff --git a/src/lib/Mothership/Magerun/Patch/AbstractMagentoPatch.php b/src/lib/Mothership/Magerun/Patch/AbstractMagentoPatch.php
new file mode 100644
index 0000000..79484f4
--- /dev/null
+++ b/src/lib/Mothership/Magerun/Patch/AbstractMagentoPatch.php
@@ -0,0 +1,92 @@
+
+ * @copyright 2016 Mothership Gmbh
+ * @link http://www.mothership.de/
+ */
+abstract class AbstractMagentoPatch implements PatchInterface
+{
+ protected $pathDir;
+
+ protected $magento_root;
+ protected $mage_php; //Mage.php original file from magento
+ protected $app_php; //App.php original file from Magento
+
+ public function __construct()
+ {
+ $this->pathDir = $this->setPathDirectory();
+ }
+
+ /**
+ * add the patch
+ *
+ * @param $magentoRoot
+ *
+ * @return void
+ */
+ function addPatch($magentoRoot)
+ {
+ $this->storeOriginalFilesPatched($magentoRoot);
+ }
+
+ /**
+ * remove patch
+ *
+ * @return void
+ *
+ * @throws \Exception
+ */
+ function removePatch()
+ {
+ if (is_null($this->magento_root)) {
+ throw new \Exception("Patch is not added to Magento yet");
+ }
+
+ file_put_contents($this->magento_root . "/app/Mage.php", $this->mage_php);
+ file_put_contents($this->magento_root . "/app/code/core/Mage/Core/Model/App.php", $this->app_php);
+ }
+
+ /**
+ * Store original files content before to add the patch
+ *
+ * @param $magentoRoot
+ *
+ * @throws \Exception
+ */
+ protected function storeOriginalFilesPatched($magentoRoot)
+ {
+ $this->magento_root = $magentoRoot;
+
+ if (!file_exists($this->magento_root . "/app/Mage.php")) {
+ throw new \Exception($this->magento_root . "/app/Mage.php doesn't exist");
+ }
+
+ if (!file_exists($this->magento_root . "/app/code/core/Mage/Core/Model/App.php")) {
+ throw new \Exception($this->magento_root . "/app/code/core/Mage/Core/Model/App.php doesn't exist");
+ }
+
+ $this->magento_root = $magentoRoot;
+ $this->mage_php = file_get_contents($this->magento_root . '/app/Mage.php');
+ $this->app_php = file_get_contents($this->magento_root . "/app/code/core/Mage/Core/Model/App.php");
+
+ }
+
+ /**
+ * Set the path directory of the patch
+ *
+ * @return void
+ */
+ abstract protected function setPathDirectory();
+}
diff --git a/src/lib/Mothership/Magerun/Patch/AbstractMagentoPatchFactory.php b/src/lib/Mothership/Magerun/Patch/AbstractMagentoPatchFactory.php
new file mode 100644
index 0000000..e9591c5
--- /dev/null
+++ b/src/lib/Mothership/Magerun/Patch/AbstractMagentoPatchFactory.php
@@ -0,0 +1,66 @@
+
+ * @copyright 2016 Mothership Gmbh
+ * @link http://www.mothership.de/
+ */
+abstract class AbstractMagentoPatchFactory
+{
+ /**
+ * @var string (ex. 1.9.2.3)
+ */
+ protected $magentoVersion;
+ /**
+ * the patch to apply
+ *
+ * @var PatchInterface
+ */
+ protected $patch;
+
+ /**
+ * AbstractMagentoPatchFactory constructor.
+ *
+ * @param $magentoV
+ */
+ public function __construct($magentoV)
+ {
+ $this->magentoVersion = $magentoV;
+ }
+
+ /**
+ * Get the class for the patch, in base of the Magento version
+ *
+ * @return void
+ *
+ * @throws \Exception if the patch is not set
+ */
+ abstract protected function setMagentoPatchClass();
+
+ /**
+ *
+ * @return mixed
+ *
+ * @throws \Exception
+ */
+ public function getPatch()
+ {
+ try {
+ $this->setMagentoPatchClass();
+ return $this->patch;
+ } catch (\Exception $e) {
+ throw $e;
+ }
+
+ }
+}
diff --git a/src/lib/Mothership/Magerun/Patch/PatchInterface.php b/src/lib/Mothership/Magerun/Patch/PatchInterface.php
new file mode 100644
index 0000000..dd4d551
--- /dev/null
+++ b/src/lib/Mothership/Magerun/Patch/PatchInterface.php
@@ -0,0 +1,37 @@
+
+ * @copyright 2016 Mothership Gmbh
+ * @link http://www.mothership.de/
+ */
+Interface PatchInterface
+{
+ /**
+ * add the patch
+ *
+ * @param $magentoRoot
+ *
+ * @return void
+ */
+ function addPatch($magentoRoot);
+
+ /**
+ * remove patch
+ *
+ * @return void
+ */
+ function removePatch();
+
+}
+
diff --git a/src/lib/Mothership/Magerun/Signal/AbstractHandler.php b/src/lib/Mothership/Magerun/Signal/AbstractHandler.php
new file mode 100644
index 0000000..b1be790
--- /dev/null
+++ b/src/lib/Mothership/Magerun/Signal/AbstractHandler.php
@@ -0,0 +1,75 @@
+
+ * @copyright 2016 Mothership Gmbh
+ * @link http://www.mothership.de/
+ */
+abstract class AbstractHandler implements HandleInterface
+{
+ /**
+ * Output to the command line
+ *
+ * @var OutputInterface
+ */
+ protected $output;
+
+ /**
+ * Handler constructor.
+ *
+ * @param OutputInterface $output
+ */
+ public function __construct(OutputInterface $output)
+ {
+ $this->output = $output;
+
+ declare(ticks = 1);
+
+ $this->run();
+ }
+
+ /**
+ * Handle the signal from the terminal
+ *
+ * @return void
+ */
+ public function run()
+ {
+ $this->configureSignals();
+ }
+
+ /**
+ * Wait $seconds for the term signal (SIGTERM)
+ *
+ * @param int $seconds
+ *
+ * @return void
+ */
+ public function waitForTermSignal($seconds = 1)
+ {
+ $info = [];
+ pcntl_sigtimedwait(array(SIGTERM), $info, $seconds);
+ }
+
+ /**
+ * Signal to handle
+ *
+ * @return void
+ */
+ abstract public function configureSignals();
+}
diff --git a/src/lib/Mothership/Magerun/Signal/HandleInterface.php b/src/lib/Mothership/Magerun/Signal/HandleInterface.php
new file mode 100644
index 0000000..7f26ead
--- /dev/null
+++ b/src/lib/Mothership/Magerun/Signal/HandleInterface.php
@@ -0,0 +1,32 @@
+
+ * @copyright 2016 Mothership Gmbh
+ * @link http://www.mothership.de/
+ */
+interface HandleInterface
+{
+ /**
+ * Start the handler
+ * @return void
+ */
+ function run();
+
+ /**
+ * action done when stop handle
+ *
+ * @return void
+ */
+ function stop();
+}
diff --git a/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/HandlePatch.php b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/HandlePatch.php
new file mode 100644
index 0000000..058f6a3
--- /dev/null
+++ b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/HandlePatch.php
@@ -0,0 +1,67 @@
+
+ * @copyright 2016 Mothership Gmbh
+ * @link http://www.mothership.de/
+ */
+class HandlePatch extends AbstractHandler
+{
+ protected $patch;
+
+ public function __construct(OutputInterface $output, PatchInterface $patch)
+ {
+ parent::__construct($output);
+ if(is_null($patch)){
+ throw new \Exception("Patch class can't be null");
+ }
+ $this->patch = $patch;
+ }
+
+ /**
+ * Signal to handle
+ *
+ * @return void
+ */
+ public function configureSignals()
+ {
+ pcntl_signal(SIGINT, function ($signal) {
+ $this->output->writeln("Handle signal: " . $signal . "");
+ $this->stop();
+ });
+
+ pcntl_signal(SIGTSTP, function ($signal) {
+ $this->output->writeln("Handle signal: " . $signal . "");
+ $this->stop();
+ });
+ }
+
+ /**
+ * action done when stop handle
+ *
+ * @return void
+ */
+ public function stop()
+ {
+ $this->output->writeln("Removing patch");
+ $this->patch->removePatch();
+ $this->output->writeln("Stop reporting");
+ exit;
+ }
+}
+
diff --git a/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/MagentoPatch1922.php b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/MagentoPatch1922.php
new file mode 100644
index 0000000..e0af9cb
--- /dev/null
+++ b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/MagentoPatch1922.php
@@ -0,0 +1,63 @@
+
+ * @copyright 2016 Mothership Gmbh
+ * @link http://www.mothership.de/
+ */
+class MagentoPatch1922 extends AbstractMagentoPatch
+{
+
+ /**
+ * add the patch
+ *
+ * @param $magentoRoot
+ *
+ * @return void
+ */
+ function addPatch($magentoRoot)
+ {
+ parent::addPatch($magentoRoot);
+
+ $patch_mageRun = file_get_contents($this->pathDir . "/patch/observerstimes_mageRun");
+ $patch_mageRunEnd = file_get_contents($this->pathDir . "/patch/observerstimes_mageRunEnd");
+
+ $mage_log = str_replace("Varien_Profiler::start('mage');", "Varien_Profiler::start('mage');" . $patch_mageRun,
+ $this->mage_php);
+ $mage_log = str_replace("Varien_Profiler::stop('mage');", $patch_mageRunEnd . "Varien_Profiler::stop('mage');",
+ $mage_log);
+
+ file_put_contents($this->magento_root . "/app/Mage.php", $mage_log);
+
+ $app_log = str_replace("Varien_Profiler::start('OBSERVER: '",
+ "\$startime=microtime(true);Varien_Profiler::start('OBSERVER: '", $this->app_php);
+
+ $patch_observer = file_get_contents($this->pathDir . "/patch/observerstimes_observer");
+
+ $app_log = str_replace("Varien_Profiler::stop('OBSERVER: '", $patch_observer . "Varien_Profiler::stop
+ ('OBSERVER: '", $app_log);
+ file_put_contents($this->magento_root . "/app/code/core/Mage/Core/Model/App.php", $app_log);
+ }
+
+ /**
+ * Set the path directory of the patch
+ *
+ * @return void
+ */
+ protected function setPathDirectory()
+ {
+ return __DIR__ . '/patches/Magento/1_9_2_2';
+ }
+}
diff --git a/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/MagentoPatch1923.php b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/MagentoPatch1923.php
new file mode 100644
index 0000000..2757ecf
--- /dev/null
+++ b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/MagentoPatch1923.php
@@ -0,0 +1,69 @@
+
+ * @copyright 2016 Mothership Gmbh
+ * @link http://www.mothership.de/
+ */
+class MagentoPatch1923 extends AbstractMagentoPatch
+{
+ /**
+ * add the patch
+ *
+ * @param $magentoRoot
+ *
+ * @return void
+ */
+ function addPatch($magentoRoot)
+ {
+ parent::addPatch($magentoRoot);
+
+ try {
+ $patch_mageRun = file_get_contents($this->pathDir . "/observerstimes_mageRun");
+ $patch_mageRunEnd = file_get_contents($this->pathDir . "/observerstimes_mageRunEnd");
+
+ $mage_log = str_replace("Varien_Profiler::start('mage');", "Varien_Profiler::start('mage');" . $patch_mageRun,
+ $this->mage_php);
+ $mage_log = str_replace("Varien_Profiler::stop('mage');", $patch_mageRunEnd . "Varien_Profiler::stop('mage');",
+ $mage_log);
+
+ file_put_contents($this->magento_root . "/app/Mage.php", $mage_log);
+
+ $app_log = str_replace("Varien_Profiler::start('OBSERVER: '",
+ "\$startime=microtime(true);Varien_Profiler::start('OBSERVER: '", $this->app_php);
+
+ $patch_observer = file_get_contents($this->pathDir . "/observerstimes_observer");
+
+ $app_log = str_replace("Varien_Profiler::stop('OBSERVER: '", $patch_observer . "Varien_Profiler::stop
+ ('OBSERVER: '", $app_log);
+ file_put_contents($this->magento_root . "/app/code/core/Mage/Core/Model/App.php", $app_log);
+ } catch (\Exception $e) {
+ $this->removePatch();
+ die($e->getMessage());
+ }
+
+ }
+
+ /**
+ * Set the path directory of the patch
+ *
+ * @return void
+ */
+ protected function setPathDirectory()
+ {
+ return __DIR__ . '/patches/Magento/1_9_2_3';
+ }
+
+}
diff --git a/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/MagentoPatchFactory.php b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/MagentoPatchFactory.php
new file mode 100644
index 0000000..d919e54
--- /dev/null
+++ b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/MagentoPatchFactory.php
@@ -0,0 +1,46 @@
+
+ * @copyright 2016 Mothership Gmbh
+ * @link http://www.mothership.de/
+ */
+class MagentoPatchFactory extends AbstractMagentoPatchFactory
+{
+
+ /**
+ * Get the class for the patch, in base of the Magento version
+ *
+ * @return void
+ *
+ * @throws \Exception
+ */
+ protected function setMagentoPatchClass()
+ {
+ switch ($this->magentoVersion) {
+ case "1.9.2.2":
+ $this->patch = new MagentoPatch1922();
+ break;
+ case "1.9.2.3":
+ $this->patch = new MagentoPatch1923();
+ break;
+ default:
+ throw new \Exception("The patch for your Magento version is implemented yet");
+ }
+
+ }
+}
+
diff --git a/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/ObserversTimesCommand.php b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/ObserversTimesCommand.php
index cd58092..cf5d794 100644
--- a/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/ObserversTimesCommand.php
+++ b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/ObserversTimesCommand.php
@@ -14,19 +14,29 @@
use \Mothership\Magerun\Base\Command\AbstractMagentoCommand;
/**
+ * Class ObserversTimesCommand
+ *
* This command provide methods to retrieve a csv reports with all the events and relative observers called for each
* Magento page with the execution time
- * @package Mothership_Addons\Reports
+ *
+ * @category Mothership
+ * @package Mothership_Reports
+ * @author Maurizio Brioschi
+ * @copyright 2015 Mothership GmbH
+ * @link http://www.mothership.de/
*/
class ObserversTimesCommand extends AbstractMagentoCommand
{
- protected $magento_root;
protected $observerlog_dir;
- protected $mage_php; //Mage.php original file from magento
- protected $app_php; //App.php original file from Magento
protected $dateStart;
protected $file_report = [];
protected $timestampfile;
+ protected $magentoRoot;
+ /**
+ * Output to command line
+ * @var OutputInterface
+ */
+ protected $output;
protected $description = 'Create a csv report with the execution workflow and observers execution times';
@@ -37,11 +47,11 @@ protected function configure()
{
parent::configure();
$this->addOption(
- 'bootleneck',
- null,
- InputOption::VALUE_OPTIONAL,
- 'if set you have a detail analisys of the most expensive observers'
- );
+ 'bootleneck',
+ null,
+ InputOption::VALUE_OPTIONAL,
+ 'if set you have a detail analisys of the most expensive observers'
+ );
}
/**
@@ -52,31 +62,42 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
+
parent::execute($input, $output);
- $this->handleSygnal();
$this->output = $output;
- $this->magento_root = $this->getApplication()->getMagentoRootFolder();
- $this->observerlog_dir = $this->magento_root . "/observerlogs";
+ $this->magentoRoot = $this->getApplication()->getMagentoRootFolder();
+ $this->observerlog_dir = $this->magentoRoot . "/observerlogs";
if (!file_exists($this->observerlog_dir)) {
mkdir($this->observerlog_dir, 0777);
}
- $this->dateStart = new \DateTime();
+
$bootleneck = false;
- $info = array();
- if ($input->getOption('bootleneck') == true) {
- $bootleneck = true;
- $this->output->writeln("I will report bootlenecks");
- }
$this->detectMagento($output);
if ($this->initMagento()) {
+ //add the patch
+ $factory = new MagentoPatchFactory(\Mage::getVersion());
+ $patch = $factory->getPatch();
$this->output->writeln("Applying the patch...");
- $this->addPatch();
+ $patch->addPatch($this->magentoRoot);
+
+ if ($input->getOption('bootleneck') == true) {
+ $bootleneck = true;
+ $this->output->writeln("I will report bootlenecks");
+ /**
+ * If i check for bootlenecks i will execute an infinite loop until a Term signal is call in the command line
+ * In the loop i check if there are new file in the log directory and i will analyze them for bootlenecks
+ */
+ $handle = new HandlePatch($this->output, $patch);
+ }
+
$this->output->writeln("Start reporting...");
$this->output->writeln("Press Ctrl+z or Ctrl+c to stop!");
$this->file_report = scandir($this->observerlog_dir);
$this->timestampfile = filemtime($this->observerlog_dir . '/timestamp');
+
+ $this->dateStart = new \DateTime();
if ($bootleneck) {
while (true) {
$this->output->write(".");
@@ -84,71 +105,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
if (count($newfiles) > count($this->file_report)) {
$this->checkBootleneck($newfiles);
}
-
- pcntl_sigtimedwait(array(SIGTERM), $info, 1);
+ $handle->waitForTermSignal();
}
} else {
- pcntl_sigtimedwait(array(SIGTERM), $info, 1);
+ $handle->waitForTermSignal();
}
-
}
-
$this->output->writeln("Init Magento fail");
}
- /**
- * Function call on SIGNTERM to stop reporting
- */
- public function stopObserver()
- {
- $this->output->writeln("Removing patch");
- $this->removePatch();
- $this->output->writeln("Stop reporting");
- exit;
- }
-
- /**
- * add patches
- */
- protected function addPatch()
- {
- $this->mage_php = file_get_contents($this->magento_root . '/app/Mage.php');
-
- $patch_mageRun = file_get_contents(dirname(__FILE__) . "/patch/observerstimes_mageRun");
- $patch_mageRunEnd = file_get_contents(dirname(__FILE__) . "/patch/observerstimes_mageRunEnd");
-
- $mage_log = str_replace("Varien_Profiler::start('mage');", "Varien_Profiler::start('mage');" . $patch_mageRun,
- $this->mage_php);
- $mage_log = str_replace("Varien_Profiler::stop('mage');", $patch_mageRunEnd . "Varien_Profiler::stop('mage');",
- $mage_log);
-
- file_put_contents($this->magento_root . "/app/Mage.php", $mage_log);
-
- $this->app_php = file_get_contents($this->magento_root . "/app/code/core/Mage/Core/Model/App.php");
- $app_log = str_replace("Varien_Profiler::start('OBSERVER: '",
- "\$startime=microtime(true);Varien_Profiler::start('OBSERVER: '", $this->app_php);
-
- $patch_observer = file_get_contents(dirname(__FILE__) . "/patch/observerstimes_observer");
-
- $app_log = str_replace("Varien_Profiler::stop('OBSERVER: '", $patch_observer . "Varien_Profiler::stop
- ('OBSERVER: '", $app_log);
- file_put_contents($this->magento_root . "/app/code/core/Mage/Core/Model/App.php", $app_log);
-
- }
-
- /**
- * remove patches
- */
- protected function removePatch()
- {
- file_put_contents($this->magento_root . "/app/Mage.php", $this->mage_php);
- file_put_contents($this->magento_root . "/app/code/core/Mage/Core/Model/App.php", $this->app_php);
- }
-
/**
* Analise bottleneck from all the files in the array and print the output on the terminal line
+ *
* @param array $newfiles
*/
protected function checkBootleneck(array $newfiles)
@@ -182,7 +152,9 @@ protected function checkBootleneck(array $newfiles)
/**
* Try to get the contents of a report files, if it's lock from Magento, sleep for 1 sec.
+ *
* @param $filename
+ *
* @return string
*/
protected function getFileContent($filename)
@@ -202,23 +174,5 @@ protected function getFileContent($filename)
}
}
- /**
- * Handle the signal from the terminal
- */
- private function handleSygnal()
- {
- declare(ticks = 1);
-
- pcntl_signal(SIGINT, function ($signal) {
- $this->output->writeln("Handle signal: " . $signal . "");
- $this->stopObserver();
- });
-
- pcntl_signal(SIGTSTP, function ($signal) {
- $this->output->writeln("Handle signal: " . $signal . "");
- $this->stopObserver();
- });
- }
-
}
\ No newline at end of file
diff --git a/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patch/observerstimes_dispatchEvent b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_2/observerstimes_dispatchEvent
similarity index 100%
rename from src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patch/observerstimes_dispatchEvent
rename to src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_2/observerstimes_dispatchEvent
diff --git a/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patch/observerstimes_mageRun b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_2/observerstimes_mageRun
similarity index 100%
rename from src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patch/observerstimes_mageRun
rename to src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_2/observerstimes_mageRun
diff --git a/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patch/observerstimes_mageRunEnd b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_2/observerstimes_mageRunEnd
similarity index 100%
rename from src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patch/observerstimes_mageRunEnd
rename to src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_2/observerstimes_mageRunEnd
diff --git a/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patch/observerstimes_observer b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_2/observerstimes_observer
similarity index 100%
rename from src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patch/observerstimes_observer
rename to src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_2/observerstimes_observer
diff --git a/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_3/observerstimes_dispatchEvent b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_3/observerstimes_dispatchEvent
new file mode 100644
index 0000000..7ca2eb5
--- /dev/null
+++ b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_3/observerstimes_dispatchEvent
@@ -0,0 +1,2 @@
+$fp = $GLOBALS['fp'];
+fputcsv($fp, [$name,"","","","",""],';');
\ No newline at end of file
diff --git a/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_3/observerstimes_mageRun b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_3/observerstimes_mageRun
new file mode 100644
index 0000000..ae280d9
--- /dev/null
+++ b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_3/observerstimes_mageRun
@@ -0,0 +1,10 @@
+$basefilename = __DIR__."/../observerlogs/observerstimes";
+$now = new \DateTime();
+$url = str_replace('/','_',$_SERVER['REQUEST_URI']);
+$filename = $basefilename."_".$now->format('YmdH').$url.".log.csv";
+
+$fp = fopen($filename, 'w');
+
+flock($fp, LOCK_EX);
+$GLOBALS['fp'] = $fp;
+fputcsv($fp, ["EVENT","OBSERVER","TYPE","METHOD","MODEL","TIME(ms)"],';');
\ No newline at end of file
diff --git a/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_3/observerstimes_mageRunEnd b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_3/observerstimes_mageRunEnd
new file mode 100644
index 0000000..4f590a0
--- /dev/null
+++ b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_3/observerstimes_mageRunEnd
@@ -0,0 +1,3 @@
+fflush($fp); // flush output before releasing the lock
+flock($fp, LOCK_UN);
+fclose($fp);
\ No newline at end of file
diff --git a/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_3/observerstimes_observer b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_3/observerstimes_observer
new file mode 100644
index 0000000..f429bb6
--- /dev/null
+++ b/src/lib/n98-magerun/modules/mothership_addons/src/Mothership/Magerun/Base/Command/Reports/patches/Magento/1_9_2_3/observerstimes_observer
@@ -0,0 +1,4 @@
+$diff = round(microtime(true) - $startime,3)*1000;
+
+$fp = $GLOBALS['fp'];
+fputcsv($fp, ["",$obsName,$obs['type'],$obs['method'],$obs['model'],$diff],';');
\ No newline at end of file