Module: nagvis Branch: master Commit: 96926457515c35128c8c3a0bb012a8c5bb1b80c0 URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=96926457515c35128c8c3a0bb012a8c5bb1b80c0
Author: LaMi <[email protected]> Date: Thu Nov 12 14:35:46 2009 +0100 Fixed state fetching bugs for hostgroup members; Improved performance using new StatsGroupBy statement --- .../core/classes/GlobalBackendmklivestatus.php | 43 +++++++++---------- .../core/classes/objects/NagiosHostgroup.php | 4 +- 2 files changed, 23 insertions(+), 24 deletions(-) diff --git a/share/server/core/classes/GlobalBackendmklivestatus.php b/share/server/core/classes/GlobalBackendmklivestatus.php index 18c196c..22dd9ed 100644 --- a/share/server/core/classes/GlobalBackendmklivestatus.php +++ b/share/server/core/classes/GlobalBackendmklivestatus.php @@ -398,13 +398,13 @@ class GlobalBackendmklivestatus implements GlobalBackendInterface { // active scheduled host checks the host state is not set to hard ok when // it gets recovered by a succeeded service check if($onlyHardstates == 1 && $e[1] != '0') { - $e[1] = $e[17]; + $e[1] = $e[16]; } // Catch pending objects - // $e[18]: has_been_checked + // $e[19]: has_been_checked // $e[1]: state - if($e[18] == '0' || $e[1] == '') { + if($e[19] == '0' || $e[1] == '') { $arrTmpReturn['state'] = 'PENDING'; $arrTmpReturn['output'] = GlobalCore::getInstance()->getLang()->getText('hostIsPending', Array('HOST' => $e[0])); } else { @@ -449,7 +449,7 @@ class GlobalBackendmklivestatus implements GlobalBackendInterface { $arrTmpReturn['last_hard_state_change'] = $e[13]; $arrTmpReturn['statusmap_image'] = $e[14]; $arrTmpReturn['perfdata'] = $e[15]; - $arrTmpReturn['problem_has_been_acknowledged'] = $e[16]; + $arrTmpReturn['problem_has_been_acknowledged'] = $e[17]; } $arrReturn[] = $arrTmpReturn; @@ -1040,9 +1040,7 @@ class GlobalBackendmklivestatus implements GlobalBackendInterface { // Count PENDING $query .= "Stats: has_been_checked = 0\n" . - "StatsGroupBy: host_name\n"; - - /* . + "StatsGroupBy: host_name\n" . // Count OK "Stats: ".$stateAttr." = 0\n" . "StatsGroupBy: host_name\n" . @@ -1111,24 +1109,23 @@ class GlobalBackendmklivestatus implements GlobalBackendInterface { "Stats: host_scheduled_downtime_depth = 1\n" . "StatsOr: 2\n" . "StatsAnd: 2\n" . - "StatsGroupBy: host_name\n";*/ - - $services = $this->queryLivestatusSingleRow($query); - - $i = 0; - foreach($aHostNames AS $hostName) { - $aReturn[$hostName] = Array(); - $aReturn[$hostName]['PENDING']['normal'] = $services[$i++]; - $aReturn[$hostName]['OK']['normal'] = $services[$i++]; - $aReturn[$hostName]['WARNING']['normal'] = $services[$i++]; - $aReturn[$hostName]['WARNING']['ack'] = $services[$i++]; - $aReturn[$hostName]['WARNING']['downtime'] = $services[$i++]; - $aReturn[$hostName]['CRITICAL']['normal'] = $services[$i++]; - $aReturn[$hostName]['CRITICAL']['ack'] = $services[$i++]; - $aReturn[$hostName]['CRITICAL']['downtime'] = $services[$i++]; - $aReturn[$hostName]['UNKNOWN']['normal'] = $services[$i++]; - $aReturn[$hostName]['UNKNOWN']['ack'] = $services[$i++]; - $aReturn[$hostName]['UNKNOWN']['downtime'] = $services[$i++]; + "StatsGroupBy: host_name\n"; + + $services = $this->queryLivestatus($query); + + foreach($services AS $service) { + $aReturn[$service[0]] = Array(); + $aReturn[$service[0]]['PENDING']['normal'] = $service[1]; + $aReturn[$service[0]]['OK']['normal'] = $service[2]; + $aReturn[$service[0]]['WARNING']['normal'] = $service[3]; + $aReturn[$service[0]]['WARNING']['ack'] = $service[4]; + $aReturn[$service[0]]['WARNING']['downtime'] = $service[5]; + $aReturn[$service[0]]['CRITICAL']['normal'] = $service[6]; + $aReturn[$service[0]]['CRITICAL']['ack'] = $service[7]; + $aReturn[$service[0]]['CRITICAL']['downtime'] = $service[8]; + $aReturn[$service[0]]['UNKNOWN']['normal'] = $service[9]; + $aReturn[$service[0]]['UNKNOWN']['ack'] = $service[10]; + $aReturn[$service[0]]['UNKNOWN']['downtime'] = $service[11]; } return $aReturn; diff --git a/share/server/core/classes/objects/NagiosHostgroup.php b/share/server/core/classes/objects/NagiosHostgroup.php index c57c272..037d102 100644 --- a/share/server/core/classes/objects/NagiosHostgroup.php +++ b/share/server/core/classes/objects/NagiosHostgroup.php @@ -239,7 +239,9 @@ class NagiosHostgroup extends NagVisStatefulObject { $OBJ->summary_output = $OBJ->output; // Put state counts to the object - $OBJ->setStateCounts($aServiceStateCounts[$aHost['name']]); + if(isset($aServiceStateCounts[$aHost['name']])) { + $OBJ->setStateCounts($aServiceStateCounts[$aHost['name']]); + } // Fetch summary state and output $OBJ->fetchSummariesFromCounts(); ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
