heartbeat-extension-for-magento - Version 0.0.2

Version Notes

Added logging functionality

Download this release

Release Info

Developer Gorilla Team
Extension heartbeat-extension-for-magento
Version 0.0.2
Comparing to
See all releases


Code changes from version 0.0.1 to 0.0.2

app/code/local/Gorilla/Heartbeat/Helper/Data.php CHANGED
@@ -5,5 +5,40 @@
5
  */
6
  class Gorilla_Heartbeat_Helper_Data extends Mage_Core_Helper_Abstract
7
  {
8
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  }
5
  */
6
  class Gorilla_Heartbeat_Helper_Data extends Mage_Core_Helper_Abstract
7
  {
8
+ public function log($message, $level = null, $file = '')
9
+ {
10
+ $level = is_null($level) ? Zend_Log::DEBUG : $level;
11
+ $file = empty($file) ? 'system.log' : $file;
12
+
13
+ try {
14
+ $logDir = Mage::getBaseDir('var') . DS . 'log';
15
+ $logFile = $logDir . DS . $file;
16
+
17
+ if (!is_dir($logDir)) {
18
+ mkdir($logDir);
19
+ chmod($logDir, 0777);
20
+ }
21
+
22
+ if (!file_exists($logFile)) {
23
+ file_put_contents($logFile, '');
24
+ chmod($logFile, 0777);
25
+ }
26
+
27
+ $format = '%timestamp% %priorityName% (%priority%): %message%' . PHP_EOL;
28
+ $formatter = new Zend_Log_Formatter_Simple($format);
29
+
30
+ $writer = new Zend_Log_Writer_Stream($logFile);
31
+
32
+ $writer->setFormatter($formatter);
33
+ $loggers[$file] = new Zend_Log($writer);
34
+
35
+ if (is_array($message) || is_object($message)) {
36
+ $message = print_r($message, true);
37
+ }
38
+
39
+ $loggers[$file]->log($message, $level);
40
+ }
41
+ catch (Exception $e) {
42
+ }
43
+ }
44
  }
app/code/local/Gorilla/Heartbeat/Model/Tests/Api.php CHANGED
@@ -24,6 +24,7 @@ class Gorilla_Heartbeat_Model_Tests_Api
24
  {
25
  foreach ($this->_collectActiveUrls() as $url) {
26
  if (! $this->_request($url) && strstr($url, 'http')) {
 
27
  return false;
28
  }
29
  }
24
  {
25
  foreach ($this->_collectActiveUrls() as $url) {
26
  if (! $this->_request($url) && strstr($url, 'http')) {
27
+ Mage::helper('heartbeat')->log('Api Test Error. Can\'t access url: ' . $url, null, 'gorilla_heartbeat.log');
28
  return false;
29
  }
30
  }
app/code/local/Gorilla/Heartbeat/Model/Tests/Catalog.php CHANGED
@@ -25,7 +25,8 @@ class Gorilla_Heartbeat_Model_Tests_Catalog
25
  if (is_int(Mage::getModel('catalog/product')->getCollection()->count())) {
26
  return true;
27
  }
28
-
 
29
  return false;
30
  }
31
 
25
  if (is_int(Mage::getModel('catalog/product')->getCollection()->count())) {
26
  return true;
27
  }
28
+
29
+ Mage::helper('heartbeat')->log('Catalog Test Error. Catalog is empty.', null, 'gorilla_heartbeat.log');
30
  return false;
31
  }
32
 
app/code/local/Gorilla/Heartbeat/Model/Tests/Database.php CHANGED
@@ -32,6 +32,7 @@ class Gorilla_Heartbeat_Model_Tests_Database
32
  return true;
33
  }
34
 
 
35
  return false;
36
  }
37
 
32
  return true;
33
  }
34
 
35
+ Mage::helper('heartbeat')->log('Database Test Error. Cant read from database.', null, 'gorilla_heartbeat.log');
36
  return false;
37
  }
38
 
app/code/local/Gorilla/Heartbeat/Model/Tests/Filesystem.php CHANGED
@@ -28,11 +28,13 @@ class Gorilla_Heartbeat_Model_Tests_Filesystem
28
 
29
  if (file_exists($filename)) {
30
  if (!is_writeable($filename)) {
 
31
  return false;
32
  }
33
  }
34
 
35
  if (!is_writable($dirname)) {
 
36
  return false;
37
  }
38
 
@@ -43,7 +45,8 @@ class Gorilla_Heartbeat_Model_Tests_Filesystem
43
  if ($fileContent == 'testcontent') {
44
  return true;
45
  }
46
-
 
47
  return false;
48
  }
49
 
28
 
29
  if (file_exists($filename)) {
30
  if (!is_writeable($filename)) {
31
+ Mage::helper('heartbeat')->log('Filesystem Test Error. Files in var directory are no writable.', null, 'gorilla_heartbeat.log');
32
  return false;
33
  }
34
  }
