[icinga-checkins] icinga.org: icinga-web/jmosshammer/principal: * Scheduler time fix

git at icinga.org git at icinga.org
Mon May 3 15:13:27 CEST 2010


Module: icinga-web
Branch: jmosshammer/principal
Commit: ad463bd63dd4cd66fa861cacf7c69c064b4705ed
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=ad463bd63dd4cd66fa861cacf7c69c064b4705ed

Author: jmosshammer <jannis.mosshammer at netways.de>
Date:   Mon May  3 15:12:08 2010 +0200

* Scheduler time fix

---

 lib/icingaScheduler/CronAgaviAdapter.class.php     |    4 +-
 lib/icingaScheduler/CronJobDefinition.class.php    |    6 +++-
 lib/icingaScheduler/CronJobMetaProvider.class.php  |    2 +-
 .../CronJobParser/CronDBParser.class.php           |   23 +++++++++++++-------
 lib/icingaScheduler/res/storage.dat                |    5 +---
 5 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/lib/icingaScheduler/CronAgaviAdapter.class.php b/lib/icingaScheduler/CronAgaviAdapter.class.php
index 6d0c44a..e5a17e8 100644
--- a/lib/icingaScheduler/CronAgaviAdapter.class.php
+++ b/lib/icingaScheduler/CronAgaviAdapter.class.php
@@ -5,7 +5,7 @@ define("PATH_TO_CONFIG",dirname(__FILE__)."/../../app/config.php");
 class CronAgaviAdapter {
 	protected $agaviPath = PATH_TO_AGAVI;
 	protected $configPath = PATH_TO_CONFIG;
-	private $__isLoaded = false;
+	protected $__isLoaded = false;
 	
 	public static function getInstance() {
 		if(!self::$instance) {
@@ -15,7 +15,7 @@ class CronAgaviAdapter {
 	}
 	
 	protected function __construct() {	
-		if(!$__isLoaded)
+		if(!$this->__isLoaded)
 			$this->bootstrap();
 	}
 	
diff --git a/lib/icingaScheduler/CronJobDefinition.class.php b/lib/icingaScheduler/CronJobDefinition.class.php
index bfc76d2..8c4dad2 100644
--- a/lib/icingaScheduler/CronJobDefinition.class.php
+++ b/lib/icingaScheduler/CronJobDefinition.class.php
@@ -193,8 +193,8 @@ class CronJobDefinition {
 	protected function isInInterval($lastExec = 0) {
 		$interval = $this->getTimeIntervalAsNumber(); 
 		$now = time();
+
 		$timeGap = $now-$lastExec;
-					
 		return ($timeGap>=$interval);
 	}
 	
@@ -296,7 +296,9 @@ class CronJobDefinition {
 		$obj->setArguments($job["args"]);
 		$obj->setWeekDays($job["weekdays"]);
 		$obj->setSuspended((Boolean) $job["suspended"]);
-		$obj->setLastExec($job["lastrun"]);
+		if(isset($job["lastrun"]))
+			$obj->setLastExec($job["lastrun"]);
+		else $obj->setLastExec(0);
 		return $obj;
 	}
 }
diff --git a/lib/icingaScheduler/CronJobMetaProvider.class.php b/lib/icingaScheduler/CronJobMetaProvider.class.php
index 45c16d6..8d2d653 100644
--- a/lib/icingaScheduler/CronJobMetaProvider.class.php
+++ b/lib/icingaScheduler/CronJobMetaProvider.class.php
@@ -42,7 +42,7 @@ class CronJobMetaProvider {
 	}
 	
 	public static function getInstance() {
-		if(self::$instance == 0)
+		if(self::$instance == null)
 			self::$instance = new self();
 		return self::$instance;
 	}
diff --git a/lib/icingaScheduler/CronJobParser/CronDBParser.class.php b/lib/icingaScheduler/CronJobParser/CronDBParser.class.php
index 87ae4e3..6d2b2d4 100644
--- a/lib/icingaScheduler/CronJobParser/CronDBParser.class.php
+++ b/lib/icingaScheduler/CronJobParser/CronDBParser.class.php
@@ -60,15 +60,21 @@ class CronJobParser_CronDBParser extends CronJobParser {
 	
 	public function onExecute(CronJobDefinition $job) {
 		$index = explode("_",$job->getName());
-		$jobEntry = $this->getDbResult($index[count($index)-1]);
+
+		$jobEntry = $this->getDbResult();
+		$jobEntry = $jobEntry[$index[1]];
 		$modelName = $this->getModel();
-		$model = new $modelName();
-		foreach($jobEntry[0] as $field=>$value) {
+		$model;
+		if(!$model = Doctrine::getTable('HmSchedulerEntries')->find($jobEntry["entry_id"]))
+			$model = new $modelName();
+		
+		foreach($jobEntry as $field=>$value) {
 			$model->set($field,$value);
 		}
-	
+		
 		$model->set("lastrun",time());
-		$model->replace();
+		
+		$model->save();
 	}
 	
 	protected function reformatJobArray(array $job,$index) {
@@ -76,11 +82,12 @@ class CronJobParser_CronDBParser extends CronJobParser {
 		$interval = $job["interval_s"];
 		$weekdays = $job["days"];
 		$job["interval"] = array();
-		$job["interval"]["days"] = Math.floor($interval/(24*3600));
+		$job["interval"]["days"] = floor($interval/(24*3600));
 		$interval %= 24*3600;
-		$job["interval"]["hours"] =  Math.floor($interval/3600);
+		$job["interval"]["hours"] =  floor($interval/3600);
 		$interval %= 3600;
-		$job["interval"]["minutes"] =  Math.floor($interval/60);
+		$job["interval"]["minutes"] =  floor($interval/60);
+
 		$job["weekdays"] = array();
 		// extract days from binary representation
 		for($i=0;$i<7;$i++) {
diff --git a/lib/icingaScheduler/res/storage.dat b/lib/icingaScheduler/res/storage.dat
index bc4fe0f..55a996b 100755
--- a/lib/icingaScheduler/res/storage.dat
+++ b/lib/icingaScheduler/res/storage.dat
@@ -1,4 +1 @@
-<<<<<<< jmosshammer/principal:lib/icingaScheduler/res/storage.dat
-=======
-a:8:{s:7:"Heatmap";a:2:{s:8:"lastExec";i:1272537662;s:6:"result";b:1;}s:10:"testtest_0";a:2:{s:8:"lastExec";i:1271420282;s:6:"result";b:1;}s:10:"testtest_1";a:2:{s:8:"lastExec";i:1271420285;s:6:"result";b:1;}s:9:"default_0";a:2:{s:8:"lastExec";i:1272537662;s:6:"result";b:1;}s:9:"Default_1";a:2:{s:8:"lastExec";i:1272537664;s:6:"result";b:1;}s:10:"testtest_2";a:2:{s:8:"lastExec";i:1272383467;s:6:"result";b:1;}s:14:"gdssdgsdgsdg_3";a:2:{s:8:"lastExec";i:1272383471;s:6:"result";b:1;}s:9:"default_4";a:2:{s:8:"lastExec";i:1272383474;s:6:"result";b:1;}}
->>>>>>> local:lib/icingaScheduler/res/storage.dat
+a:3:{s:7:"Heatmap";a:2:{s:8:"lastExec";i:1272891659;s:6:"result";b:1;}s:10:"testtest_0";a:2:{s:8:"lastExec";i:1272891659;s:6:"result";b:1;}s:7:"tesat_1";a:2:{s:8:"lastExec";i:1272891661;s:6:"result";b:1;}}
\ No newline at end of file





More information about the icinga-checkins mailing list