Module: nagvis Branch: master Commit: c8b54d35b1c5399761babf946436fe57a9e8b7ed URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=c8b54d35b1c5399761babf946436fe57a9e8b7ed
Author: LaMi <[email protected]> Date: Thu Apr 1 00:57:29 2010 +0200 Nice performance improvement when fetching information of child objects --- share/server/core/classes/objects/NagVisObject.php | 45 ++++++++++---------- .../core/classes/objects/NagVisStatefulObject.php | 25 +---------- share/server/core/defines/global.php | 1 + 3 files changed, 25 insertions(+), 46 deletions(-) diff --git a/share/server/core/classes/objects/NagVisObject.php b/share/server/core/classes/objects/NagVisObject.php index 766f90e..65df365 100644 --- a/share/server/core/classes/objects/NagVisObject.php +++ b/share/server/core/classes/objects/NagVisObject.php @@ -202,15 +202,33 @@ class NagVisObject { } /** - * PULBLIC getObjectInformation() + * PUBLIC getObjectInformation() * * Gets all necessary information of the object as array * * @return Array Object configuration * @author Lars Michelsen <[email protected]> */ - public function getObjectInformation($bFetchChilds=true) { + public function getObjectInformation($bFetchChilds = true) { $arr = Array(); + + // When the childs don't need to be fetched this object is a child + // itselfs. So much less information are needed. Progress them here + // If someone wants more information in hover menu children, this is + // the place to change. + if(!$bFetchChilds) { + $aChild = Array('type' => $this->getType(), + 'name' => $this->getName(), + 'summary_state' => $this->getSummaryState(), + 'summary_in_downtime' => $this->getSummaryInDowntime(), + 'summary_problem_has_been_acknowledged' => $this->getSummaryAcknowledgement(), + 'summary_output' => strtr($this->getSummaryOutput(), Array("\r" => '<br />', "\n" => '<br />', '"' => '"', '\'' => '‘'))); + if($this->type == 'service') { + $aChild['service_description'] = $this->getServiceDescription(); + } + + return $aChild; + } // Need to remove some options which are not relevant $arrDenyKeys = Array('CORE' => '', 'BACKEND' => '', 'MAPCFG' => '', @@ -341,28 +359,11 @@ class NagVisObject { $arr = array_merge($arr, $this->getObjectStateInformations(false)); } - // On children only return the following options to lower the bandwidth, - // memory and cpu usage. If someone wants more information in hover menu - // children, this is the place to change - if(!$bFetchChilds) { - $aChild = Array('type' => $arr['type'], - 'name' => $arr['name'], - 'summary_state' => $arr['summary_state'], - 'summary_in_downtime' => $arr['summary_in_downtime'], - 'summary_problem_has_been_acknowledged' => $arr['summary_problem_has_been_acknowledged'], - 'summary_output' => $arr['summary_output']); - if($this->type == 'service') { - $aChild['service_description'] = $arr['service_description']; - } - - $arr = $aChild; - } - - // Only do this for parents - if($bFetchChilds && isset($arr['num_members']) && $arr['num_members'] > 0) { + // If there are some members fetch the information for them + if(isset($arr['num_members']) && $arr['num_members'] > 0) { $arr['members'] = Array(); foreach($this->getSortedObjectMembers() AS $OBJ) { - $arr['members'][] = $OBJ->getObjectInformation(false); + $arr['members'][] = $OBJ->getObjectInformation(!GET_CHILDS); } } diff --git a/share/server/core/classes/objects/NagVisStatefulObject.php b/share/server/core/classes/objects/NagVisStatefulObject.php index 5b47564..c23c02c 100644 --- a/share/server/core/classes/objects/NagVisStatefulObject.php +++ b/share/server/core/classes/objects/NagVisStatefulObject.php @@ -447,29 +447,6 @@ class NagVisStatefulObject extends NagVisObject { public function getObjectStateInformations($bFetchChilds=true) { $arr = Array(); - /* FIXME: These are no state informations - don't send them - if(isset($this->alias) && $this->alias != '') { - $arr['alias'] = $this->alias; - } else { - $arr['alias'] = ''; - } - - if(isset($this->display_name) && $this->display_name != '') { - $arr['display_name'] = $this->display_name; - } else { - $arr['display_name'] = ''; - } - - // Save the number of members - switch($this->getType()) { - case 'host': - case 'map': - case 'hostgroup': - case 'servicegroup': - $arr['num_members'] = $this->getNumMembers(); - break; - }*/ - $arr['state'] = $this->getState(); $arr['summary_state'] = $this->getSummaryState(); $arr['summary_problem_has_been_acknowledged'] = $this->getSummaryAcknowledgement(); @@ -501,7 +478,7 @@ class NagVisStatefulObject extends NagVisObject { if($bFetchChilds && $this->hasMembers()) { $arr['members'] = Array(); foreach($this->getSortedObjectMembers() AS $OBJ) { - $arr['members'][] = $OBJ->getObjectInformation(false); + $arr['members'][] = $OBJ->getObjectInformation(!GET_CHILDS); } } diff --git a/share/server/core/defines/global.php b/share/server/core/defines/global.php index 5903881..d885c0f 100644 --- a/share/server/core/defines/global.php +++ b/share/server/core/defines/global.php @@ -72,6 +72,7 @@ define('DONT_GET_OBJECT_STATE', false); define('DONT_GET_SINGLE_MEMBER_STATES', false); define('IS_VIEW', true); define('ONLY_GLOBAL', true); +define('GET_CHILDS', true); // Maximum length for usernames/passwords define('AUTH_MAX_PASSWORD_LENGTH', 15); ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
