/** * Merges the summary output from objects and all child objects together */ protected function mergeSummaryOutput($arrStates, $objLabel, $finish = true, $continue = false) { if (NagVisStatefulObject::$langMemberStates === null) { NagVisStatefulObject::$langMemberStates = l('Contains'); } if ($this->sum[OUTPUT] === null) { $this->sum[OUTPUT] = ''; } if (!$continue) { $this->sum[OUTPUT] .= NagVisStatefulObject::$langMemberStates . ' '; } foreach ($arrStates as $state => $num) { if ($num > 0) { $this->sum[OUTPUT] .= $num . ' ' . state_str($state) . ', '; } } // If some has been added remove last comma, else add a simple 0 if (substr($this->sum[OUTPUT], -2, 2) == ', ') { $this->sum[OUTPUT] = rtrim($this->sum[OUTPUT], ', '); } else { $this->sum[OUTPUT] .= '0 '; } $this->sum[OUTPUT] .= ' ' . $objLabel; if ($finish) { $this->sum[OUTPUT] .= '.'; } }
/** * PRIVATE fetchSummaryOutput() * * Fetches the summary output from host and all services * * @author Lars Michelsen <*****@*****.**> */ private function fetchSummaryOutput() { // Write host state $this->sum[OUTPUT] = l('hostStateIs') . ' ' . state_str($this->state[STATE]) . '. '; // Only merge host state with service state when recognize_services is set // to 1 if ($this->recognize_services) { // If there are services write the summary state for them if ($this->hasMembers()) { $arrStates = array(CRITICAL => 0, DOWN => 0, WARNING => 0, UNKNOWN => 0, UP => 0, OK => 0, ERROR => 0, PENDING => 0, UNCHECKED => 0); foreach ($this->members as &$SERVICE) { $arrStates[$SERVICE->getSummaryState()]++; } $this->mergeSummaryOutput($arrStates, l('services')); } else { $this->sum[OUTPUT] .= l('hostHasNoServices', 'HOST~' . $this->getName()); } } }
/** * Returns an array with the state weight configuration for the * JS frontend, which is not yet aware of numeric state codes. So * translate the states here. */ public function getStateWeightJS() { $arr = array(); foreach ($this->stateWeight as $state => $val) { $arr[state_str($state)] = $val; } return $arr; }