Yireo_Mpi - Version 0.2.1

Version Notes

No notes

Download this release

Release Info

Developer Yireo
Extension Yireo_Mpi
Version 0.2.1
Comparing to
See all releases


Version 0.2.1

Files changed (54) hide show
  1. app/code/community/Yireo/Mpi/Block/Menu.php +54 -0
  2. app/code/community/Yireo/Mpi/Block/Overview.php +43 -0
  3. app/code/community/Yireo/Mpi/Helper/Data.php +94 -0
  4. app/code/community/Yireo/Mpi/Model/Check.php +50 -0
  5. app/code/community/Yireo/Mpi/Model/Check/Abstract.php +61 -0
  6. app/code/community/Yireo/Mpi/Model/Check/Enabled.php +30 -0
  7. app/code/community/Yireo/Mpi/Model/Check/EntryFile.php +35 -0
  8. app/code/community/Yireo/Mpi/Model/Check/Secret.php +35 -0
  9. app/code/community/Yireo/Mpi/Model/Check/Version.php +26 -0
  10. app/code/community/Yireo/Mpi/Model/Metric.php +249 -0
  11. app/code/community/Yireo/Mpi/Model/Resource.php +163 -0
  12. app/code/community/Yireo/Mpi/Model/Resource/Abstract.php +171 -0
  13. app/code/community/Yireo/Mpi/Model/Resource/Core/Attribute.php +66 -0
  14. app/code/community/Yireo/Mpi/Model/Resource/Core/Cache.php +45 -0
  15. app/code/community/Yireo/Mpi/Model/Resource/Core/Catalog.php +30 -0
  16. app/code/community/Yireo/Mpi/Model/Resource/Core/Compiler.php +42 -0
  17. app/code/community/Yireo/Mpi/Model/Resource/Core/Configuration.php +67 -0
  18. app/code/community/Yireo/Mpi/Model/Resource/Core/Customer.php +27 -0
  19. app/code/community/Yireo/Mpi/Model/Resource/Core/Indexer.php +41 -0
  20. app/code/community/Yireo/Mpi/Model/Resource/Core/Module.php +74 -0
  21. app/code/community/Yireo/Mpi/Model/Resource/Core/Rules.php +28 -0
  22. app/code/community/Yireo/Mpi/Model/Resource/Core/Sales.php +27 -0
  23. app/code/community/Yireo/Mpi/Model/Resource/Core/Session.php +34 -0
  24. app/code/community/Yireo/Mpi/Model/Resource/Core/Store.php +29 -0
  25. app/code/community/Yireo/Mpi/Model/Resource/Core/Version.php +46 -0
  26. app/code/community/Yireo/Mpi/Model/Resource/Database/Abstract.php +24 -0
  27. app/code/community/Yireo/Mpi/Model/Resource/Database/Basics.php +109 -0
  28. app/code/community/Yireo/Mpi/Model/Resource/Database/Status.php +59 -0
  29. app/code/community/Yireo/Mpi/Model/Resource/Database/Table.php +73 -0
  30. app/code/community/Yireo/Mpi/Model/Resource/Database/Variable.php +82 -0
  31. app/code/community/Yireo/Mpi/Model/Resource/Environment/Basics.php +73 -0
  32. app/code/community/Yireo/Mpi/Model/Resource/Environment/Log.php +29 -0
  33. app/code/community/Yireo/Mpi/Model/Resource/Environment/Report.php +27 -0
  34. app/code/community/Yireo/Mpi/Model/Resource/Environment/Session.php +27 -0
  35. app/code/community/Yireo/Mpi/Model/Resource/Php/Basics.php +88 -0
  36. app/code/community/Yireo/Mpi/Model/Resource/Php/Configuration.php +87 -0
  37. app/code/community/Yireo/Mpi/Model/Resource/Php/Module.php +35 -0
  38. app/code/community/Yireo/Mpi/Model/Resource/Security/Addhandler.php +39 -0
  39. app/code/community/Yireo/Mpi/Model/Resource/Security/Admin.php +44 -0
  40. app/code/community/Yireo/Mpi/Model/Resource/Security/Get.php +45 -0
  41. app/code/community/Yireo/Mpi/Model/Resource/Security/Shoplift.php +36 -0
  42. app/code/community/Yireo/Mpi/Model/Resource/Security/Xmlrpc.php +45 -0
  43. app/code/community/Yireo/Mpi/Model/Resource/Test.php +37 -0
  44. app/code/community/Yireo/Mpi/Model/Resource/Webserver/Advanced.php +41 -0
  45. app/code/community/Yireo/Mpi/Model/Resource/Webserver/Basics.php +56 -0
  46. app/code/community/Yireo/Mpi/controllers/IndexController.php +157 -0
  47. app/code/community/Yireo/Mpi/controllers/MpiController.php +49 -0
  48. app/code/community/Yireo/Mpi/etc/config.xml +138 -0
  49. app/code/community/Yireo/Mpi/etc/system.xml +60 -0
  50. app/design/adminhtml/default/default/template/mpi/menu.phtml +20 -0
  51. app/design/adminhtml/default/default/template/mpi/overview.phtml +59 -0
  52. app/etc/modules/Yireo_Mpi.xml +19 -0
  53. package.xml +2 -0
  54. yireo_mpi.php +100 -0