35
 
36
  if (!is_writable($dirname)) {
37
+ Mage::helper('heartbeat')->log('Filesystem Test Error. Var directory is no writable.', null, 'gorilla_heartbeat.log');
38
  return false;
39
  }
40
 
45
  if ($fileContent == 'testcontent') {
46
  return true;
47
  }
48
+
49
+ Mage::helper('heartbeat')->log('Filesystem Test Error. Cant read or write to the test file in var directory.', null, 'gorilla_heartbeat.log');
50
  return false;
51
  }
52
 
app/code/local/Gorilla/Heartbeat/Model/Tests/Flattable.php CHANGED
@@ -54,6 +54,7 @@ class Gorilla_Heartbeat_Model_Tests_Flattable
54
  return true;
55
  }
56
 
 
57
  return false;
58
  }
59
 
54
  return true;
55
  }
56
 
57
+ Mage::helper('heartbeat')->log('Flattable Test Error. Products count in catalog doesn\'t match products count in the flat table(s).', null, 'gorilla_heartbeat.log');
58
  return false;
59
  }
60
 
app/code/local/Gorilla/Heartbeat/Model/Tests/Index.php CHANGED
@@ -29,6 +29,7 @@ class Gorilla_Heartbeat_Model_Tests_Index
29
  return true;
30
  }
31
 
 
32
  return false;
33
  }
34
 
29
  return true;
30
  }
31
 
32
+ Mage::helper('heartbeat')->log('Index Test Error. Reindex required for one or mode indexes.', null, 'gorilla_heartbeat.log');
33
  return false;
34
  }
35
 
app/code/local/Gorilla/Heartbeat/Model/Tests/Log.php CHANGED
@@ -13,7 +13,7 @@ class Gorilla_Heartbeat_Model_Tests_Log
13
  */
14
  public function isEnabled()
15
  {
16
- return true;
17
  }
18
 
19
  /**
@@ -28,7 +28,8 @@ class Gorilla_Heartbeat_Model_Tests_Log
28
  if (file_exists($logDir . DS . $logFile) && file_get_contents($logDir. DS .$logFile)) {
29
  return false;
30
  }
31
-
 
32
  return true;
33
  }
34
 
13
  */
14
  public function isEnabled()
15
  {
16
+ return false;
17
  }
18
 
