Skip to content

Commit

Permalink
Merge pull request #273 from steverobbins/feature/memory-usage
Browse files Browse the repository at this point in the history
Add memory usage column to scheduler list
  • Loading branch information
fbrnc authored Jun 15, 2016
2 parents 9571577 + 9925f47 commit 124e774
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,15 @@ protected function _prepareColumns()
'frame_callback' => array($this, 'decorateMessages')
)
);
$this->addColumn(
'memory_usage',
array(
'header' => $this->__('Memory Usage'),
'index' => 'memory_usage',
'type' => 'number',
'renderer' => 'aoe_scheduler/adminhtml_scheduler_renderer_memory',
)
);
$this->addColumn(
'host',
array(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

class Aoe_Scheduler_Block_Adminhtml_Scheduler_Renderer_Memory
extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
{
public function render(Varien_Object $row)
{
$value = $row->getMemoryUsage();
if ($value) {
return number_format($row->getMemoryUsage(), 2) . ' MB';
}
return parent::render($row);
}
}
1 change: 1 addition & 0 deletions app/code/community/Aoe/Scheduler/Model/Schedule.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ public function runNow($tryLockJob = true, $forceRun = false)
}

$this->setFinishedAt(strftime('%Y-%m-%d %H:%M:%S', time()));
$this->setMemoryUsage(memory_get_usage() / pow(1024, 2)); // convert bytes to megabytes
Mage::dispatchEvent('cron_' . $this->getJobCode() . '_after', array('schedule' => $this));
Mage::dispatchEvent('cron_after', array('schedule' => $this));

Expand Down
2 changes: 1 addition & 1 deletion app/code/community/Aoe/Scheduler/etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<config>
<modules>
<Aoe_Scheduler>
<version>1.4.0</version>
<version>1.5.0</version>
</Aoe_Scheduler>
</modules>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

$installer = $this; /* @var $installer Mage_Core_Model_Resource_Setup */

$installer->startSetup();

$installer->getConnection()->addColumn($installer->getTable('cron/schedule'), 'memory_usage', array(
'type' => Varien_Db_Ddl_Table::TYPE_DECIMAL,
'length' => '12,4',
'unsigned' => true,
'nullable' => true,
'default' => null,
'comment' => 'Memory Used in MB',
));

$installer->endSetup();
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ $_helper = $this->helper('aoe_scheduler/data'); /* @var $_helper Aoe_Scheduler_H
</td>
</tr>
<?php endif; ?>
<tr>
<td class="label"><?php echo $this->__('Memory Usage') ?>:</td>
<td><?php echo number_format($_schedule->getMemoryUsage(), 2) . ' MB'; ?></td>
</tr>
</table>
</div>
</div>

0 comments on commit 124e774

Please sign in to comment.