Module: nagvis
Branch: master
Commit: 1a4cbebe053e777064feaaf3f9d13008c1016c95
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=1a4cbebe053e777064feaaf3f9d13008c1016c95

Author: Lars Michelsen <[email protected]>
Date:   Sun Feb  6 17:19:12 2011 +0100

Made test backend a little more restistant against non existing objects

---

 share/server/core/classes/GlobalBackendTest.php |   18 ++++++++++--------
 1 files changed, 10 insertions(+), 8 deletions(-)

diff --git a/share/server/core/classes/GlobalBackendTest.php 
b/share/server/core/classes/GlobalBackendTest.php
index b4b5189..360bb51 100644
--- a/share/server/core/classes/GlobalBackendTest.php
+++ b/share/server/core/classes/GlobalBackendTest.php
@@ -405,7 +405,8 @@ class GlobalBackendTest implements GlobalBackendInterface {
                if(count($filters) == 1 && $filters[0]['key'] == 'host_name' && 
$filters[0]['op'] == '=') {
                        foreach($objects AS $OBJS) {
                                $name = $OBJS[0]->getName();
-                               $arrReturn[$name] = $this->obj['host'][$name];
+                               if(isset($this->obj['host'][$name]))
+                                       $arrReturn[$name] = 
$this->obj['host'][$name];
                        }
                } elseif(count($filters) == 1 && $filters[0]['key'] == 
'host_groups' && $filters[0]['op'] == '>=') {
                        foreach($objects AS $OBJS) {
@@ -507,13 +508,14 @@ class GlobalBackendTest implements GlobalBackendInterface 
{
                        foreach($objects AS $OBJS) {
                                $name = $OBJS[0]->getName();
                                $aReturn[$name] = Array('counts' => 
$this->serviceStates);
-                               foreach($this->obj['service'][$name] AS 
$service) {
-                                       
if($service['problem_has_been_acknowledged'] == 1)
-                                               
$aReturn[$name]['counts'][$service['state']]['ack']++;
-                                       elseif($service['in_downtime'] == 1)
-                                               
$aReturn[$name]['counts'][$service['state']]['downtime']++;
-                                       else
-                                               
$aReturn[$name]['counts'][$service['state']]['normal']++;
+                               if(isset($this->obj['service'][$name]))
+                                       foreach($this->obj['service'][$name] AS 
$service) {
+                                               
if($service['problem_has_been_acknowledged'] == 1)
+                                                       
$aReturn[$name]['counts'][$service['state']]['ack']++;
+                                               elseif($service['in_downtime'] 
== 1)
+                                                       
$aReturn[$name]['counts'][$service['state']]['downtime']++;
+                                               else
+                                                       
$aReturn[$name]['counts'][$service['state']]['normal']++;
                                }
                        }
                } elseif(count($filters) == 1 && $filters[0]['key'] == 
'host_groups' && $filters[0]['op'] == '>=') {


------------------------------------------------------------------------------
The modern datacenter depends on network connectivity to access resources
and provide services. The best practices for maximizing a physical server's
connectivity to a physical network are well understood - see how these
rules translate into the virtual world? 
http://p.sf.net/sfu/oracle-sfdevnlfb
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to