Beispiel #1
0
 /**
  * PRIVATE fetchSummaryOutputFromCounts()
  *
  * Fetches the summary output from the object state counts
  *
  * @author	Lars Michelsen <*****@*****.**>
  */
 private function fetchSummaryOutputFromCounts()
 {
     if (NagVisHost::$langHostStateIs === null) {
         NagVisHost::$langHostStateIs = l('hostStateIs');
     }
     // Write host state
     $this->sum[OUTPUT] = NagVisHost::$langHostStateIs . ' ' . state_str($this->state[STATE]) . '. ';
     // Only merge host state with service state when recognize_services is set
     // to 1
     if ($this->recognize_services) {
         $iNumServices = 0;
         $arrServiceStates = array();
         // Loop all major states
         if ($this->aStateCounts !== null) {
             foreach ($this->aStateCounts as $sState => $aSubstates) {
                 if (is_host_state($sState)) {
                     continue;
                 }
                 // Loop all substates (normal,ack,downtime,...)
                 foreach ($aSubstates as $sSubState => $iCount) {
                     // Found some objects with this state+substate
                     if ($iCount > 0) {
                         if (!isset($arrServiceStates[$sState])) {
                             $arrServiceStates[$sState] = $iCount;
                             $iNumServices += $iCount;
                         } else {
                             $arrServiceStates[$sState] += $iCount;
                             $iNumServices += $iCount;
                         }
                     }
                 }
             }
         }
         if ($iNumServices > 0) {
             if (NagVisHost::$langServices === null) {
                 NagVisHost::$langServices = l('services');
             }
             $this->mergeSummaryOutput($arrServiceStates, NagVisHost::$langServices);
         } else {
             $this->sum[OUTPUT] .= l('hostHasNoServices', 'HOST~' . $this->getName());
         }
     }
 }
Beispiel #2
0
 /**
  * Fetches the summary output from the object state counts
  */
 private function fetchSummaryOutputFromCounts()
 {
     $arrHostStates = array();
     $arrServiceStates = array();
     // Loop all major states
     $iSumCount = 0;
     foreach ($this->aStateCounts as $sState => $aSubstates) {
         // Loop all substates (normal,ack,downtime,...)
         foreach ($aSubstates as $sSubState => $iCount) {
             // Found some objects with this state+substate
             if ($iCount > 0) {
                 // Count all child objects
                 $iSumCount += $iCount;
                 if (is_host_state($sState)) {
                     if (!isset($arrHostStates[$sState])) {
                         $arrHostStates[$sState] = $iCount;
                     } else {
                         $arrHostStates[$sState] += $iCount;
                     }
                 } else {
                     if (!isset($arrServiceStates[$sState])) {
                         $arrServiceStates[$sState] = $iCount;
                     } else {
                         $arrServiceStates[$sState] += $iCount;
                     }
                 }
             }
         }
     }
     // Fallback for hostgroups without members
     if ($iSumCount == 0) {
         $this->sum[OUTPUT] = l('The hostgroup "[GROUP]" has no members or does not exist (Backend: [BACKEND]).', array('GROUP' => $this->getName(), 'BACKEND' => implode(", ", $this->backend_id)));
     } else {
         // FIXME: Recode mergeSummaryOutput method
         $this->mergeSummaryOutput($arrHostStates, l('hosts'), false);
         if ($this->recognize_services) {
             $this->sum[OUTPUT] .= ' ' . l('and') . ' ';
             $this->mergeSummaryOutput($arrServiceStates, l('services'), true, true);
         }
     }
 }