/** * Populates the state weight structure, provided by hardcoded defaults * and maybe the user configuration */ private function parseStateWeight() { $arr = array(); foreach ($this->validConfig['states'] as $lowState => $aVal) { $key = explode('_', $lowState); // Convert state values to int $last_part = $key[sizeof($key) - 1]; if ($last_part != 'color' && $last_part != 'bgcolor' && $last_part != 'sound') { $val = intval($this->getValue('states', $lowState)); } else { $val = $this->getValue('states', $lowState); } $state = state_num(strtoupper($key[0])); // First create array when not exists if (!isset($arr[$state])) { $arr[$state] = array(); } if (isset($key[1]) && isset($key[2])) { // at the moment only bg colors of substates $arr[$state][$key[1] . '_' . $key[2]] = $val; } elseif (isset($key[1])) { // ack/downtime $arr[$state][$key[1]] = $val; } else { // normal state definition $arr[$state]['normal'] = $val; } } $this->stateWeight = $arr; }
private function getBPState($state) { if ($state == null) { return UNKNOWN; } return state_num($state); }
/** * Returns the state with detailed information of a list of services. Using * the given objects and filters. */ public function getServiceState($objects, $options, $filters) { $aggregations = $this->getUrl('view.py?view_name=aggr_all_api&po_aggr_expand=1&po_aggr_treetype=0'); $ret = array(); foreach ($objects as $key => $OBJS) { $aggr = $this->matchAggregation($aggregations, $key); if ($aggr === null) { continue; } // did not find this aggregation // Add the services // Add the single component state counts $elements = $this->getAggrElements($aggr); foreach ($elements as $element) { // 0: state short code, 1: element name $s = state_num(GlobalBackendmkbi::$bi_short_states[$element[0]]); $child = array($s, '', 0, 0, 1, 1, 1, null, null, null, null, '', $element[1], $element[1], '', '', '', null, null, null, null, null, 0, $element[1]); $ret[$key][] = $child; } } return $ret; }
private function getAggrState($state) { return state_num(GlobalBackendmkbi::$bi_aggr_states[(int) $state]); }