[icinga-checkins] icinga.org: icingaweb2-module-director/master: ProvidedHook/Monitoring: make actions failsafe

git at icinga.org git at icinga.org
Tue Jun 28 09:41:41 CEST 2016


Module: icingaweb2-module-director
Branch: master
Commit: 7908d6934938fc5cd263f65325011204a6f26640
URL:    https://git.icinga.org/?p=icingaweb2-module-director.git;a=commit;h=7908d6934938fc5cd263f65325011204a6f26640

Author: Thomas Gelf <thomas at gelf.net>
Date:   Tue Jun 28 09:40:25 2016 +0200

ProvidedHook/Monitoring: make actions failsafe

---

 library/Director/ProvidedHook/Monitoring/HostActions.php    |   10 ++++++++++
 library/Director/ProvidedHook/Monitoring/ServiceActions.php |   10 ++++++++++
 2 files changed, 20 insertions(+)

diff --git a/library/Director/ProvidedHook/Monitoring/HostActions.php b/library/Director/ProvidedHook/Monitoring/HostActions.php
index 6afbda2..24f8d86 100644
--- a/library/Director/ProvidedHook/Monitoring/HostActions.php
+++ b/library/Director/ProvidedHook/Monitoring/HostActions.php
@@ -2,6 +2,7 @@
 
 namespace Icinga\Module\Director\ProvidedHook\Monitoring;
 
+use Exception;
 use Icinga\Application\Config;
 use Icinga\Module\Director\Db;
 use Icinga\Module\Director\Objects\IcingaHost;
@@ -13,6 +14,15 @@ class HostActions extends HostActionsHook
 {
     public function getActionsForHost(Host $host)
     {
+        try {
+            return $this->getThem($host);
+        } catch (Exception $e) {
+            return array();
+        }
+    }
+
+    protected function getThem(Host $host)
+    {
         $db = $this->db();
         if (! $db) {
             return array();
diff --git a/library/Director/ProvidedHook/Monitoring/ServiceActions.php b/library/Director/ProvidedHook/Monitoring/ServiceActions.php
index 649adbe..4c9414c 100644
--- a/library/Director/ProvidedHook/Monitoring/ServiceActions.php
+++ b/library/Director/ProvidedHook/Monitoring/ServiceActions.php
@@ -2,6 +2,7 @@
 
 namespace Icinga\Module\Director\ProvidedHook\Monitoring;
 
+use Exception;
 use Icinga\Application\Config;
 use Icinga\Module\Director\Db;
 use Icinga\Module\Director\Objects\IcingaHost;
@@ -13,6 +14,15 @@ class ServiceActions extends ServiceActionsHook
 {
     public function getActionsForService(Service $service)
     {
+        try {
+            return $this->getThem($service);
+        } catch (Exception $e) {
+            return array();
+        }
+    }
+
+    protected function getThem(Service $service)
+    {
         $db = $this->db();
         if (! $db) {
             return array();



More information about the icinga-checkins mailing list