4 * State calculator for multiple objects that returns the best state at any point in time
6 class BestStateCalculator
extends WorstStateCalculator
8 public function calculate_object_state()
10 if ($this->st_is_service
)
11 $states = array(Reports_Model
::SERVICE_OK
, Reports_Model
::SERVICE_WARNING
, Reports_Model
::SERVICE_CRITICAL
, Reports_Model
::SERVICE_UNKNOWN
, Reports_Model
::SERVICE_PENDING
, Reports_Model
::SERVICE_EXCLUDED
);
13 $states = array(Reports_Model
::HOST_UP
, Reports_Model
::HOST_DOWN
, Reports_Model
::HOST_UNREACHABLE
, Reports_Model
::HOST_PENDING
, Reports_Model
::HOST_EXCLUDED
);
15 $final_state = $states[count($states) - 1];
17 foreach ($states as $state) {
18 $keys = array_keys($this->st_sub
[$state]);
19 // Sort downtime states outside downtime first
21 foreach ($keys as $in_dt) {
22 if (!empty($this->st_sub
[$state][$in_dt])) {
23 $final_state = $state;
24 $this->st_dt_depth
= $in_dt;
30 $this->st_obj_state
= $final_state;