[icinga-checkins] icinga.org: icinga-web/r1.5: Command sending errors now are more verbose and will be send

git at icinga.org git at icinga.org
Fri Aug 26 16:28:47 CEST 2011


Module: icinga-web
Branch: r1.5
Commit: e60273a6dfa1b94fc09c6a39a42dd4d0feca8736
URL:    https://git.icinga.org/?p=icinga-web.git;a=commit;h=e60273a6dfa1b94fc09c6a39a42dd4d0feca8736

Author: Jannis Moßhanner <jannis.mosshammer at netways.de>
Date:   Fri Aug 26 11:23:12 2011 +0200

Command sending errors now are more verbose and will be send 

---

 .../Commands/CommandDispatcherModel.class.php      |    5 +++++
 .../System/ViewProc/SendCommandAction.class.php    |   14 ++++++++++----
 2 files changed, 15 insertions(+), 4 deletions(-)

diff --git a/app/modules/Api/models/Commands/CommandDispatcherModel.class.php b/app/modules/Api/models/Commands/CommandDispatcherModel.class.php
index 0d1b31d..a838003 100644
--- a/app/modules/Api/models/Commands/CommandDispatcherModel.class.php
+++ b/app/modules/Api/models/Commands/CommandDispatcherModel.class.php
@@ -40,8 +40,13 @@ class Api_Commands_CommandDispatcherModel extends IcingaApiBaseModel implements
 
         try {
             $this->consoleContext->exec($cmd);
+            if($cmd->getReturnCode() != '0')
+                throw new Exception("Could not send command. Check your www-users permission for writing the command pipe.");
         } catch (Exception $e) {
+           
            $this->context->getLoggerManager()->log("Sending command failed ".$e->getMessage() );
+           throw $e;
+           
         }
     }
 
diff --git a/app/modules/Cronks/actions/System/ViewProc/SendCommandAction.class.php b/app/modules/Cronks/actions/System/ViewProc/SendCommandAction.class.php
index 469c775..5d135fd 100644
--- a/app/modules/Cronks/actions/System/ViewProc/SendCommandAction.class.php
+++ b/app/modules/Cronks/actions/System/ViewProc/SendCommandAction.class.php
@@ -43,10 +43,16 @@ class Cronks_System_ViewProc_SendCommandAction extends CronksBaseAction {
             $sender->setCommandName($command);
             $sender->setSelection($selection);
             $sender->setData($data);
-            $sender->dispatchCommands();
-
-            $this->setAttribute('ok', true);
-            $this->setAttribute('error', null);
+            try {
+                $sender->dispatchCommands();
+            
+                $this->setAttribute('ok', true);
+                $this->setAttribute('error', null);
+            } catch(Exception $e) {
+                $this->setAttribute("ok", false);
+                $this->setAttribute("error",$e->getMessage());
+            }
+            
         } else {
             $this->setAttribute('ok', false);
             $this->setAttribute('error', 'Authentification failed');





More information about the icinga-checkins mailing list