diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index e1622e947..8c4abc506 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -71,7 +71,6 @@ class AuthenticationController extends ActionController if ($this->view->form->isPostAndValid()) { - $credentials->setUsername($this->view->form->getValue('username')); $credentials->setPassword($this->view->form->getValue('password')); diff --git a/config/backends.ini.in b/config/backends.ini.in old mode 100644 new mode 100755 diff --git a/config/menu.ini b/config/menu.ini old mode 100644 new mode 100755 diff --git a/config/modules/monitoring/menu.ini b/config/modules/monitoring/menu.ini old mode 100644 new mode 100755 index bd902fd2e..25dd62018 --- a/config/modules/monitoring/menu.ini +++ b/config/modules/monitoring/menu.ini @@ -9,4 +9,5 @@ _1 = 1 Hosts = "/monitoring/list/hosts" Services = "/monitoring/list/services" +Downtimes = "/monitoring/list/downtimes" Summaries = "/monitoring/summary/group/by/hostgroup" diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index 2d0b4d281..d9698642c 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -45,7 +45,6 @@ class Monitoring_ListController extends ModuleActionController 'host_last_comment' ) ); - } public function servicesAction() @@ -86,9 +85,7 @@ class Monitoring_ListController extends ModuleActionController 'service_notes_url', 'service_last_comment' )); - if ($this->_getParam('sort')) { - $this->view->sort = $this->_getParam('sort'); - } + $this->inheritCurrentSortColumn(); } public function hostgroupsAction() @@ -145,6 +142,36 @@ class Monitoring_ListController extends ModuleActionController exit; } + /** + * Fetch the current downtimes and put them into the view + * property 'downtimes' + */ + public function downtimesAction() + { + $query = $this->backend->select() + ->from('downtime',array( + 'host_name', + 'object_type', + 'service_description', + 'downtime_entry_time', + 'downtime_internal_downtime_id', + 'downtime_author_name', + 'downtime_comment_data', + 'downtime_duration', + 'downtime_scheduled_start_time', + 'downtime_scheduled_end_time', + 'downtime_is_fixed', + 'downtime_is_in_effect', + 'downtime_triggered_by_id', + 'downtime_trigger_time' + )); + if (!$this->_getParam('sort')) { + $query->order('downtime_is_in_effect'); + } + $this->view->downtimes = $query->applyRequest($this->_request); + $this->inheritCurrentSortColumn(); + } + protected function query($view, $columns) { $extra = preg_split( @@ -197,6 +224,11 @@ class Monitoring_ListController extends ModuleActionController 'icon' => 'img/classic/server.png', 'url' => 'monitoring/list/hosts', )); + $tabs->add('downtimes', array( + 'title' => 'Downtimes', + 'icon' => 'img/classic/downtime.gif', + 'url' => 'monitoring/list/downtimes', + )); /* $tabs->add('hostgroups', array( 'title' => 'Hostgroups', @@ -221,4 +253,16 @@ class Monitoring_ListController extends ModuleActionController */ return $tabs; } + + + /** + * Let the current response inherit the used sort column by applying it to the + * view property 'sort' + */ + private function inheritCurrentSortColumn() + { + if ($this->_getParam('sort')) { + $this->view->sort = $this->_getParam('sort'); + } + } } diff --git a/modules/monitoring/application/controllers/ShowController.php b/modules/monitoring/application/controllers/ShowController.php index 0ab900172..23ba73b49 100644 --- a/modules/monitoring/application/controllers/ShowController.php +++ b/modules/monitoring/application/controllers/ShowController.php @@ -135,6 +135,30 @@ class Monitoring_ShowController extends ModuleActionController ->where('service_description', $this->view->service->service_description) ->fetchAll(); + $this->view->downtimes = $this->backend->select() + ->from( + 'downtime', + array( + 'host_name', + 'service_description', + 'downtime_type', + 'downtime_author_name', + 'downtime_comment_data', + 'downtime_is_fixed', + 'downtime_duration', + 'downtime_scheduled_start_time', + 'downtime_scheduled_end_time', + 'downtime_actual_start_time', + 'downtime_was_started', + 'downtime_is_in_effect', + 'downtime_internal_downtime_id' + ) + ) + ->where('host_name', $this->view->host->host_name) + ->where('service_description', $this->view->service->service_description) + ->where('object_type','service') + ->fetchAll(); + $this->view->customvars = $this->backend->select() ->from( 'customvar', @@ -236,6 +260,7 @@ class Monitoring_ShowController extends ModuleActionController ) ) ->where('host_name', $this->view->host->host_name) + ->where('object_type','host') ->fetchAll(); $this->view->customvars = $this->backend->select() @@ -368,7 +393,6 @@ class Monitoring_ShowController extends ModuleActionController } } } - /** * Creating tabs for this controller * @return \Icinga\Web\Widget\AbstractWidget diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml new file mode 100644 index 000000000..1decf5052 --- /dev/null +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -0,0 +1,159 @@ +tabs ?> + +util()->showTime($d->getTimestamp()); +} +$paginator = $downtimes->paginate(); +$downtimes = $downtimes->fetchAll(); +?> +
+ Sort by formSelect( + 'sort', + $this->sort, + array('class' => 'autosubmit'), + array( + 'downtime_is_in_effect' => 'Is In Effect', + 'object_type' => 'Service/Host', + 'host_name' => 'Host Name', + 'service_description' => 'Service Name', + 'downtime_entry_time' => 'Entry Time', + 'downtime_author_name' => 'Author', + 'downtime_comment_data' => 'Comment', + 'downtime_scheduled_start_time' => 'Start', + 'downtime_scheduled_end_time' => 'End', + 'downtime_trigger_time' => 'Trigger Time', + 'downtime_internal_downtime_id' => 'Downtime ID', + 'downtime_duration' => 'Duration', + ) + ) ?> + + +
+paginationControl( + $paginator, + null, + array( + 'mixedPagination.phtml', + 'default'), + array('preserve' => $this->preserve)) +?> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Is In Effect Object Host Name Service Name Entry Time Author Comment Start Time End Time Type Trigger Time Downtime ID Trigger ID Duration
+ downtime_is_in_effect == 0 ? 'False' : 'True'; ?> + +
+ object_type == 'service'): ?> + + + object_type == 'host'): ?> + + +
+
+ host_name ?> + + service_description ?> + + downtime_entry_time); ?> + + downtime_author_name ?> + + downtime_comment_data ?> + + downtime_scheduled_start_time); ?> + + downtime_scheduled_end_time); ?> + + downtime_is_fixed == 1 ? 'Fixed' : 'Not Fixed' ?> + + downtime_trigger_time); + echo $date != 'undef' ? $date : 'N/A'; + ?> + + downtime_internal_downtime_id ?> + + downtime_triggered_by_id == 0 ? + 'N/A' : $downtime->downtime_triggered_by_id ?> + + util()->showHourMin(intval($downtime->downtime_duration)); ?> + + service_description)) { + echo $this->qlink( + '', + 'monitoring/show/host', + array( + 'host' => $downtime->host_name + ), + array( + 'class' => 'row-action' + ) + ); + } else { + echo $this->qlink( + '', + 'monitoring/show/service', + array( + 'host' => $downtime->host_name, + 'service' => $downtime->service_description + ), + array( + 'class' => 'row-action' + ) + ); + } + ?> +
diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php index 5388d48ad..39a201748 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php @@ -40,6 +40,7 @@ class DowntimeQuery extends AbstractQuery 'downtime_type' => 'sd.downtime_type', 'downtime_author_name' => 'sd.author_name', 'downtime_comment_data' => 'sd.comment_data', + 'downtime_entry_time' => 'sd.entry_time', 'downtime_is_fixed' => 'sd.is_fixed', 'downtime_duration' => 'sd.duration', 'downtime_scheduled_start_time' => 'sd.scheduled_start_time', @@ -49,14 +50,14 @@ class DowntimeQuery extends AbstractQuery 'downtime_actual_start_time_usec' => 'sd.actual_start_time_usec', 'downtime_is_in_effect' => 'sd.is_in_effect', 'downtime_trigger_time' => 'sd.trigger_time', + 'downtime_triggered_by_id' => 'sd.triggered_by_id', 'downtime_internal_downtime_id' => 'sd.internal_downtime_id' ), - 'hosts' => array( - 'host_name' => 'ho.name1', - ), - 'services' => array( - 'service_host_name' => 'so.name1', - 'service_description' => 'so.name2', + 'objects' => array( + 'host_name' => 'o.name1 COLLATE latin1_general_ci', + 'service_host_name' => 'o.name1 COLLATE latin1_general_ci', + 'service_description' => 'o.name2 COLLATE latin1_general_ci', + 'object_type' => "CASE o.objecttype_id WHEN 1 THEN 'host' ELSE 'service' END", ) ); @@ -70,29 +71,17 @@ class DowntimeQuery extends AbstractQuery array() ); - $this->joinedVirtualTables = array('downtime' => true); + $this->joinedVirtualTables = array('downtime' => true, 'services' => true); } /** * Join if host needed */ - protected function joinHosts() + protected function joinObjects() { $this->baseQuery->join( - array('ho' => $this->prefix . 'objects'), - 'sd.object_id = ho.object_id AND ho.is_active = 1 AND ho.objecttype_id = 1', - array() - ); - } - - /** - * Join if services needed - */ - protected function joinServices() - { - $this->baseQuery->join( - array('so' => $this->prefix . 'objects'), - 'so.object_id = ho.object_id AND ho.is_active = 1 AND ho.objecttype_id = 2', + array('o' => $this->prefix . 'objects'), + 'sd.object_id = o.object_id AND o.is_active = 1 AND o.objecttype_id IN (1, 2)', array() ); } diff --git a/modules/monitoring/library/Monitoring/View/DowntimeView.php b/modules/monitoring/library/Monitoring/View/DowntimeView.php index 1f7194386..6300f25ff 100644 --- a/modules/monitoring/library/Monitoring/View/DowntimeView.php +++ b/modules/monitoring/library/Monitoring/View/DowntimeView.php @@ -40,11 +40,16 @@ class DowntimeView extends MonitoringView * @var string[] */ protected $availableColumns = array( + 'host_name', + 'object_type', + 'service_host_name', + 'service_description', 'downtime_type', 'downtime_author_name', 'downtime_comment_data', 'downtime_is_fixed', 'downtime_duration', + 'downtime_entry_time', 'downtime_scheduled_start_time', 'downtime_scheduled_end_time', 'downtime_was_started', @@ -52,6 +57,7 @@ class DowntimeView extends MonitoringView 'downtime_actual_start_time_usec', 'downtime_is_in_effect', 'downtime_trigger_time', + 'downtime_triggered_by_id', 'downtime_internal_downtime_id' );