浏览代码

Synchro: keep track of the memory usage peak (SynchroLog), should the synchro be executed at once or in several steps

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@1733 a333f486-631f-4898-b8df-5754b55c2be0
romainq 13 年之前
父节点
当前提交
19d0f7f341
共有 2 个文件被更改,包括 14 次插入0 次删除
  1. 10 0
      core/kpi.class.inc.php
  2. 4 0
      synchro/synchrodatasource.class.inc.php

+ 10 - 0
core/kpi.class.inc.php

@@ -191,6 +191,16 @@ class ExecutionKPI
 			return $output[1] * 1024;
 		}
 	}
+
+	static public function memory_get_peak_usage($bRealUsage = false)
+	{
+		if (function_exists('memory_get_peak_usage'))
+		{
+			return memory_get_peak_usage($bRealUsage);
+		}
+		// PHP > 5.2.1 - this verb depends on a compilation option
+		return 0;
+	}
 }
 
 class ApplicationStartupKPI extends ExecutionKPI

+ 4 - 0
synchro/synchrodatasource.class.inc.php

@@ -1234,6 +1234,8 @@ class SynchroLog extends DBObject
 		MetaModel::Init_AddAttribute(new AttributeText("last_error", array("allowed_values"=>null, "sql"=>"last_error", "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array())));
 		MetaModel::Init_AddAttribute(new AttributeLongText("traces", array("allowed_values"=>null, "sql"=>"traces", "default_value"=>'', "is_null_allowed"=>true, "depends_on"=>array())));
 
+		MetaModel::Init_AddAttribute(new AttributeInteger("memory_usage_peak", array("allowed_values"=>null, "sql"=>"memory_usage_peak", "default_value"=>0, "is_null_allowed"=>false, "depends_on"=>array())));
+
 		// Display lists
 		MetaModel::Init_SetZListItems('details', array('sync_source_id', 'start_date', 'end_date', 'status', 'stats_nb_replica_total', 'stats_nb_replica_seen', 'stats_nb_obj_created', /*'stats_nb_replica_reconciled',*/ 'stats_nb_obj_updated', 'stats_nb_obj_obsoleted', 'stats_nb_obj_deleted',
 														'stats_nb_obj_created_errors', 'stats_nb_replica_reconciled_errors', 'stats_nb_replica_disappeared_no_action', 'stats_nb_obj_updated_errors', 'stats_nb_obj_obsoleted_errors', 'stats_nb_obj_deleted_errors', 'stats_nb_obj_new_unchanged', 'stats_nb_obj_new_updated', 'traces')); // Attributes to be displayed for the complete details
@@ -1338,6 +1340,8 @@ class SynchroLog extends DBObject
 	protected function OnUpdate()
 	{
 		$this->TraceToText();
+		$sMemPeak = max($this->Get('memory_usage_peak'), ExecutionKPI::memory_get_peak_usage());
+		$this->Set('memory_usage_peak', $sMemPeak);
 		parent::OnUpdate();
 	}
 }