19
  /**
28
  if (file_exists($logDir . DS . $logFile) && file_get_contents($logDir. DS .$logFile)) {
29
  return false;
30
  }
31
+
32
+ Mage::helper('heartbeat')->log('Log Test Error. Exception.log is not empty.', null, 'gorilla_heartbeat.log');
33
  return true;
34
  }
35
 
app/code/local/Gorilla/Heartbeat/Model/TestsCollector.php CHANGED
@@ -45,7 +45,7 @@ class Gorilla_Heartbeat_Model_TestsCollector extends Mage_Core_Model_Abstract
45
  );
46
  }
47
  } catch (Exception $e) {
48
- Mage::log('Cant load test ' . $modelName . '(' . $e->getMessage() . ')', null, 'gorilla_heartbeat.log');
49
  }
50
  }
51
 
45
  );
46
  }
47
  } catch (Exception $e) {
48
+ Mage::helper('heartbeat')->log('Cant load test ' . $modelName . '(' . $e->getMessage() . ')', null, 'gorilla_heartbeat.log');
49
  }
50
  }
51
 
package.xml CHANGED
@@ -1,21 +1,21 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>heartbeat-extension-for-magento</name>
4
- <version>0.0.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://instore.gorillagroup.com/license-agreement">Gorilla License</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>The HeartBeat module is designed to provide in-depth monitoring for your Magento site. There are two ways to monitor the status of your site &#x2013; via an XML report or through Pingdom.</summary>
10
- <description>The HeartBeat module is designed to provide in-depth monitoring for your Magento site. There are two ways to monitor the status of your site &#x2013; via an XML report or through Pingdom.&#xD;
11
  Pingdom is monitoring service that tracks all website &amp; server vitals in one convenient monitoring platform. It helps you spot performance trends, share data with others, and helps with issue resolution. Pingdom also sends users real-time updates via email, SMS (texts), Twitter, or mobile notification via iOS or Android devices.&#xD;
12
  &#xD;
13
  The HeartBeat module monitors seven components that are vital for site functionality and performance of any Magento website. These tests include: API availability, database, flat table, logs, catalog, file system, and indexes.</description>
14
- <notes>HeartBeat Released</notes>
15
  <authors><author><name>Gorilla Team</name><user>briangrady</user><email>grady@gorillagroup.com</email></author></authors>
16
- <date>2012-06-13</date>
17
- <time>17:14:09</time>
18
- <contents><target name="magelocal"><dir name="Gorilla"><dir name="Heartbeat"><dir name="Helper"><file name="Data.php" hash="5b5a72e4bb5a4ce3f1714a774dc7349f"/></dir><dir name="Model"><dir name="Tests"><file name="Api.php" hash="ea91218d8f5b212b132fdc5b86cdb967"/><file name="Catalog.php" hash="a7e19979440ecca0ae650b113227819e"/><file name="Database.php" hash="ebe95c834437faeb988cb3ca8abcaad7"/><file name="Filesystem.php" hash="bbf3f0b4b10fd2ad87640f4dea432fb8"/><file name="Flattable.php" hash="3f6facf4489b9cf590e6ec13ad806f6b"/><file name="Index.php" hash="204709bcdf381f63a3401941a1ddc495"/><file name="Log.php" hash="edc8dee0cb74f718d556ca8548da523e"/></dir><file name="TestsCollector.php" hash="b935e52bed9b908d4c2e702b37cfa42c"/><file name="TestsInterface.php" hash="5ae94e08822da721b45a9b1546a2a4b5"/></dir><dir name="controllers"><file name="IndexController.php" hash="1616d51d85d43a974ff0fdd57fa1b3cb"/></dir><dir name="etc"><file name="adminhtml.xml" hash="818551d3d7ba1962d837eff1f85f0203"/><file name="config.xml" hash="3705efcb09a4c46a0c241c9e532d16a9"/><file name="system.xml" hash="1024c468f92ce8e236e1084b73712d3a"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Gorilla_Heartbeat.xml" hash="73424503c8a3a95a747570ac3e05b4cb"/></dir></target></contents>
19
  <compatible/>
20
  <dependencies><required><php><min>5.0.0</min><max>5.4.3</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0</min><max>1.7.0</max></package></required></dependencies>
21
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>heartbeat-extension-for-magento</name>
4
+ <version>0.0.2</version>
5
  <stability>stable</stability>
6
  <license uri="http://instore.gorillagroup.com/license-agreement">Gorilla License</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>The HeartBeat module is designed to provide in-depth monitoring for your Magento site. There are two ways to monitor the status of your site &#x2013; via an XML report or through Pingdom.</summary>
10
+ <description>he HeartBeat module is designed to provide in-depth monitoring for your Magento site. There are two ways to monitor the status of your site &#x2013; via an XML report or through Pingdom.&#xD;
11
  Pingdom is monitoring service that tracks all website &amp; server vitals in one convenient monitoring platform. It helps you spot performance trends, share data with others, and helps with issue resolution. Pingdom also sends users real-time updates via email, SMS (texts), Twitter, or mobile notification via iOS or Android devices.&#xD;
12
  &#xD;
13
  The HeartBeat module monitors seven components that are vital for site functionality and performance of any Magento website. These tests include: API availability, database, flat table, logs, catalog, file system, and indexes.</description>
14
+ <notes>Added logging functionality</notes>
15
  <authors><author><name>Gorilla Team</name><user>briangrady</user><email>grady@gorillagroup.com</email></author></authors>
16
+ <date>2012-06-21</date>
17
+ <time>09:39:39</time>
18
+ <contents><target name="magelocal"><dir name="Gorilla"><dir name="Heartbeat"><dir name="Helper"><file name="Data.php" hash="e90a9d9d93dcbed32c7ab6b50ffceb03"/></dir><dir name="Model"><dir name="Tests"><file name="Api.php" hash="ed7271827fe330cb8ba0b72a5c2ef3a6"/><file name="Catalog.php" hash="19864f6e40fce8e51a1abf9815880e86"/><file name="Database.php" hash="640312670b8cea85fa0ab7f1c691022d"/><file name="Filesystem.php" hash="06f14b1c62a9f0ef8209c5b42d7a8a60"/><file name="Flattable.php" hash="92b1061ffbf7f89316def2ca704a74cc"/><file name="Index.php" hash="5685419430c3f12c4d1941614e5abfb7"/><file name="Log.php" hash="3e009825e4c618c38f8cf4cfeede531d"/></dir><file name="TestsCollector.php" hash="618e0592a30ecbdbf377ea9d3e97ba45"/><file name="TestsInterface.php" hash="5ae94e08822da721b45a9b1546a2a4b5"/></dir><dir name="controllers"><file name="IndexController.php" hash="1616d51d85d43a974ff0fdd57fa1b3cb"/></dir><dir name="etc"><file name="adminhtml.xml" hash="818551d3d7ba1962d837eff1f85f0203"/><file name="config.xml" hash="3705efcb09a4c46a0c241c9e532d16a9"/><file name="system.xml" hash="1024c468f92ce8e236e1084b73712d3a"/></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Gorilla_Heartbeat.xml" hash="73424503c8a3a95a747570ac3e05b4cb"/></dir></target></contents>
19
  <compatible/>
20
  <dependencies><required><php><min>5.0.0</min><max>5.4.3</max></php><package><name>Mage_Core_Modules</name><channel>community</channel><min>1.6.0</min><max>1.7.0</max></package></required></dependencies>
21
  </package>