Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add memory usage column to scheduler list #273

Merged
merged 2 commits into from
Jun 15, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>