From e7d4e5d2a6b3679c62e73fd8135aed4812213c87 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch> Date: Thu, 5 Sep 2019 11:06:10 +0200 Subject: [PATCH] added config entry when expired job is an error --- classes/cronlog-renderer.class.php | 4 ++-- classes/cronlog.class.php | 8 ++++++++ config/inc_cronlog.php.dist | 5 ++++- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/classes/cronlog-renderer.class.php b/classes/cronlog-renderer.class.php index 48f9aa3..e139dcb 100644 --- a/classes/cronlog-renderer.class.php +++ b/classes/cronlog-renderer.class.php @@ -66,7 +66,7 @@ class cronlogrenderer extends cronlog{ $aErrors=array(); $iNextRun=$aEntry['SCRIPTSTARTTIME']+((int)$aEntry['SCRIPTTTL']*60); - if($iNextRun < date("U")){ + if($iNextRun < date("U")-$this->_iExpiredJobsFailAfter){ $aErrors[]='outdated'; } if($aEntry['SCRIPTRC']>0){ @@ -101,7 +101,7 @@ class cronlogrenderer extends cronlog{ .$aEntry['SCRIPTRC'] .'</td>' . '<td class="'.($iNextRun < date("U") - ? ($iNextRun < date("U") -600 ? 'message-error' : 'message-warning') + ? ($iNextRun < date("U") - $this->_iExpiredJobsFailAfter ? 'message-error' : 'message-warning') : '' ).'">' . date("Y-m-d H:i", $iNextRun).'</td>' . '<td class="'.(count($aErrors) ? 'message-error' : '' ).'">' diff --git a/classes/cronlog.class.php b/classes/cronlog.class.php index ba6c4c0..50ffabb 100644 --- a/classes/cronlog.class.php +++ b/classes/cronlog.class.php @@ -13,6 +13,12 @@ class cronlog { protected $_sDataDir = "__APPDIR__/data"; protected $_iTtlCache = 60; // in sec + + /** + * when show an error for expired jobs (latency to execute job and sync logs) + * @var integer + */ + protected $_iExpiredJobsFailAfter = 60*30; // in sec protected $_aSkipJoblogs = array(); protected $_aServers = false; @@ -24,10 +30,12 @@ class cronlog { public function __construct() { + // read config if (file_exists(__DIR__.'/../config/inc_cronlog.php')){ $aCfgTemp=include(__DIR__.'/../config/inc_cronlog.php'); $this->_sDataDir = isset($aCfgTemp['sDatadir']) ? $aCfgTemp['sDatadir'] : $this->_sDataDir; $this->_iTtlCache = isset($aCfgTemp['iTtlCache']) ? (int)$aCfgTemp['iTtlCache'] : $this->_iTtlCache; + $this->_iExpiredJobsFailAfter = isset($aCfgTemp['iExpiredJobsFailAfter']) ? (int)$aCfgTemp['iExpiredJobsFailAfter'] : $this->_iExpiredJobsFailAfter; $this->_aSkipJoblogs = isset($aCfgTemp['aHidelogs']) && is_array($aCfgTemp['aHidelogs']) ? $aCfgTemp['aHidelogs'] : $this->_aSkipJoblogs; } $this->_sDataDir = str_replace("__APPDIR__", dirname(dirname(__FILE__)), $this->_sDataDir); diff --git a/config/inc_cronlog.php.dist b/config/inc_cronlog.php.dist index 9804246..a430a77 100644 --- a/config/inc_cronlog.php.dist +++ b/config/inc_cronlog.php.dist @@ -8,9 +8,12 @@ return array( // starting directory with all servers cronwrapper logs 'sDatadir'=>'__APPDIR__/data', - // caching time for infos in the browser + // caching time for serverinfos 'iTtlCache'=>60, + // when show an error for expired jobs (latency to execute job and sync logs) + 'iExpiredJobsFailAfter'=>60*30, + // hide these cronjob labels in the web gui 'aHidelogs'=>array( 'copycronlogs', -- GitLab