app/code/community/Yireo/Mpi/Block/Menu.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Mpi extension for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ class Yireo_Mpi_Block_Menu extends Mage_Core_Block_Template
12
+ {
13
+ /**
14
+ * Constructor method
15
+ */
16
+ public function _construct()
17
+ {
18
+ parent::_construct();
19
+
20
+ $this->setTemplate('mpi/menu.phtml');
21
+ }
22
+
23
+ /**
24
+ * Helper method to get a list of the menu-items
25
+ */
26
+ public function getMenuItems()
27
+ {
28
+ // Build the list of menu-items
29
+ $items = array(
30
+ array(
31
+ 'action' => 'index',
32
+ 'title' => 'System Check',
33
+ ),
34
+ );
35
+
36
+ $url = Mage::getModel('adminhtml/url');
37
+ $current_action = $this->getRequest()->getActionName();
38
+
39
+ foreach($items as $index => $item) {
40
+
41
+ if($item['action'] == $current_action) {
42
+ $item['class'] = 'active';
43
+ } else {
44
+ $item['class'] = 'inactive';
45
+ }
46
+
47
+ $item['url'] = $url->getUrl('adminhtml/mpi/'.$item['action']);
48
+
49
+ $items[$index] = $item;
50
+ }
51
+
52
+ return $items;
53
+ }
54
+ }
app/code/community/Yireo/Mpi/Block/Overview.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Mpi extension for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ class Yireo_Mpi_Block_Overview extends Mage_Core_Block_Template
12
+ {
13
+ /**
14
+ * Constructor method
15
+ */
16
+ public function _construct()
17
+ {
18
+ parent::_construct();
19
+
20
+ $this->setTemplate('mpi/overview.phtml');
21
+ }
22
+
23
+ /**
24
+ * Helper to return the header of this page
25
+ */
26
+ public function getHeader($title = null)
27
+ {
28
+ return 'Yireo MPI (Magento Performance Insights) - '.$this->__($title);
29
+ }
30
+
31
+ /**
32
+ * Helper to return the menu
33
+ */
34
+ public function getMenu()
35
+ {
36
+ return $this->getLayout()->createBlock('mpi/menu')->toHtml();
37
+ }
38
+
39
+ public function getChecks()
40
+ {
41
+ return Mage::getModel('mpi/check')->getResults();
42
+ }
43
+ }
app/code/community/Yireo/Mpi/Helper/Data.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Mpi helper
13
+ */
14
+ class Yireo_Mpi_Helper_Data extends Mage_Core_Helper_Abstract
15
+ {
16
+ /**
17
+ * @return bool|mixed
18
+ */
19
+ public function enabled()
20
+ {
21
+ if ((bool)Mage::getStoreConfig('advanced/modules_disable_output/Yireo_Mpi')) {
22
+ return false;
23
+ }
24
+
25
+ return Mage::getStoreConfig('mpi/settings/enabled');
26
+ }
27
+
28
+ /**
29
+ * @return mixed
30
+ */
31
+ public function getSecret()
32
+ {
33
+ return Mage::getStoreConfig('mpi/settings/secret');
34
+ }
35
+
36
+ /**
37
+ * @return bool
38
+ */
39
+ public function authenticate()
40
+ {
41
+ $secret = Mage::app()->getRequest()->getParam('secret');
42
+ $secret = trim($secret);
43
+
44
+ if (empty($secret)) {
45
+ return false;
46
+ }
47
+
48
+ if (strlen($secret) < 10) {
49
+ return false;
50
+ }
51
+
52
+ if ($secret == $this->getSecret()) {
53
+ return true;
54
+ }
55
+
56
+ return false;
57
+ }
58
+
59
+ public function log($string, $variable1 = null, $variable2 = null)
60
+ {
61
+ $string = $this->__($string, $variable1, $variable2);
62
+
63
+ // @todo: Add option for debugging
64
+
65
+ $logger = Mage::getModel('core/log_adapter', 'mpi.log');
66
+ $logger->log($string);
67
+ }
68
+
69
+ public function getMetricsFromRequest()
70
+ {
71
+ $metrics = Mage::app()->getRequest()->getParam('metric');
72
+ if (!empty($metrics)) {
73
+ $metrics = preg_replace('/([^a-zA-Z0-9\-\_\,]+)/', '', $metrics);
74
+ $metrics = explode(',', $metrics);
75
+ } else {
76
+ $metrics = array();
77
+ }
78
+
79
+ return $metrics;
80
+ }
81
+
82
+ public function getGroupsFromRequest()
83
+ {
84
+ $groups = Mage::app()->getRequest()->getParam('group');
85
+ if (!empty($groups)) {
86
+ $groups = preg_replace('/([^a-zA-Z0-9\-\_\,]+)/', '', $groups);
87
+ $groups = explode(',', $groups);
88
+ } else {
89
+ $groups = array();
90
+ }
91
+
92
+ return $groups;
93
+ }
94
+ }
app/code/community/Yireo/Mpi/Model/Check.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * System check class
13
+ */
14
+ class Yireo_Mpi_Model_Check
15
+ {
16
+ public function getResults()
17
+ {
18
+ $results = array();
19
+
20
+ $checkDir = BP . '/app/code/community/Yireo/Mpi/Model/Check/';
21
+ $checkFiles = scandir($checkDir);
22
+
23
+ foreach($checkFiles as $checkFile) {
24
+ if (preg_match('/\.php$/', $checkFile) == false) {
25
+ continue;
26
+ }
27
+
28
+ if ($checkFile == 'Abstract.php') {
29
+ continue;
30
+ }
31
+
32
+ $checkModelName = preg_replace('/\.php$/', '', $checkFile);
33
+
34
+ /** @var Yireo_Mpi_Model_Check_Abstract $checkModel */
35
+ $checkModel = Mage::getModel('mpi/check_'.$checkModelName);
36
+
37
+ if (empty($checkModel)) {
38
+ continue;
39
+ }
40
+
41
+ $checks = $checkModel->getChecks();
42
+
43
+ if (is_array($checks)) {
44
+ $results = array_merge($results, $checks);
45
+ }
46
+ }
47
+
48
+ return $results;
49
+ }
50
+ }
app/code/community/Yireo/Mpi/Model/Check/Abstract.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ *
13
+ */
14
+ class Yireo_Mpi_Model_Check_Abstract
15
+ {
16
+ /**
17
+ *
18
+ */
19
+ const RESULT_SUCCESS = 1;
20
+
21
+ /**
22
+ *
23
+ */
24
+ const RESULT_FAILED = 0;
25
+
26
+ /**
27
+ * @var array
28
+ */
29
+ protected $checks = array();
30
+
31
+ /**
32
+ * @param $name
33
+ * @param $label
34
+ * @param $result
35
+ */
36
+ public function addCheck($label, $resultText, $result)
37
+ {
38
+ if ($result == true) {
39
+ $result = self::RESULT_SUCCESS;
40
+ } else {
41
+ $result = self::RESULT_FAILED;
42
+ }
43
+
44
+ $check = (object)null;
45
+ $check->label = $label;
46
+ $check->result_text = $resultText;
47
+
48
+ // @todo: Implement images
49
+ $check->result_image = ($result) ? '[ok]' : '[failed]';
50
+
51
+ $this->checks[] = $check;
52
+ }
53
+
54
+ /**
55
+ * @return array
56
+ */
57
+ public function getChecks()
58
+ {
59
+ return $this->checks;
60
+ }
61
+ }
app/code/community/Yireo/Mpi/Model/Check/Enabled.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * System check class
13
+ */
14
+ class Yireo_Mpi_Model_Check_Enabled extends Yireo_Mpi_Model_Check_Abstract
15
+ {
16
+ /**
17
+ * Constructor
18
+ */
19
+ public function __construct()
20
+ {
21
+ $enabled = Mage::helper('mpi')->enabled();
22
+
23
+ if ($enabled == false) {
24
+ $this->addCheck('Enabled', 'The Yireo_MPI extension is disabled by setting', false);
25
+ return false;
26
+ }
27
+
28
+ $this->addCheck('Enabled' , 'The Yireo_MPI extension is enabled', true);
29
+ }
30
+ }
app/code/community/Yireo/Mpi/Model/Check/EntryFile.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * System check class
13
+ */
14
+ class Yireo_Mpi_Model_Check_EntryFile extends Yireo_Mpi_Model_Check_Abstract
15
+ {
16
+ /**
17
+ * Constructor
18
+ */
19
+ public function __construct()
20
+ {
21
+ $entryFile = BP.'/yireo_mpi.php';
22
+
23
+ if (!is_file($entryFile)) {
24
+ $this->addCheck('Entry File', 'PHP file <code>yireo_mpi.php</code> does not exist', false);
25
+ return false;
26
+ }
27
+
28
+ if (is_readable($entryFile) == false) {
29
+ $this->addCheck('Entry File', 'PHP file <code>yireo_mpi.php</code> exists but is not readable', false);
30
+ return false;
31
+ }
32
+
33
+ $this->addCheck('Entry File' , 'PHP file <code>yireo_mpi.php</code> exists', true);
34
+ }
35
+ }
app/code/community/Yireo/Mpi/Model/Check/Secret.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * System check class
13
+ */
14
+ class Yireo_Mpi_Model_Check_Secret extends Yireo_Mpi_Model_Check_Abstract
15
+ {
16
+ /**
17
+ * Constructor
18
+ */
19
+ public function __construct()
20
+ {
21
+ $secret = Mage::helper('mpi')->getSecret();
22
+
23
+ if (empty($secret)) {
24
+ $this->addCheck('API Key', 'You have not configured an API key yet', false);
25
+ return false;
26
+ }
27
+
28
+ if (strlen($secret) < 10) {
29
+ $this->addCheck('API Key', 'You have configured an invalid API key', false);
30
+ return false;
31
+ }
32
+
33
+ $this->addCheck('API Key' , 'You have a valid API Key', true);
34
+ }
35
+ }
app/code/community/Yireo/Mpi/Model/Check/Version.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * System check class
13
+ */
14
+ class Yireo_Mpi_Model_Check_Version extends Yireo_Mpi_Model_Check_Abstract
15
+ {
16
+ /**
17
+ * Constructor
18
+ */
19
+ public function __construct()
20
+ {
21
+ $config = Mage::app()->getConfig()->getModuleConfig('Yireo_Mpi');
22
+ $version = (string)$config->version;
23
+
24
+ $this->addCheck('Version', 'Current version is '.$version, true);
25
+ }
26
+ }
app/code/community/Yireo/Mpi/Model/Metric.php ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Metric container to handle all checks
13
+ */
14
+ class Yireo_Mpi_Model_Metric
15
+ {
16
+ /**
17
+ * Metric type
18
+ *
19
+ * @var string
20
+ */
21
+ protected $type = null;
22
+
23
+ /**
24
+ * Allowed metric types
25
+ */
26
+ protected $allowedTypes = array('int', 'bool', 'string', 'text', 'seconds', 'bytes', 'double', 'timestamp', 'array');
27
+
28
+ /**
29
+ * Metric name
30
+ *
31
+ * @var string
32
+ */
33
+ protected $name = null;
34
+
35
+ /**
36
+ * Metric value
37
+ *
38
+ * @var mixed
39
+ */
40
+ protected $value = null;
41
+
42
+ /**
43
+ * Message-level
44
+ *
45
+ * @var string
46
+ */
47
+ protected $level = null;
48
+
49
+ /**
50
+ * Timestamp at which this metric was started
51
+ *
52
+ * @var int
53
+ */
54
+ protected $startTime = null;
55
+
56
+ /**
57
+ * Timestamp at which this metric was ended
58
+ *
59
+ * @var int
60
+ */
61
+ protected $endTime = null;
62
+
63
+ /**
64
+ * Optional comment
65
+ *
66
+ * @var string
67
+ */
68
+ protected $comment = null;
69
+
70
+ /**
71
+ * Constructor
72
+ */
73
+ public function __construct($name = null, $value = null, $type = null, $level = null, $startTime = null, $endTime = null, $comment = null)
74
+ {
75
+ $this->setName($name);
76
+ $this->setValue($value);
77
+ $this->setType($type);
78
+ $this->setLevel($level);
79
+ $this->setStartTime($startTime);
80
+ $this->setEndTime($endTime);
81
+ $this->setComment($comment);
82
+ }
83
+
84
+ /**
85
+ * Method to export this metric to an array
86
+ */
87
+ public function export()
88
+ {
89
+ $data = array();
90
+ $data['name'] = $this->getName();
91
+ $data['value'] = $this->getValue();
92
+ $data['type'] = $this->getType();
93
+ $data['start_time'] = $this->getStartTime();
94
+ $data['end_time'] = $this->getEndTime();
95
+
96
+ $comment = $this->getComment();
97
+ if (!empty($comment)) {
98
+ $data['comment'] = $comment;
99
+ }
100
+
101
+ return $data;
102
+ }
103
+
104
+ /**
105
+ * @param mixed $name
106
+ */
107
+ public function setName($name)
108
+ {
109
+ $this->name = $name;
110
+ }
111
+
112
+ /**
113
+ * @return mixed
114
+ */
115
+ public function getName()
116
+ {
117
+ return $this->name;
118
+ }
119
+
120
+ /**
121
+ * @param mixed $type
122
+ *
123
+ * @throws Exception
124
+ */
125
+ public function setType($type)
126
+ {
127
+ if (empty($type)) {
128
+ return;
129
+ }
130
+
131
+ if (in_array($type, $this->allowedTypes) == false) {
132
+ throw new Exception('Unknown metric type');
133
+ }
134
+
135
+ $this->type = $type;
136
+ }
137
+
138
+ /**
139
+ * @return mixed
140
+ */
141
+ public function getType()
142
+ {
143
+ if (!empty($this->type)) {
144
+ return $this->type;
145
+ }
146
+
147
+ if (is_numeric($this->value)) {
148
+ return 'int';
149
+ }
150
+
151
+ if (is_bool($this->value)) {
152
+ return 'bool';
153
+ }
154
+
155
+ if (is_string($this->value)) {
156
+ return 'string';
157
+ }
158
+
159
+ return 'unknown';
160
+ }
161
+
162
+ /**
163
+ * @param mixed $value
164
+ */
165
+ public function setValue($value)
166
+ {
167
+ $this->value = $value;
168
+ }
169
+
170
+ /**
171
+ * @return mixed
172
+ */
173
+ public function getValue()
174
+ {
175
+ return $this->value;
176
+ }
177
+
178
+ /**
179
+ * @param mixed $comment
180
+ */
181
+ public function setComment($comment)
182
+ {
183
+ $this->comment = $comment;
184
+ }
185
+
186
+ /**
187
+ * @return mixed
188
+ */
189
+ public function getComment()
190
+ {
191
+ return $this->comment;
192
+ }
193
+
194
+ /**
195
+ * @param int $endTime
196
+ */
197
+ public function setEndTime($endTime)
198
+ {
199
+ if (empty($endTime)) {
200
+ $endTime = time();
201
+ }
202
+
203
+ $this->endTime = $endTime;
204
+ }
205
+
206
+ /**
207
+ * @return int
208
+ */
209
+ public function getEndTime()
210
+ {
211
+ return $this->endTime;
212
+ }
213
+
214
+ /**
215
+ * @param string $level
216
+ */
217
+ public function setLevel($level)
218
+ {
219
+ $this->level = $level;
220
+ }
221
+
222
+ /**
223
+ * @return string
224
+ */
225
+ public function getLevel()
226
+ {
227
+ return $this->level;
228
+ }
229
+
230
+ /**
231
+ * @param int $startTime
232
+ */
233
+ public function setStartTime($startTime)
234
+ {
235
+ if (empty($startTime)) {
236
+ $startTime = time();
237
+ }
238
+
239
+ $this->startTime = $startTime;
240
+ }
241
+
242
+ /**
243
+ * @return int
244
+ */
245
+ public function getStartTime()
246
+ {
247
+ return $this->startTime;
248
+ }
249
+ }
app/code/community/Yireo/Mpi/Model/Resource.php ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Main resource class to identify and collect resources from subclasses
13
+ */
14
+ class Yireo_Mpi_Model_Resource
15
+ {
16
+ /**
17
+ * Associative array of resource classes, grouped by collector class
18
+ *
19
+ * @var array
20
+ */
21
+ protected $resourceModels = array(
22
+ 'test' => array(
23
+ 'test',
24
+ ),
25
+ 'all' => array(
26
+ 'core_attribute',
27
+ 'core_cache',
28
+ 'core_catalog',
29
+ 'core_compiler',
30
+ 'core_configuration',
31
+ 'core_customer',
32
+ 'core_indexer',
33
+ 'core_module',
34
+ 'core_rules',
35
+ 'core_sales',
36
+ 'core_session',
37
+ 'core_store',
38
+ 'core_version',
39
+ 'environment_basics',
40
+ 'environment_log',
41
+ 'environment_report',
42
+ 'environment_session',
43
+ 'php_basics',
44
+ 'php_configuration',
45
+ 'php_module',
46
+ 'security_addhandler',
47
+ 'security_admin',
48
+ 'security_get',
49
+ 'security_shoplift',
50
+ 'security_xmlrpc',
51
+ 'webserver_advanced',
52
+ 'webserver_basics',
53
+ 'database_basics',
54
+ 'database_status',
55
+ 'database_table',
56
+ 'database_variable',
57
+ ),
58
+ 'poll_short' => array(
59
+ ),
60
+ 'poll_long' => array(
61
+ ),
62
+ );
63
+
64
+ /**
65
+ * @return array
66
+ */
67
+ public function getResourceModels()
68
+ {
69
+ // @todo: Add an event to allow for third party extensions to extend this array
70
+ return $this->resourceModels;
71
+ }
72
+
73
+ /**
74
+ * @param $resourceModels
75
+ *
76
+ * @return array
77
+ */
78
+ public function getDataFromModels($resourceModels)
79
+ {
80
+ $data = array();
81
+
82
+ foreach ($resourceModels as $resourceModel) {
83
+ $modelMetrics = $this->getDataFromModel($resourceModel);
84
+ $data = array_merge($data, array($resourceModel => $modelMetrics));
85
+ }
86
+
87
+ return $data;
88
+ }
89
+
90
+ /**
91
+ * @param $resourceModel
92
+ *
93
+ * @return array|mixed
94
+ */
95
+ public function getDataFromModel($resourceModel)
96
+ {
97
+ $modelName = 'mpi/resource_' . $resourceModel;
98
+ $model = Mage::getModel($modelName);
99
+
100
+ if (empty($model) || is_object($model) == false) {
101
+ $this->log('Invalid resource-model %s', $modelName);
102
+ return array();
103
+ }
104
+
105
+ if (method_exists($model, 'getData') == false) {
106
+ $this->log('Resource-model %s has no getData() method', $modelName);
107
+ return array();
108
+ }
109
+
110
+ $modelMetrics = $model->getData();
111
+
112
+ if (is_array($modelMetrics) == false) {
113
+ return array();
114
+ }
115
+
116
+ foreach($modelMetrics as $modelMetricIndex => $modelMetric) {
117
+ if (is_object($modelMetric)) {
118
+ /** @var Yireo_Mpi_Model_Metric $modelMetric */
119
+ $modelMetric = $modelMetric->export();
120
+ }
121
+
122
+ $modelMetrics[$modelMetricIndex] = $modelMetric;
123
+ }
124
+
125
+ return $modelMetrics;
126
+ }
127
+
128
+ /**
129
+ * @param array $selectGroups
130
+ *
131
+ * @return array
132
+ */
133
+ public function getDataFromGroups($selectGroups = array())
134
+ {
135
+ $data = array();
136
+
137
+ foreach ($this->resourceModels as $resourceModelGroupName => $resourceModelGroup) {
138
+
139
+ if(!empty($selectGroups) && in_array($resourceModelGroupName, $selectGroups) == false) {
140
+ continue;
141
+ }
142
+
143
+ $modelData = $this->getDataFromModels($resourceModelGroup);
144
+ $data = array_merge($data, $modelData);
145
+ }
146
+
147
+ return $data;
148
+ }
149
+
150
+ /**
151
+ * Shortcut for logging
152
+ *
153
+ * @param $string
154
+ * @param null $variable1
155
+ * @param null $variable2
156
+ */
157
+ public function log($string, $variable1 = null, $variable2 = null)
158
+ {
159
+ /** @var $helper Yireo_Mpi_Helper_Data */
160
+ $helper = Mage::helper('mpi');
161
+ $helper->log($string, $variable1, $variable2);
162
+ }
163
+ }
app/code/community/Yireo/Mpi/Model/Resource/Abstract.php ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Abstract class for checks
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Logging level: Notice
18
+ */
19
+ const MPI_LOGLEVEL_NOTICE = 'notice';
20
+
21
+ /**
22
+ * Logging level: Warning
23
+ */
24
+ const MPI_LOGLEVEL_WARNING = 'warning';
25
+
26
+ /**
27
+ * Logging level: Error
28
+ */
29
+ const MPI_LOGLEVEL_ERROR = 'error';
30
+
31
+ /**
32
+ * Collected metrics
33
+ */
34
+ protected $metrics = array();
35
+
36
+ /**
37
+ * @param $name
38
+ * @param $callback
39
+ * @param null $type
40
+ *
41
+ * @return false|Mage_Core_Model_Abstract
42
+ */
43
+ public function getMetricFromCallback($name, $callback, $type = null)
44
+ {
45
+ $startTimer = microtime(true);
46
+
47
+ $value = null;
48
+ if (method_exists($this, $callback)) {
49
+ $value = call_user_func(array($this, $callback));
50
+ }
51
+
52
+ $endTimer = microtime(true);
53
+
54
+ $metric = $this->getMetric($name, $value, $type);
55
+ $metric->setStartTime($startTimer);
56
+ $metric->setEndTime($endTimer);
57
+
58
+ return $metric;
59
+ }
60
+
61
+ /**
62
+ * @param $name
63
+ * @param $value
64
+ * @param null $type
65
+ *
66
+ * @return null
67
+ */
68
+ public function addMetric($name, $value, $type = null)
69
+ {
70
+ $this->metrics[] = $this->getMetric($name, $value, $type);
71
+ }
72
+
73
+ /**
74
+ * @param $name
75
+ * @param $value
76
+ * @param null $type
77
+ *
78
+ * @return false|Mage_Core_Model_Abstract
79
+ */
80
+ public function getMetric($name, $value, $type = null)
81
+ {
82
+ $className = get_class($this);
83
+ preg_match('/(.*)_Model_Resource_(.*)/', $className, $classMatch);
84
+ $prefix = strtolower($classMatch[1]) . '/' . strtolower($classMatch[2]);
85
+ $name = $prefix.'/'.$name;
86
+
87
+ return $this->getGlobalMetric($name, $value, $type);
88
+ }
89
+
90
+ /**
91
+ * @param $name
92
+ * @param $value
93
+ * @param null $type
94
+ *
95
+ * @return false|Mage_Core_Model_Abstract
96
+ */
97
+ public function getGlobalMetric($name, $value, $type = null)
98
+ {
99
+ /** @var Yireo_Mpi_Model_Metric $metric */
100
+ $metric = Mage::getModel('mpi/metric');
101
+
102
+ $metric->setName($name);
103
+ $metric->setValue($value);
104
+
105
+ if (!empty($type)) {
106
+ $metric->setType($type);
107
+ }
108
+
109
+ return $metric;
110
+ }
111
+
112
+ /**
113
+ * @param $name
114
+ * @param null $filters
115
+ *
116
+ * @return int
117
+ */
118
+ protected function countCollection($name, $filters = null)
119
+ {
120
+ $collection = Mage::getModel($name)->getCollection();
121
+
122
+ if(is_array($filters) && !empty($filters)) {
123
+ foreach($filters as $filterName => $filterValue) {
124
+ if (empty($filterName)) {
125
+ continue;
126
+ }
127
+ $collection->addAttributeToFilter($filterName, $filterValue);
128
+ }
129
+ }
130
+
131
+ return $collection->getSize();
132
+ }
133
+
134
+ /**
135
+ * @param $dir
136
+ *
137
+ * @return int
138
+ */
139
+ public function countFilesInDir($dir)
140
+ {
141
+ $dir = MAGENTO_ROOT.'/'.$dir;
142
+
143
+ return count(glob($dir.'/*', GLOB_NOSORT));
144
+ }
145
+
146
+ /**
147
+ * @param $file
148
+ *
149
+ * @return int
150
+ */
151
+ public function getFileSize($file)
152
+ {
153
+ $file = MAGENTO_ROOT.'/'.$file;
154
+
155
+ if (file_exists($file) == false) {
156
+ return 0;
157
+ }
158
+
159
+ return filesize($file);
160
+ }
161
+
162
+ /**
163
+ * @param $string
164
+ * @param null $variable1
165
+ * @param null $variable2
166
+ */
167
+ public function log($string, $variable1 = null, $variable2 = null)
168
+ {
169
+ Mage::helper('mpi')->log($string, $variable1, $variable2);
170
+ }
171
+ }
app/code/community/Yireo/Mpi/Model/Resource/Core/Attribute.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ *
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Core_Attribute extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ protected $attributeCountAll = 0;
17
+
18
+ protected $attributeCountLayNav = 0;
19
+
20
+ protected $attributeCountSearch = 0;
21
+
22
+ /**
23
+ * Return all data of this class
24
+ *
25
+ * @return array
26
+ */
27
+ public function getData()
28
+ {
29
+ $this->getAttributeStatistics();
30
+
31
+ $this->addMetric('catalog_product_attributes', $this->attributeCountAll);
32
+ $this->addMetric('catalog_product_attributes_laynav', $this->attributeCountLayNav);
33
+ $this->addMetric('catalog_product_attributes_search', $this->attributeCountSearch);
34
+
35
+ return $this->metrics;
36
+ }
37
+
38
+ /**
39
+ *
40
+ */
41
+ protected function getAttributeStatistics()
42
+ {
43
+ $attributes = $this->getAttributes();
44
+
45
+ foreach($attributes as $attribute) {
46
+ $this->attributeCountAll++;
47
+
48
+ if($attribute->getData('is_filterable') == 1) {
49
+ $this->attributeCountLayNav++;
50
+ }
51
+
52
+ if($attribute->getData('is_searchable') == 1 && $attribute->getData('is_filterable_in_search') == 1) {
53
+ $this->attributeCountSearch++;
54
+ }
55
+ }
56
+ }
57
+
58
+ /**
59
+ * @return mixed
60
+ */
61
+ protected function getAttributes()
62
+ {
63
+ $attributes = Mage::getSingleton('eav/config')->getEntityType(Mage_Catalog_Model_Product::ENTITY)->getAttributeCollection();
64
+ return $attributes;
65
+ }
66
+ }
app/code/community/Yireo/Mpi/Model/Resource/Core/Cache.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Get caching information
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Core_Cache extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all caches of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ $cacheTypes = $this->getCacheTypes();
24
+ foreach($cacheTypes as $cacheName => $cacheType) {
25
+ $this->addMetric('type/'.$cacheName.'/type', $cacheType->getData('cache_type'));
26
+ $this->addMetric('type/'.$cacheName.'/status', (bool)$cacheType->getData('status'));
27
+ $this->addMetric('type/'.$cacheName.'/tags', $cacheType->getData('tags'));
28
+ }
29
+
30
+ $this->addMetric('caching_backend', $this->getCachingBackend());
31
+
32
+ return $this->metrics;
33
+ }
34
+
35
+ public function getCacheTypes()
36
+ {
37
+ $cacheTypes = Mage::app()->getCacheInstance()->getTypes();
38
+ return $cacheTypes;
39
+ }
40
+
41
+ public function getCachingBackend()
42
+ {
43
+ return (string)Mage::getConfig()->getNode('global/cache/backend');
44
+ }
45
+ }
app/code/community/Yireo/Mpi/Model/Resource/Core/Catalog.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ *
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Core_Catalog extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ $this->addMetric('product_count', $this->countCollection('catalog/product'));
24
+ $this->addMetric('product_inactive_count', $this->countCollection('catalog/product', array(
25
+ 'status' => Mage_Catalog_Model_Product_Status::STATUS_DISABLED)));
26
+ $this->addMetric('category_count', $this->countCollection('catalog/category'));
27
+
28
+ return $this->metrics;
29
+ }
30
+ }
app/code/community/Yireo/Mpi/Model/Resource/Core/Compiler.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Get information on the Magento Compiler
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Core_Compiler extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ return array(
24
+ $this->getMetricFromCallback('enabled', 'isEnabled'),
25
+ );
26
+ }
27
+
28
+ public function isEnabled()
29
+ {
30
+ // Check for compiler
31
+ $compilerConfigFile = BP.'/includes/config.php';
32
+
33
+ if (file_exists($compilerConfigFile) && is_readable($compilerConfigFile)) {
34
+ include_once $compilerConfigFile;
35
+ if(defined('COMPILER_INCLUDE_PATH')) {
36
+ return true;
37
+ }
38
+ }
39
+
40
+ return false;
41
+ }
42
+ }
app/code/community/Yireo/Mpi/Model/Resource/Core/Configuration.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Get core versioning
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Core_Configuration extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ $result = array();
24
+
25
+ foreach ($this->getPaths() as $path => $variableType) {
26
+ $result[] = $this->getMetric($path, Mage::getStoreConfig($path), $variableType);
27
+ }
28
+
29
+ foreach ($this->getNodes() as $node => $variableType) {
30
+ $result[] = $this->getMetric($node, (string) Mage::getConfig()->getNode($node), $variableType);
31
+ }
32
+
33
+ return $result;
34
+ }
35
+
36
+ /**
37
+ * @return array
38
+ */
39
+ public function getNodes()
40
+ {
41
+ return array(
42
+ 'global/disable_local_modules' => 'bool',
43
+ 'global/skip_process_modules_updates' => 'bool',
44
+ 'admin/routers/adminhtml/args/frontName' => 'string',
45
+ );
46
+ }
47
+
48
+ /**
49
+ * @return array
50
+ */
51
+ public function getPaths()
52
+ {
53
+ return array(
54
+ 'catalog/frontend/flat_catalog_category' => 'bool',
55
+ 'catalog/frontend/flat_catalog_product' => 'bool',
56
+ 'catalog/search/use_layered_navigation_count' => 'int',
57
+ 'admin/url/use_custom' => 'bool',
58
+ 'system/media_storage_configuration/media_storage' => 'bool',
59
+ 'system/external_page_cache/enabled' => 'bool',
60
+ 'dev/debug/profiler' => 'bool',
61
+ 'dev/translate_inline/active' => 'bool',
62
+ 'dev/log/active' => 'bool',
63
+ 'dev/js/merge_files' => 'bool',
64
+ 'dev/css/merge_css_files' => 'bool',
65
+ );
66
+ }
67
+ }
app/code/community/Yireo/Mpi/Model/Resource/Core/Customer.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ *
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Core_Customer extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ $this->addMetric('customer_count', $this->countCollection('customer/customer'));
24
+
25
+ return $this->metrics;
26
+ }
27
+ }
app/code/community/Yireo/Mpi/Model/Resource/Core/Indexer.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Get information on the Magento indexer
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Core_Indexer extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ $result = array();
24
+
25
+ $indices = $this->getIndexes();
26
+ foreach($indices as $index) {
27
+ $indexCode = $index->getData('indexer_code');
28
+ $result[] = $this->getMetric('index/'.$indexCode.'/label', $index->getIndexer()->getName());
29
+ $result[] = $this->getMetric('index/'.$indexCode.'/status', $index->getData('status'));
30
+ $result[] = $this->getMetric('index/'.$indexCode.'/mode', $index->getData('mode'));
31
+ $result[] = $this->getMetric('index/'.$indexCode.'/date', strtotime($index->getData('started_at')), 'timestamp');
32
+ }
33
+
34
+ return $result;
35
+ }
36
+
37
+ public function getIndexes()
38
+ {
39
+ return Mage::getModel('index/process')->getCollection();
40
+ }
41
+ }
app/code/community/Yireo/Mpi/Model/Resource/Core/Module.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Get core versioning
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Core_Module extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ protected $modulesCount = 0;
17
+
18
+ protected $modulesCountActive = 0;
19
+
20
+ protected $modulesCountActiveNoncore = 0;
21
+
22
+ /**
23
+ * Return all data of this class
24
+ *
25
+ * @return array
26
+ */
27
+ public function getData()
28
+ {
29
+ $modules = $this->getModules();
30
+
31
+ $this->addMetric('extensions', $modules, 'array');
32
+ $this->addMetric('extensions_count_total', $this->modulesCount);
33
+ $this->addMetric('extensions_count_active', $this->modulesCountActive);
34
+ $this->addMetric('extensions_count_active_3po', $this->modulesCountActiveNoncore);
35
+
36
+ return $this->metrics;
37
+ }
38
+
39
+ /**
40
+ * @return array
41
+ */
42
+ public function getModules()
43
+ {
44
+ $modules = Mage::getConfig()->getNode('modules')->children();
45
+
46
+ $modulesResult = array();
47
+
48
+ foreach ($modules as $moduleName => $module) {
49
+
50
+ $this->modulesCount++;
51
+ $module = (array)$module;
52
+ $module['name'] = $moduleName;
53
+
54
+ if (empty($module['codePool'])) {
55
+ $module['codePool'] = 'unknown';
56
+ }
57
+
58
+ if ($module['active'] == true) {
59
+ $this->modulesCountActive++;
60
+ if ($module['codePool'] != 'core') {
61
+ $this->modulesCountActiveNoncore++;
62
+ }
63
+ }
64
+
65
+ if (isset($module['depends'])) {
66
+ unset($module['depends']);
67
+ }
68
+
69
+ $modulesResult[] = $module;
70
+ }
71
+
72
+ return $modulesResult;
73
+ }
74
+ }
app/code/community/Yireo/Mpi/Model/Resource/Core/Rules.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ *
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Core_Rules extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ return array(
24
+ $this->getMetric('catalogrule_count', $this->countCollection('catalogrule/rule')),
25
+ $this->getMetric('salesrule_count', $this->countCollection('salesrule/rule')),
26
+ );
27
+ }
28
+ }
app/code/community/Yireo/Mpi/Model/Resource/Core/Sales.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ *
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Core_Sales extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ return array(
24
+ $this->getMetric('order_count', $this->countCollection('sales/order')),
25
+ );
26
+ }
27
+ }
app/code/community/Yireo/Mpi/Model/Resource/Core/Session.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Get caching information
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Core_Session extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ $result = array();
24
+
25
+ $result[] = $this->getMetric('session_save', $this->getSessionSave());
26
+
27
+ return $result;
28
+ }
29
+
30
+ public function getSessionSave()
31
+ {
32
+ return (string)Mage::getConfig()->getNode('global/session_save');
33
+ }
34
+ }
app/code/community/Yireo/Mpi/Model/Resource/Core/Store.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ *
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Core_Store extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ return array(
24
+ $this->getMetric('store_count', $this->countCollection('core/store')),
25
+ $this->getMetric('storegroup_count', $this->countCollection('core/store_group')),
26
+ $this->getMetric('website_count', $this->countCollection('core/website')),
27
+ );
28
+ }
29
+ }
app/code/community/Yireo/Mpi/Model/Resource/Core/Version.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Get core versioning
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Core_Version extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ return array(
24
+ $this->getMetric('version', $this->getVersion()),
25
+ $this->getMetric('edition', $this->getEdition()),
26
+ );
27
+ }
28
+
29
+ public function getVersion()
30
+ {
31
+ if(method_exists('Mage', 'getVersion')) {
32
+ return Mage::getVersion();
33
+ }
34
+
35
+ return 'unknown';
36
+ }
37
+
38
+ public function getEdition()
39
+ {
40
+ if(method_exists('Mage', 'getEdition')) {
41
+ return Mage::getEdition();
42
+ }
43
+
44
+ return 'unknown';
45
+ }
46
+ }
app/code/community/Yireo/Mpi/Model/Resource/Database/Abstract.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ *
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Database_Abstract extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * @return mixed
18
+ */
19
+ protected function getDbConnection()
20
+ {
21
+ $db = Mage::getSingleton('core/resource')->getConnection('core_read');
22
+ return $db;
23
+ }
24
+ }
app/code/community/Yireo/Mpi/Model/Resource/Database/Basics.php ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Get core versioning
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Database_Basics extends Yireo_Mpi_Model_Resource_Database_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ $result = array();
24
+
25
+ $result[] = $this->getMetric('version', $this->getDatabaseVersion());
26
+ $result[] = $this->getMetric('host', $this->getDatabaseHost());
27
+ $result[] = $this->getMetric('database', $this->getDatabaseName());
28
+ $result[] = $this->getMetric('database_count', $this->countDatabases());
29
+ $result[] = $this->getMetric('table_count', $this->countTables());
30
+ $result[] = $this->getMetric('status', $this->getStatus(), 'array');
31
+
32
+ $tableStatuses = $this->getTableStatus();
33
+ foreach($tableStatuses as $tableStatus) {
34
+ $tableName = array_shift($tableStatus);
35
+ $result[] = $this->getMetric('table_status/'.$tableName, $tableStatus, 'array');
36
+ }
37
+
38
+ return $result;
39
+ }
40
+
41
+ /**
42
+ * @return string
43
+ */
44
+ protected function getDatabaseVersion()
45
+ {
46
+ $db = $this->getDbConnection();
47
+ return (string) $db->getConnection()->getAttribute(PDO::ATTR_SERVER_VERSION);
48
+ }
49
+
50
+ /**
51
+ * @return Mage_Core_Model_Config_Element
52
+ */
53
+ protected function getDatabaseHost()
54
+ {
55
+ return (string) Mage::getConfig()->getNode('global/resources/default_setup/connection/host');
56
+ }
57
+
58
+ /**
59
+ * @return Mage_Core_Model_Config_Element
60
+ */
61
+ protected function getDatabaseName()
62
+ {
63
+ return (string) Mage::getConfig()->getNode('global/resources/default_setup/connection/dbname');
64
+ }
65
+
66
+ /**
67
+ * @return int
68
+ */
69
+ protected function countDatabases()
70
+ {
71
+ $db = $this->getDbConnection();
72
+ $query = 'SHOW DATABASES';
73
+ $result = $db->fetchAll($query);
74
+ return count($result) - 1;
75
+ }
76
+
77
+ /**
78
+ * @return int
79
+ */
80
+ protected function countTables()
81
+ {
82
+ $db = $this->getDbConnection();
83
+ $query = 'SHOW TABLES';
84
+ $result = $db->fetchAll($query);
85
+ return count($result);
86
+ }
87
+
88
+ /**
89
+ * @return mixed
90
+ */
91
+ protected function getTableStatus()
92
+ {
93
+ $db = $this->getDbConnection();
94
+ $query = 'SHOW TABLE STATUS';
95
+ $result = $db->fetchAll($query);
96
+ return $result;
97
+ }
98
+
99
+ /**
100
+ * @return mixed
101
+ */
102
+ protected function getStatus()
103
+ {
104
+ $db = $this->getDbConnection();
105
+ $query = 'SHOW STATUS';
106
+ $result = $db->fetchAll($query);
107
+ return $result;
108
+ }
109
+ }
app/code/community/Yireo/Mpi/Model/Resource/Database/Status.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Get core versioning
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Database_Status extends Yireo_Mpi_Model_Resource_Database_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ $db = $this->getDbConnection();
24
+ $variables = $this->getVariables();
25
+
26
+ $query = 'SHOW STATUS';
27
+ $rows = $db->fetchAll($query);
28
+ foreach ($rows as $row) {
29
+ $rowName = strtolower(array_shift($row));
30
+ $rowValue = array_shift($row);
31
+
32
+ if (array_key_exists($rowName, $variables)) {
33
+ $variableType = $variables[$rowName];
34
+ $this->addMetric($rowName, $rowValue, $variableType);
35
+ }
36
+ }
37
+
38
+ return $this->metrics;
39
+ }
40
+
41
+ protected function getVariables()
42
+ {
43
+ return array(
44
+ 'connections' => 'int',
45
+ 'innodb_page_size' => 'bytes',
46
+ 'innodb_buffer_pool_pages_total' => 'int',
47
+ 'innodb_buffer_pool_pages_misc' => 'int',
48
+ 'innodb_buffer_pool_pages_free' => 'int',
49
+ 'innodb_buffer_pool_pages_data' => 'int',
50
+ 'innodb_buffer_pool_pages_flushed' => 'int',
51
+ 'innodb_buffer_pool_pages_dirty' => 'int',
52
+ 'open_tables' => 'int',
53
+ 'open_table_definitions' => 'int',
54
+ 'qcache_free_memory' => 'bytes',
55
+ 'slow_queries' => 'int',
56
+ 'uptime' => 'seconds',
57
+ );
58
+ }
59
+ }
app/code/community/Yireo/Mpi/Model/Resource/Database/Table.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Get core versioning
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Database_Table extends Yireo_Mpi_Model_Resource_Database_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ $result = array();
24
+
25
+ $tables = $this->getTableNames();
26
+ foreach($tables as $table) {
27
+ $result[] = $this->getMetric($table . '/count', $this->getTableSize($table));
28
+ }
29
+
30
+ return $result;
31
+ }
32
+
33
+ /**
34
+ * @param $table
35
+ *
36
+ * @return mixed
37
+ */
38
+ protected function getTableSize($table)
39
+ {
40
+ $db = $this->getDbConnection();
41
+ $table_name = Mage::getSingleton('core/resource')->getTableName($table);
42
+
43
+ $query = 'SELECT COUNT(*) FROM `'.$table_name.'`';
44
+ $result = $db->fetchOne($query);
45
+
46
+ return $result;
47
+ }
48
+
49
+ /**
50
+ * @return array
51
+ */
52
+ protected function getTableNames()
53
+ {
54
+ return array(
55
+ 'core_url_rewrite',
56
+ 'log_customer',
57
+ 'log_quote',
58
+ 'log_summary',
59
+ 'log_summary_type',
60
+ 'log_url',
61
+ 'log_url_info',
62
+ 'log_visitor',
63
+ 'log_visitor_info',
64
+ 'log_visitor_online',
65
+ 'report_viewed_product_index',
66
+ 'report_compared_product_index',
67
+ 'report_event',
68
+ 'catalog_compare_item',
69
+ 'dataflow_batch_export',
70
+ 'dataflow_batch_import',
71
+ );
72
+ }
73
+ }
app/code/community/Yireo/Mpi/Model/Resource/Database/Variable.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Get core versioning
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Database_Variable extends Yireo_Mpi_Model_Resource_Database_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ $db = $this->getDbConnection();
24
+ $variables = $this->getVariables();
25
+
26
+ $query = 'SHOW VARIABLES';
27
+ $rows = $db->fetchAll($query);
28
+ foreach ($rows as $row) {
29
+ $rowName = strtolower(array_shift($row));
30
+ $rowValue = array_shift($row);
31
+
32
+ if (array_key_exists($rowName, $variables)) {
33
+ $variableType = $variables[$rowName];
34
+ $this->addMetric($rowName, $rowValue, $variableType);
35
+ }
36
+ }
37
+
38
+ return $this->metrics;
39
+ }
40
+
41
+ protected function getVariables()
42
+ {
43
+ return array(
44
+ 'read_buffer_size' => 'bytes',
45
+ 'read_rnd_buffer_size' => 'bytes',
46
+ 'join_buffer_size' => 'bytes',
47
+ 'key_buffer_size' => 'bytes',
48
+ 'sort_buffer_size' => 'bytes',
49
+ 'query_cache_limit' => 'bytes',
50
+ 'query_cache_min_res_unit' => 'bytes',
51
+ 'query_cache_size' => 'bytes',
52
+ 'query_cache_type' => 'int',
53
+ 'query_cache_wlock_invalidate' => 'bool',
54
+ 'have_query_cache' => 'bool',
55
+ 'table_open_cache' => 'int',
56
+ 'table_cache' => 'int',
57
+ 'table_definition_cache' => 'int',
58
+ 'max_heap_table_size' => 'bytes',
59
+ 'thread_cache_size' => 'bytes',
60
+ 'thread_stack' => 'bytes',
61
+ 'binlog_cache_size' => 'bytes',
62
+ 'tmp_table_size' => 'bytes',
63
+ 'myisam_sort_buffer_size' => 'bytes',
64
+ 'innodb_buffer_pool_size' => 'bytes',
65
+ 'innodb_additional_mem_pool_size' => 'bytes',
66
+ 'innodb_log_file_size' => 'bytes',
67
+ 'innodb_thread_concurrency' => 'int',
68
+ 'innodb_thread_sleep_delay' => 'int',
69
+ 'innodb_flush_log_at_trx_commit' => 'int',
70
+ 'innodb_flush_method' => 'string',
71
+ 'innodb_log_file_size' => 'bytes',
72
+ 'innodb_lock_wait_timeout' => 'seconds',
73
+ 'long_query_time' => 'seconds',
74
+ 'log_slow_queries' => 'string',
75
+ 'slow_query_log' => 'bool',
76
+ 'slow_query_log_file' => 'string',
77
+ 'max_connections' => 'int',
78
+ 'connect_timeout' => 'seconds',
79
+ 'performance_schema' => 'bool',
80
+ );
81
+ }
82
+ }
app/code/community/Yireo/Mpi/Model/Resource/Environment/Basics.php ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Get environment basics
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Environment_Basics extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ return array(
24
+ $this->getMetricFromCallback('ip', 'getIpAddress'),
25
+ $this->getMetricFromCallback('internal_ip', 'getInternalIpAddress'),
26
+ $this->getMetricFromCallback('keep_alive', 'getKeepAlive'),
27
+ $this->getMetricFromCallback('gzip', 'getGzip'),
28
+ $this->getMetricFromCallback('deflate', 'getDeflate'),
29
+ $this->getMetricFromCallback('dns_time', 'getDnsTime', 'seconds'),
30
+ $this->getMetric('timezone:php', date_default_timezone_get()),
31
+ $this->getMetric('timezone:ini', ini_get('date.timezone')),
32
+ );
33
+ }
34
+
35
+ public function getIpAddress()
36
+ {
37
+ return $_SERVER['SERVER_ADDR'];
38
+ }
39
+
40
+ public function getInternalIpAddress()
41
+ {
42
+ return gethostbyname($_SERVER['HTTP_HOST']);
43
+ }
44
+
45
+ public function getKeepAlive()
46
+ {
47
+ return ($_SERVER['HTTP_CONNECTION'] == 'keep-alive');
48
+ }
49
+
50
+ public function getGzip()
51
+ {
52
+ return (bool) stristr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip');
53
+ }
54
+
55
+ public function getDeflate()
56
+ {
57
+ return (bool) stristr($_SERVER['HTTP_ACCEPT_ENCODING'], 'deflate');
58
+ }
59
+
60
+ public function getDnsTime()
61
+ {
62
+ $host = 'www.magentocommerce.com';
63
+ $dnsTimer = 0;
64
+ for($i = 0; $i < 4; $i++) {
65
+ $startTimer = microtime(true);
66
+ gethostbyname($host);
67
+ $endTimer = microtime(true);
68
+ $dnsTimer = $dnsTimer + (float)$endTimer - $startTimer;
69
+ }
70
+
71
+ return (float) round($dnsTimer / 4, 4);
72
+ }
73
+ }
app/code/community/Yireo/Mpi/Model/Resource/Environment/Log.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ *
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Environment_Log extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ return array(
24
+ $this->getMetric('system_log_size', $this->getFileSize('var/log/system.log')),
25
+ $this->getMetric('exception_log_size', $this->getFileSize('var/log/exception.log')),
26
+ );
27
+ }
28
+
29
+ }
app/code/community/Yireo/Mpi/Model/Resource/Environment/Report.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ *
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Environment_Report extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ return array(
24
+ $this->getMetric('count', $this->countFilesInDir('var/session')),
25
+ );
26
+ }
27
+ }
app/code/community/Yireo/Mpi/Model/Resource/Environment/Session.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ *
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Environment_Session extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ return array(
24
+ $this->getMetric('count', $this->countFilesInDir('var/session')),
25
+ );
26
+ }
27
+ }
app/code/community/Yireo/Mpi/Model/Resource/Php/Basics.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ *
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Php_Basics extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ $result = array();
24
+
25
+ $result[] = $this->getMetric('version', $this->getVersion());
26
+ $result[] = $this->getMetric('user', $this->getUser());
27
+ $result[] = $this->getMetric('os', $this->getOs());
28
+ $result[] = $this->getMetric('hostname', $this->getHostname());
29
+ $result[] = $this->getMetric('machine_type', $this->getMachineType());
30
+ $result[] = $this->getMetric('os_additional', $this->getOsAdditional());
31
+ $result[] = $this->getMetric('zend_version', $this->getZendVersion());
32
+ $result[] = $this->getMetric('resource_usage', $this->getResourceUsage(), 'array');
33
+ $result[] = $this->getMetric('memory_usage', $this->getMemoryUsage(), 'bytes');
34
+ $result[] = $this->getMetric('load_average', $this->getLoadAverage(), 'array');
35
+
36
+ return $result;
37
+ }
38
+
39
+ protected function getVersion()
40
+ {
41
+ return phpversion();
42
+ }
43
+
44
+ protected function getUser()
45
+ {
46
+ return get_current_user();
47
+ }
48
+
49
+ protected function getOs()
50
+ {
51
+ return php_uname('s') . ' ' . php_uname('r');
52
+ }
53
+
54
+ protected function getHostname()
55
+ {
56
+ return php_uname('n');
57
+ }
58
+
59
+ protected function getMachineType()
60
+ {
61
+ return php_uname('m');
62
+ }
63
+
64
+ protected function getOsAdditional()
65
+ {
66
+ return php_uname('v');
67
+ }
68
+
69
+ protected function getZendVersion()
70
+ {
71
+ return zend_version();
72
+ }
73
+
74
+ protected function getResourceUsage()
75
+ {
76
+ return getrusage();
77
+ }
78
+
79
+ protected function getMemoryUsage()
80
+ {
81
+ return memory_get_usage();
82
+ }
83
+
84
+ protected function getLoadAverage()
85
+ {
86
+ return sys_getloadavg();
87
+ }
88
+ }
app/code/community/Yireo/Mpi/Model/Resource/Php/Configuration.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Get core versioning
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Php_Configuration extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ $result = array();
24
+
25
+ if (function_exists('ini_get') == false) {
26
+ $this->log('PHP ini_get() does not exist');
27
+ return $result;
28
+ }
29
+
30
+ foreach ($this->getOptions() as $option => $variableType) {
31
+ $result[] = $this->getMetric($option, ini_get($option), $variableType);
32
+ }
33
+
34
+ return $result;
35
+ }
36
+
37
+ /**
38
+ * @return array
39
+ */
40
+ public function getOptions()
41
+ {
42
+ return array(
43
+ 'display_errors' => 'bool',
44
+ 'error_reporting' => 'int',
45
+ 'log_errors' => 'bool',
46
+ 'magic_quotes_gpc' => 'bool',
47
+ 'safe_mode' => 'bool',
48
+ 'disable_functions' => 'string',
49
+ 'realpath_cache_size' => 'bytes',
50
+ 'realpath_cache_ttl' => 'seconds',
51
+ 'expose_php' => 'bool',
52
+ 'open_basedir' => 'string',
53
+ 'max_execution_time' => 'seconds',
54
+ 'max_input_time' => 'seconds',
55
+ 'memory_limit' => 'bytes',
56
+ 'ignore_repeated_errors' => 'bool',
57
+ 'post_max_size' => 'bytes',
58
+ 'upload_max_filesize' => 'bytes',
59
+ 'default_socket_timeout' => 'seconds',
60
+ 'mysql.allow_persistent' => 'bool',
61
+ 'mysql.max_links' => 'int',
62
+ 'mysql.connect_timeout' => 'seconds',
63
+ 'session.save_path' => 'string',
64
+ 'session.save_handler' => 'string',
65
+ 'apc.enabled' => 'bool',
66
+ 'apc.shm_size' => 'bytes',
67
+ 'apc.stat' => 'bool',
68
+ 'opcache.enable' => 'bool',
69
+ 'opcache.memory_consumption' => 'bytes',
70
+ 'opcache.revalidate_freq' => 'seconds',
71
+ 'opcache.validate_timestamps' => 'bool',
72
+ 'memcache.allow_failover' => 'bool',
73
+ 'memcache.chunk_size' => 'bytes',
74
+ 'memcache.lock_timeout' => 'seconds',
75
+ 'zlib.output_compression' => 'bool',
76
+ 'zend_optimizerplus.enable' => 'bool',
77
+ 'zend_optimizerplus.memory_consumption' => 'bytes',
78
+ 'zend_optimizerplus.enable_slow_optimizations' => 'bool',
79
+ 'zend_optimizerplus.validate_timestamps' => 'bool',
80
+ 'eaccelerator.enable' => 'bool',
81
+ 'eaccelerator.optimizer' => 'bool',
82
+ 'eaccelerator.check_mtime' => 'bool',
83
+ 'eaccelerator.shm_size' => 'bytes',
84
+ 'soap.wsdl_cache_enabled' => 'bool',
85
+ );
86
+ }
87
+ }
app/code/community/Yireo/Mpi/Model/Resource/Php/Module.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ *
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Php_Module extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ $result = array();
24
+
25
+ $result[] = $this->getMetric('extensions', $this->getExtensions(), 'array');
26
+
27
+ return $result;
28
+ }
29
+
30
+ public function getExtensions()
31
+ {
32
+ $extensions = get_loaded_extensions();
33
+ return $extensions;
34
+ }
35
+ }
app/code/community/Yireo/Mpi/Model/Resource/Security/Addhandler.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Security check for the AddHandler security exploit
13
+ *
14
+ * @info http://devdocs.magento.com/guides/m1x/other/appsec-900_addhandler.html
15
+ */
16
+ class Yireo_Mpi_Model_Resource_Security_Addhandler extends Yireo_Mpi_Model_Resource_Abstract
17
+ {
18
+ /**
19
+ * Return all data of this class
20
+ *
21
+ * @return array
22
+ */
23
+ public function getData()
24
+ {
25
+ return array(
26
+ $this->getMetricFromCallback('addhandler', 'getAddHandlerCheck'),
27
+ );
28
+ }
29
+
30
+ /**
31
+ * Perform the AddHandler check
32
+ *
33
+ * @return array
34
+ */
35
+ public function getAddHandlerCheck()
36
+ {
37
+ return false;
38
+ }
39
+ }
app/code/community/Yireo/Mpi/Model/Resource/Security/Admin.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Get core versioning
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Security_Admin extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ $result = array();
24
+
25
+ $result[] = $this->getMetric('users', $this->getAdminUsers(), 'array');
26
+
27
+ return $result;
28
+ }
29
+
30
+ /**
31
+ * @return array
32
+ */
33
+ protected function getAdminUsers()
34
+ {
35
+ $adminUsers = Mage::getModel('admin/user')->getCollection();
36
+ $adminUserData = array();
37
+ foreach($adminUsers as $adminUser) {
38
+ /** @var $adminUser Mage_Admin_Model_User */
39
+ $adminUserData[] = array('username' => $adminUser->getUsername(), 'email' => $adminUser->getEmail());
40
+ }
41
+
42
+ return $adminUserData;
43
+ }
44
+ }
app/code/community/Yireo/Mpi/Model/Resource/Security/Get.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Security check for the XML-RPC security exploit
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Security_Get extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ return array(
24
+ $this->getMetric('vulnerable', $this->hasPotentialExploit()),
25
+ );
26
+ }
27
+
28
+ /**
29
+ * Perform the AddHandler check
30
+ *
31
+ * @return array
32
+ */
33
+ public function hasPotentialExploit()
34
+ {
35
+ if (version_compare(Mage::getVersion(), '1.7.0.0', '==') == false) {
36
+ return false;
37
+ }
38
+
39
+ if (is_file(MAGENTO_ROOT.'/get.php') == false) {
40
+ return false;
41
+ }
42
+
43
+ return true;
44
+ }
45
+ }
app/code/community/Yireo/Mpi/Model/Resource/Security/Shoplift.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Security check for the AddHandler security exploit
13
+ *
14
+ * @info SUPEE-5344
15
+ */
16
+ class Yireo_Mpi_Model_Resource_Security_Shoplift extends Yireo_Mpi_Model_Resource_Abstract
17
+ {
18
+ public function getData()
19
+ {
20
+ return array(
21
+ $this->getMetricFromCallback('cms_wysiwyg_post', 'checkCmsWysiwygPost'),
22
+ $this->getMetricFromCallback('patch_internally_forwarded', 'checkInternallyForwardedMethod'),
23
+ );
24
+ }
25
+
26
+ public function checkCmsWysiwygPost()
27
+ {
28
+ return false;
29
+ }
30
+
31
+ public function checkInternallyForwardedMethod()
32
+ {
33
+ $result = method_exists('Mage_Admin_Model_Observer','setInternallyForwarded');
34
+ return $result;
35
+ }
36
+ }
app/code/community/Yireo/Mpi/Model/Resource/Security/Xmlrpc.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Security check for the XML-RPC security exploit
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Security_Xmlrpc extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ return array(
24
+ $this->getMetric('vulnerable', $this->hasPotentialExploit()),
25
+ );
26
+ }
27
+
28
+ /**
29
+ * Perform the AddHandler check
30
+ *
31
+ * @return array
32
+ */
33
+ public function hasPotentialExploit()
34
+ {
35
+ if (version_compare(Mage::getVersion(), '1.7.0.1', '<') == false) {
36
+ return false;
37
+ }
38
+
39
+ if (is_file(MAGENTO_ROOT.'/app/code/core/Mage/Api/controllers/XmlrpcController.php') == false) {
40
+ return false;
41
+ }
42
+
43
+ return true;
44
+ }
45
+ }
app/code/community/Yireo/Mpi/Model/Resource/Test.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Test check
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Test extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ return array(
24
+ $this->getMetricFromCallback('test', 'getTest'),
25
+ );
26
+ }
27
+
28
+ /**
29
+ * Get simple test data
30
+ *
31
+ * @return array
32
+ */
33
+ public function getTest()
34
+ {
35
+ return 1;
36
+ }
37
+ }
app/code/community/Yireo/Mpi/Model/Resource/Webserver/Advanced.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Get core versioning
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Webserver_Advanced extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ $result = array();
24
+
25
+ $result[] = $this->getMetric('disk_free_space_varcache', $this->getFreeSpace('var/cache'));
26
+ $result[] = $this->getMetric('disk_free_space_varsession', $this->getFreeSpace('var/session'));
27
+
28
+ return $result;
29
+ }
30
+
31
+ protected function getFreeSpace($dir)
32
+ {
33
+ $dir = MAGENTO_ROOT.'/'.$dir;
34
+
35
+ if(function_exists('disk_free_space')) {
36
+ return disk_free_space($dir);
37
+ }
38
+
39
+ return -1;
40
+ }
41
+ }
app/code/community/Yireo/Mpi/Model/Resource/Webserver/Basics.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Get core versioning
13
+ */
14
+ class Yireo_Mpi_Model_Resource_Webserver_Basics extends Yireo_Mpi_Model_Resource_Abstract
15
+ {
16
+ /**
17
+ * Return all data of this class
18
+ *
19
+ * @return array
20
+ */
21
+ public function getData()
22
+ {
23
+ $result = array();
24
+
25
+ $result[] = $this->getMetric('sapi', $this->getSapi());
26
+ $result[] = $this->getMetric('apache_version', $this->getApacheVersion());
27
+ $result[] = $this->getMetric('system_memory', $this->getSystemMemory(), 'bytes');
28
+
29
+ return $result;
30
+ }
31
+
32
+ protected function getSapi()
33
+ {
34
+ return php_sapi_name();
35
+ }
36
+
37
+ protected function getApacheVersion()
38
+ {
39
+ if (function_exists('apache_get_version')) {
40
+ return apache_get_version();
41
+ }
42
+ }
43
+
44
+ protected function getSystemMemory()
45
+ {
46
+ $memory = trim(exec('cat /proc/meminfo|grep MemTotal|cut -d\: -f2'));
47
+ $memory = explode(' ', $memory);
48
+ $memory = $memory[0];
49
+
50
+ if (empty($memory)) {
51
+ return 0;
52
+ }
53
+
54
+ return $memory * 1024;
55
+ }
56
+ }
app/code/community/Yireo/Mpi/controllers/IndexController.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Mpi extension for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * MPI frontend controller
13
+ *
14
+ * @category Mpi
15
+ * @package Yireo_Mpi
16
+ */
17
+ class Yireo_Mpi_IndexController extends Mage_Core_Controller_Front_Action
18
+ {
19
+ /**
20
+ * Action to display a listing of resource models
21
+ */
22
+ public function indexAction()
23
+ {
24
+ if ($this->getHelper()->authenticate()) {
25
+ return true;
26
+ }
27
+
28
+ $resourceModels = $this->getResourceModel()->getResourceModels();
29
+
30
+ $this->sendOutput($resourceModels);
31
+ }
32
+
33
+ /**
34
+ * Action to display of listing of collected resource metrics
35
+ */
36
+ public function collectAction()
37
+ {
38
+ $this->authenticate();
39
+
40
+ $groups = Mage::helper('mpi')->getGroupsFromRequest();
41
+ $metrics = Mage::helper('mpi')->getMetricsFromRequest();
42
+
43
+ if (!empty($metrics)) {
44
+ $data = $this->getResourceModel()->getDataFromModels($metrics);
45
+ } else {
46
+ $data = $this->getResourceModel()->getDataFromGroups($groups);
47
+ }
48
+
49
+ $this->sendOutput($data);
50
+ }
51
+
52
+ /**
53
+ * Action to display a PHP info page
54
+ */
55
+ public function phpinfoAction()
56
+ {
57
+ if ($this->getHelper()->authenticate()) {
58
+ return true;
59
+ }
60
+
61
+ echo phpinfo();
62
+ exit;
63
+ }
64
+
65
+ /**
66
+ * Action to handle unroutable actions
67
+ *
68
+ * @param null $coreRoute
69
+ */
70
+ public function norouteAction($coreRoute = null)
71
+ {
72
+ $data = array('error' => 'Route "'.$coreRoute.'" not found');
73
+ $this->sendOutput($data);
74
+ }
75
+
76
+ /**
77
+ * Print output
78
+ *
79
+ * @param $data
80
+ */
81
+ protected function sendOutput($data)
82
+ {
83
+ $this->getResponse()->clearHeaders();
84
+
85
+ $format = $this->getRequest()->getParam('format');
86
+ if (empty($format)) {
87
+ $format = 'json';
88
+ }
89
+
90
+ if ($format == 'json') {
91
+ return $this->sendOutputAsJson($data);
92
+ } elseif ($format == 'dump') {
93
+ return $this->sendOutputAsDump($data);
94
+ }
95
+ }
96
+
97
+ /**
98
+ * Print output as PHP dump
99
+ *
100
+ * @param $data
101
+ */
102
+ protected function sendOutputAsDump($data)
103
+ {
104
+ $this->getResponse()->setHeader('Content-type', 'text/html', true);
105
+ ini_set('xdebug.var_display_max_children', 1024);
106
+ Zend_Debug::dump($data);
107
+ }
108
+
109
+ /**
110
+ * Print output as JSON
111
+ *
112
+ * @param $data
113
+ */
114
+ protected function sendOutputAsJson($data)
115
+ {
116
+ $this->getResponse()->setHeader('Content-type', 'application/json', true);
117
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($data));
118
+ }
119
+
120
+ /**
121
+ * Authenticate access to this API
122
+ *
123
+ * @return bool
124
+ */
125
+ protected function authenticate()
126
+ {
127
+ if ($this->getHelper()->authenticate()) {
128
+ return true;
129
+ }
130
+
131
+ $data = array('error' => 'Access denied');
132
+
133
+ $this->getResponse()->clearHeaders();
134
+ $this->getResponse()->setHeader('HTTP/1.0', '403 Forbidden', true);
135
+ $this->getResponse()->setHeader('Content-type', 'application/json', true);
136
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($data));
137
+ $this->getResponse()->sendResponse();
138
+ $this->getRequest()->setDispatched(true);
139
+ exit;
140
+ }
141
+
142
+ /**
143
+ * @return Yireo_Mpi_Helper_Data
144
+ */
145
+ protected function getHelper()
146
+ {
147
+ return Mage::helper('mpi');
148
+ }
149
+
150
+ /**
151
+ * @return Yireo_Mpi_Model_Resource
152
+ */
153
+ protected function getResourceModel()
154
+ {
155
+ return Mage::getModel('mpi/resource');
156
+ }
157
+ }
app/code/community/Yireo/Mpi/controllers/MpiController.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Mpi extension for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * MPI backend controller
13
+ *
14
+ * @category Mpi
15
+ * @package Yireo_Mpi
16
+ */
17
+ class Yireo_Mpi_MpiController extends Mage_Adminhtml_Controller_Action
18
+ {
19
+ /**
20
+ * Common method
21
+ */
22
+ protected function _initAction()
23
+ {
24
+ $this->loadLayout()
25
+ ->_setActiveMenu('system/tools/mpi')
26
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('System'), Mage::helper('adminhtml')->__('System'))
27
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Tools'), Mage::helper('adminhtml')->__('Tools'))
28
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('System Information'), Mage::helper('adminhtml')->__('Performance Insights'))
29
+ ;
30
+ return $this;
31
+ }
32
+
33
+ /**
34
+ * Overview page
35
+ */
36
+ public function indexAction()
37
+ {
38
+ $this->_initAction()
39
+ ->_addContent($this->getLayout()->createBlock('mpi/overview'))
40
+ ->renderLayout();
41
+ }
42
+
43
+ protected function _isAllowed()
44
+ {
45
+ $aclResource = 'admin/system/tools/mpi';
46
+
47
+ return Mage::getSingleton('admin/session')->isAllowed($aclResource);
48
+ }
49
+ }
app/code/community/Yireo/Mpi/etc/config.xml ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Yireo Mpi for Magento
5
+ *
6
+ * @package Yireo_Mpi
7
+ * @author Yireo (http://www.yireo.com/)
8
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
9
+ * @license Open Source License (OSL v3)
10
+ */
11
+ -->
12
+ <config>
13
+
14
+ <modules>
15
+ <Yireo_Mpi>
16
+ <version>0.2.1</version>
17
+ </Yireo_Mpi>
18
+ </modules>
19
+
20
+ <global>
21
+
22
+ <blocks>
23
+ <mpi>
24
+ <class>Yireo_Mpi_Block</class>
25
+ </mpi>
26
+ </blocks>
27
+
28
+ <helpers>
29
+ <mpi>
30
+ <class>Yireo_Mpi_Helper</class>
31
+ </mpi>
32
+ </helpers>
33
+
34
+ <models>
35
+ <mpi>
36
+ <class>Yireo_Mpi_Model</class>
37
+ </mpi>
38
+ </models>
39
+
40
+ </global>
41
+
42
+ <adminhtml>
43
+ <menu>
44
+ <system>
45
+ <children>
46
+ <tools>
47
+ <children>
48
+ <mpi translate="title" module="mpi">
49
+ <title>Yireo MPI</title>
50
+ <action>adminhtml/mpi/index</action>
51
+ </mpi>
52
+ </children>
53
+ </tools>
54
+ </children>
55
+ </system>
56
+ </menu>
57
+
58
+ <translate>
59
+ <modules>
60
+ <Yireo_Mpi>
61
+ <files>
62
+ <default>Yireo_Mpi.csv</default>
63
+ </files>
64
+ </Yireo_Mpi>
65
+ </modules>
66
+ </translate>
67
+
68
+ <acl>
69
+ <resources>
70
+ <admin>
71
+ <children>
72
+ <system>
73
+ <children>
74
+ <config>
75
+ <children>
76
+ <mpi translate="title" module="mpi">
77
+ <title>Mpi Section</title>
78
+ </mpi>
79
+ </children>
80
+ </config>
81
+ <tools>
82
+ <children>
83
+ <mpi translate="title" module="mpi">
84
+ <title>Mpi</title>
85
+ </mpi>
86
+ </children>
87
+ </tools>
88
+ </children>
89
+ </system>
90
+ </children>
91
+ </admin>
92
+ </resources>
93
+ </acl>
94
+ </adminhtml>
95
+
96
+ <admin>
97
+ <routers>
98
+ <adminhtml>
99
+ <args>
100
+ <modules>
101
+ <mpi after="Mage_Adminhtml">Yireo_Mpi</mpi>
102
+ </modules>
103
+ </args>
104
+ </adminhtml>
105
+ </routers>
106
+ </admin>
107
+
108
+ <frontend>
109
+ <routers>
110
+ <mpi>
111
+ <use>standard</use>
112
+ <args>
113
+ <module>Yireo_Mpi</module>
114
+ <frontName>mpi</frontName>
115
+ </args>
116
+ </mpi>
117
+ </routers>
118
+
119
+ <translate>
120
+ <modules>
121
+ <Yireo_Mpi>
122
+ <files>
123
+ <default>Yireo_Mpi.csv</default>
124
+ </files>
125
+ </Yireo_Mpi>
126
+ </modules>
127
+ </translate>
128
+ </frontend>
129
+
130
+ <default>
131
+ <mpi>
132
+ <settings>
133
+ <enabled>1</enabled>
134
+ </settings>
135
+ </mpi>
136
+ </default>
137
+
138
+ </config>
app/code/community/Yireo/Mpi/etc/system.xml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Yireo Mpi for Magento
5
+ *
6
+ * @package Yireo_Mpi
7
+ * @author Yireo (http://www.yireo.com/)
8
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
9
+ * @license Open Source License (OSL v3)
10
+ */
11
+ -->
12
+ <config>
13
+ <tabs>
14
+ <yireo translate="label" module="mpi">
15
+ <label>Yireo</label>
16
+ <sort_order>1000</sort_order>
17
+ </yireo>
18
+ </tabs>
19
+ <sections>
20
+ <mpi translate="label" module="mpi">
21
+ <label>Magento Performance Insights</label>
22
+ <tab>yireo</tab>
23
+ <frontend_type>text</frontend_type>
24
+ <sort_order>1</sort_order>
25
+ <show_in_default>1</show_in_default>
26
+ <show_in_website>1</show_in_website>
27
+ <show_in_store>1</show_in_store>
28
+ <groups>
29
+ <settings translate="label">
30
+ <label>Settings</label>
31
+ <frontend_type>text</frontend_type>
32
+ <sort_order>1</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ <fields>
37
+ <enabled translate="label">
38
+ <label>Enable</label>
39
+ <frontend_type>select</frontend_type>
40
+ <source_model>adminhtml/system_config_source_yesno</source_model>
41
+ <sort_order>10</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ </enabled>
46
+ <secret translate="label">
47
+ <label>API Secret</label>
48
+ <comment><![CDATA[Yireo API-secret for MPI service. Minimum of 10 chars]]></comment>
49
+ <frontend_type>text</frontend_type>
50
+ <sort_order>30</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ </secret>
55
+ </fields>
56
+ </settings>
57
+ </groups>
58
+ </mpi>
59
+ </sections>
60
+ </config>
app/design/adminhtml/default/default/template/mpi/menu.phtml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MPI extension for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright (c) 2013 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License
9
+ */
10
+ ?>
11
+ <ul id="system_config_tabs" class="tabs config-tabs">
12
+ <li>
13
+ <dl>
14
+ <dt class="label">Menu</dt>
15
+ <?php foreach($this->getMenuItems() as $item) { ?>
16
+ <dd><a href="<?php echo $item['url']; ?>" class="<?php echo $item['class']; ?>"><span><?php echo $item['title']; ?></span></a></dd>
17
+ <?php } ?>
18
+ </dl>
19
+ </li>
20
+ </ul>
app/design/adminhtml/default/default/template/mpi/overview.phtml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MPI extension for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright (c) 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License
9
+ */
10
+
11
+ $checks = $this->getChecks();
12
+ ?>
13
+
14
+ <div class="columns ">
15
+
16
+ <div class="side-col" id="page:left">
17
+ <?= $this->getMenu(); ?>
18
+ </div>
19
+
20
+ <div class="main-col" id="content">
21
+ <div class="main-col-inner">
22
+
23
+ <div class="content-header">
24
+ <table cellspacing="0">
25
+ <tr>
26
+ <td><h3 class="icon-head head-tag"><?= $this->getHeader('System Check'); ?></h3></td>
27
+ </tr>
28
+ </table>
29
+ </div>
30
+
31
+ <div class="entry-edit">
32
+ <div class="entry-edit-head">
33
+ <h4 class="icon-head head-edit-form fieldset-legend"><?= $this->__('System Check'); ?></h4>
34
+ </div>
35
+ <div class="fieldset ">
36
+ <table cellspacing="5" class="form-list">
37
+ <tbody>
38
+ <?php if(!empty($checks)) : ?>
39
+ <?php foreach ($checks as $check) : ?>
40
+ <tr>
41
+ <td width="200">
42
+ <strong><?= $check->label; ?></strong>
43
+ </td>
44
+ <td width="50">
45
+ <?= $check->result_image; ?>
46
+ </td>
47
+ <td>
48
+ <?= $check->result_text; ?>
49
+ </td>
50
+ </tr>
51
+ <?php endforeach; ?>
52
+ <?php endif; ?>
53
+ </tbody>
54
+ </table>
55
+ </div>
56
+ </div>
57
+ </div>
58
+ </div>
59
+ </div>
app/etc/modules/Yireo_Mpi.xml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Yireo Mpi-module for Magento
5
+ *
6
+ * @package Yireo_Mpi
7
+ * @author Yireo (http://www.yireo.com/)
8
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
9
+ * @license Open Software License
10
+ */
11
+ -->
12
+ <config>
13
+ <modules>
14
+ <Yireo_Mpi>
15
+ <active>true</active>
16
+ <codePool>community</codePool>
17
+ </Yireo_Mpi>
18
+ </modules>
19
+ </config>
package.xml ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?xml version="1.0"?>
2
+ <package><name>Yireo_Mpi</name><version>0.2.1</version><stability>stable</stability><license>Open Source License</license><channel>community</channel><extends></extends><summary>No summary</summary><description>No description</description><notes>No notes</notes><authors><author><name>Yireo</name><user>yireo</user><email>info@yireo.com</email></author></authors><date>2015-09-05</date><time>3:13:26</time><compatible></compatible><dependencies><required><php><min>5.4.0</min><max>6.0.0</max></php></required></dependencies><contents><target name="mage"><file name="yireo_mpi.php" hash="bb5c49394dabd9e50200b762776d70a3"/><dir name="app"><dir name="etc"><dir name="modules"><file name="Yireo_Mpi.xml" hash="2e4b22d73860a18fbe666da141734a54"/></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="mpi"><file name="menu.phtml" hash="dd51715d4ef2c04bdad992be151df793"/><file name="overview.phtml" hash="a56f2ab6086dfb77ae384ba28a4a2a12"/></dir></dir></dir></dir></dir></dir><dir name="code"><dir name="community"><dir name="Yireo"><dir name="Mpi"><dir name="etc"><file name="config.xml" hash="269c6a26ed21cb915c9e14618a0586d9"/><file name="system.xml" hash="7a00cf11f89a68142d9e37bd6ee763e4"/></dir><dir name="controllers"><file name="IndexController.php" hash="1bf39a8f1e5832bfb63993f50e0f4eb5"/><file name="MpiController.php" hash="5b9be0ce017f5249c142757c1b69cf84"/></dir><dir name="Model"><file name="Check.php" hash="7b2c6fae95ba46cb0715ae2d56f5a001"/><file name="Metric.php" hash="17fbdeb50425f8d1c3e2a010d7d17882"/><file name="Resource.php" hash="1521766bd0eb5c9b66e28d302bfa07d5"/><dir name="Resource"><file name="Abstract.php" hash="cf5677ed01658d94976cf698a820945c"/><file name="Test.php" hash="a88a9ccb6e7b083f7ee15e0ff056c9d9"/><dir name="Webserver"><file name="Advanced.php" hash="e7dd54e341f1bee882ccd45b3780c628"/><file name="Basics.php" hash="e96e9692f7a758af456ca925a42f665b"/></dir><dir name="Security"><file name="Addhandler.php" hash="7f454d7fdeedd5fbb2019d6612b40110"/><file name="Admin.php" hash="0b3a3f6ff9997d567bc745c76d9222c4"/><file name="Get.php" hash="3944bc667c4d5f577d6dc4cc9e627e58"/><file name="Shoplift.php" hash="2e9ca69f18fddbe1544459d56d838730"/><file name="Xmlrpc.php" hash="fc06937f8b03b8f00904a8ed2552a5c1"/></dir><dir name="Php"><file name="Basics.php" hash="efba5cdd43b07a85982125d944a91b17"/><file name="Configuration.php" hash="87a7e9838c5bdc36120284d86df582da"/><file name="Module.php" hash="4d97ae354f405b11458f1599f258ba43"/></dir><dir name="Environment"><file name="Basics.php" hash="beb5f1b28a015918890df493a3b2a754"/><file name="Log.php" hash="bf1decdbc7e2c825df4edf8e1adf725e"/><file name="Report.php" hash="07e3acbde52f416cd42369d470580fd4"/><file name="Session.php" hash="eb4986c14cb43b6f748b27fbb120b87a"/></dir><dir name="Database"><file name="Abstract.php" hash="c1b088a9f1c629d75aa231c25eb5cb4d"/><file name="Basics.php" hash="75f4e42388fa0f6cd312b6c0a025c82a"/><file name="Status.php" hash="892387946ab77756902f1a302e50ca1a"/><file name="Table.php" hash="60709eb8a5aeef4611ee0c14c5e88f17"/><file name="Variable.php" hash="ad2f908d77ea2de93a0b0b4aabd43ecd"/></dir><dir name="Core"><file name="Attribute.php" hash="ba202bbf05ca97793ab86b450d4de999"/><file name="Cache.php" hash="ba30d154382f46056fe9b840846c6780"/><file name="Catalog.php" hash="a6d0af0d22124a8f030d090bea85988f"/><file name="Compiler.php" hash="1c6ccbb511624d1644d249cf15ba5214"/><file name="Configuration.php" hash="33aa0351d4d2561f35192d839584c92c"/><file name="Customer.php" hash="482ad24019e1da6d54078f6b68d469b9"/><file name="Indexer.php" hash="c849098086375023d4158f87c5751796"/><file name="Module.php" hash="96314ec114c5e7031c782db8c03ae911"/><file name="Rules.php" hash="3ca63ef6b2b364ed01671db23cae7b8d"/><file name="Sales.php" hash="0ecd789810edac31a460797cc2f8e5d1"/><file name="Session.php" hash="23b193caa531a2b98f6f060f17e2cf9b"/><file name="Store.php" hash="6281137b79bc50defdd93ab119d1b288"/><file name="Version.php" hash="20801101ff1e064ad7148a09e813dfe8"/></dir></dir><dir name="Check"><file name="Abstract.php" hash="1ba6d0d8283d80f51371da3b25e94219"/><file name="Enabled.php" hash="0f21e750a87747dc5aef0c4a91119241"/><file name="EntryFile.php" hash="479ecb60fe22941b04a20fd093980f1f"/><file name="Secret.php" hash="0ad533697d9167e5a790b3ed70ee9d9b"/><file name="Version.php" hash="800cf91236295a4033c8e2618fafeefb"/></dir></dir><dir name="Helper"><file name="Data.php" hash="9b6f4db420478e84c4af528e10b02361"/></dir><dir name="Block"><file name="Menu.php" hash="615ee2d005267072ab06db70cc6f0e95"/><file name="Overview.php" hash="f2790ca6e95600d0d08e4aee63c7ce1e"/></dir></dir></dir></dir></dir></dir></target></contents></package>
yireo_mpi.php ADDED
@@ -0,0 +1,100 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Yireo Mpi for Magento
4
+ *
5
+ * @package Yireo_Mpi
6
+ * @author Yireo (http://www.yireo.com/)
7
+ * @copyright Copyright 2015 Yireo (http://www.yireo.com/)
8
+ * @license Open Source License (OSL v3)
9
+ */
10
+
11
+ /**
12
+ * Standalone PHP script for MPI
13
+ * This script should be placed in the same folder as the Magento entry-file `index.php`
14
+ */
15
+
16
+ // Display PHP errors
17
+ // ini_set('display_errors', 1);
18
+
19
+ // Initialize scan
20
+ $mpi = new YireoMpi();
21
+ $mpi->initialize();
22
+ $mpi->dispatch();
23
+
24
+ // Class YireoScan
25
+ class YireoMpi
26
+ {
27
+ /**
28
+ * Listing of metrics
29
+ */
30
+ protected $metrics = array();
31
+
32
+ public function initialize()
33
+ {
34
+ // Start timing
35
+ $startTime = microtime(true);
36
+
37
+ // Initialize Magento
38
+ if (is_file('app/Mage.php') == false) {
39
+ die('No Mage.php file found');
40
+ }
41
+
42
+ // Start-up Magento
43
+ require_once 'app/Mage.php';
44
+ Mage::app();
45
+ Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
46
+
47
+ // Measure the elapsed time
48
+ $endTime = microtime(true);
49
+ $this->metrics[] = array(
50
+ 'name' => 'yireo_mpi/init/startup',
51
+ 'value' => round($endTime - $startTime, 4),
52
+ 'type' => 'seconds',
53
+ 'start_time' => $startTime,
54
+ 'end_time' => $endTime,
55
+ );
56
+ }
57
+
58
+ public function dispatch()
59
+ {
60
+ if ($this->getHelper()->authenticate() == false) {
61
+ die('Access denied');
62
+ }
63
+
64
+ $metrics = $this->getHelper()->getMetricsFromRequest();
65
+
66
+ if (!empty($metrics)) {
67
+ $data = $this->getResourceModel()->getDataFromModels($metrics);
68
+ } else {
69
+ $groups = $this->getHelper()->getGroupsFromRequest();
70
+ $data = $this->getResourceModel()->getDataFromGroups($groups);
71
+ }
72
+
73
+ $data['init'] = $this->metrics;
74
+
75
+ header('Content-Type: application/json', true);
76
+ echo Mage::helper('core')->jsonEncode($data);
77
+ exit;
78
+ }
79
+
80
+ protected function getResponse()
81
+ {
82
+ return Mage::app()->getResponse();
83
+ }
84
+
85
+ /**
86
+ * @return Yireo_Mpi_Helper_Data
87
+ */
88
+ protected function getHelper()
89
+ {
90
+ return Mage::helper('mpi');
91
+ }
92
+
93
+ /**
94
+ * @return Yireo_Mpi_Model_Resource
95
+ */
96
+ protected function getResourceModel()
97
+ {
98
+ return Mage::getModel('mpi/resource');
99
+ }
100
+ }