Esempio n. 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());
         }
     }
 }