Monitoring\Object: explictely define columns

Define the colums we use instead of fetching "everything" status view
provides. Without this performance degrades with every new feature.
This commit is contained in:
Thomas Gelf 2014-05-20 22:19:26 +00:00
parent 76c1aa73c8
commit a7b8e0023d
3 changed files with 126 additions and 7 deletions

View File

@ -251,11 +251,6 @@ abstract class AbstractObject
return $this->$expandedName;
}
public function getRequest()
{
return $this->request;
}
public static function fromRequest(Request $request)
{
if ($request->has('service') && $request->has('host')) {

View File

@ -28,7 +28,48 @@ class Host extends AbstractObject
protected function getProperties()
{
$this->view = HostStatus::fromRequest($this->getRequest());
$this->view = HostStatus::fromRequest($this->request, array(
'host_name',
'host_alias',
'host_address',
'host_state',
'host_state_type',
'host_handled',
'host_in_downtime',
'host_acknowledged',
'host_last_state_change',
'host_last_notification',
'host_last_check',
'host_next_check',
'host_check_execution_time',
'host_check_latency',
'host_check_source',
'host_output',
'host_long_output',
'host_check_command',
'host_perfdata',
'host_passive_checks_enabled',
'host_passive_checks_enabled_changed',
'host_obsessing',
'host_obsessing_changed',
'host_notifications_enabled',
'host_notifications_enabled_changed',
'host_event_handler_enabled',
'host_event_handler_enabled_changed',
'host_flap_detection_enabled',
'host_flap_detection_enabled_changed',
'host_active_checks_enabled',
'host_active_checks_enabled_changed',
'host_current_check_attempt',
'host_max_check_attempts',
'host_current_notification_number',
'host_percent_state_change',
'host_is_flapping',
'host_action_url',
'host_notes_url',
'host_modified_host_attributes',
'host_problem'
));
return $this->view->getQuery()->fetchRow();
}
}

View File

@ -29,7 +29,90 @@ class Service extends AbstractObject
protected function getProperties()
{
$this->view = ServiceStatus::fromRequest($this->getRequest());
$this->view = ServiceStatus::fromRequest($this->request, array(
'host_name',
'host_state',
'host_state_type',
'host_last_state_change',
'host_address',
'host_problem',
'host_handled',
'service_description',
'service_display_name',
'service_state',
'service_in_downtime',
'service_acknowledged',
'service_handled',
'service_unhandled',
'service_output',
'service_last_state_change',
'service_icon_image',
'service_long_output',
'service_is_flapping',
'service_state_type',
'service_severity',
'service_last_check',
'service_notifications_enabled',
'service_notifications_enabled_changed',
'service_action_url',
'service_notes_url',
'service_last_check',
'service_next_check',
'service_attempt',
'service_last_notification',
'service_check_command',
'service_check_source',
'service_current_notification_number',
'host_icon_image',
'host_acknowledged',
'host_output',
'host_long_output',
'host_in_downtime',
'host_is_flapping',
'host_last_check',
'host_notifications_enabled',
'host_unhandled_service_count',
'host_action_url',
'host_notes_url',
'host_last_comment',
'host_display_name',
'host_alias',
'host_ipv4',
'host_severity',
'host_perfdata',
'host_active_checks_enabled',
'host_passive_checks_enabled',
'host_last_hard_state',
'host_last_hard_state_change',
'host_last_time_up',
'host_last_time_down',
'host_last_time_unreachable',
'host_modified_host_attributes',
'host',
'service',
'service_hard_state',
'service_problem',
'service_perfdata',
'service_active_checks_enabled',
'service_active_checks_enabled_changed',
'service_passive_checks_enabled',
'service_passive_checks_enabled_changed',
'service_last_hard_state',
'service_last_hard_state_change',
'service_last_time_ok',
'service_last_time_warning',
'service_last_time_critical',
'service_last_time_unknown',
'service_current_check_attempt',
'service_max_check_attempts',
'service_obsessing',
'service_obsessing_changed',
'service_event_handler_enabled',
'service_event_handler_enabled_changed',
'service_flap_detection_enabled',
'service_flap_detection_enabled_changed',
'service_modified_service_attributes',
));
return $this->view->getQuery()->fetchRow();
}
}