diff --git a/src/MultiFlexi/Env/Logger.php b/src/MultiFlexi/Env/Logger.php index 1190200..b669f42 100644 --- a/src/MultiFlexi/Env/Logger.php +++ b/src/MultiFlexi/Env/Logger.php @@ -34,7 +34,15 @@ public static function allKeysHandled() */ public function getEnvironment(): array { - return $this->addMetaData($this->addSelfAsSource(['EASE_LOGGER' => ['value' => 'syslog|console']])); + // If Zabbix action is enabled log only to syslog + $actions = $this->engine->runTemplate->getPostActions(); + $methods[] = 'syslog'; + if(array_key_exists('Zabbix', $actions)){ + if(!($actions['Zabbix']['success'] || $actions['Zabbix']['fail'])){ + $methods[] = 'console'; + } + } + return $this->addMetaData($this->addSelfAsSource(['EASE_LOGGER' => ['value' => implode('|', $methods)]])); } /** diff --git a/src/MultiFlexi/Job.php b/src/MultiFlexi/Job.php index d5be209..f936dd5 100644 --- a/src/MultiFlexi/Job.php +++ b/src/MultiFlexi/Job.php @@ -119,6 +119,7 @@ class Job extends Engine */ public function __construct($identifier = null, $options = []) { + $this->runTemplate = new RunTemplate(); parent::__construct($identifier, $options); if (\Ease\Shared::cfg('ZABBIX_SERVER')) { $this->zabbixSender = new ZabbixSender(\Ease\Shared::cfg('ZABBIX_SERVER')); @@ -528,6 +529,10 @@ public function takeData($data) if (is_null($this->getDataValue('app_id')) === false) { $this->application = new Application(intval($this->getDataValue('app_id'))); } + + if($this->application->getMyKey() && $this->company->getMyKey()){ + $this->runTemplate->loadFromSQL($this->runTemplate->runTemplateID($this->application->getMyKey(), $this->company->getMyKey())); + } if ($this->getDataValue('executor')) { $executorClass = '\\MultiFlexi\\Executor\\' . $this->getDataValue('executor'); diff --git a/src/MultiFlexi/RunTemplate.php b/src/MultiFlexi/RunTemplate.php index 7bebe4b..d9c5485 100644 --- a/src/MultiFlexi/RunTemplate.php +++ b/src/MultiFlexi/RunTemplate.php @@ -256,4 +256,25 @@ public static function stripToValues(array $envData) } return $env; } + + + /** + * Actions Availble with flag when performed in case of success of failure + * + * @return array + */ + public function getPostActions() + { + $actions = []; + $s = $this->getDataValue('success') ? unserialize($this->getDataValue('success')): []; + $f = $this->getDataValue('fail') ? unserialize($this->getDataValue('fail')): []; + foreach ($s as $action => $enabled){ + $actions[$action]['success'] = $enabled; + } + foreach ($s as $action => $enabled){ + $actions[$action]['fail'] = $enabled; + } + return $actions; + } + }