diff --git a/modules/monitoring/application/controllers/CommandController.php b/modules/monitoring/application/controllers/CommandController.php index 3b92c963b..351415068 100644 --- a/modules/monitoring/application/controllers/CommandController.php +++ b/modules/monitoring/application/controllers/CommandController.php @@ -1022,6 +1022,7 @@ class Monitoring_CommandController extends ActionController if ($form->IsSubmittedAndValid() === true) { $this->target->sendCommand($form->createCommand(), $this->view->objects); + Notification::success('Downtime removal has been requested'); } } diff --git a/modules/monitoring/application/controllers/ListController.php b/modules/monitoring/application/controllers/ListController.php index cba80de89..ba3347e15 100644 --- a/modules/monitoring/application/controllers/ListController.php +++ b/modules/monitoring/application/controllers/ListController.php @@ -194,7 +194,24 @@ class Monitoring_ListController extends Controller 'title' => 'Downtimes', 'url' => Url::fromPath('monitoring/list/downtimes') ))->activate('downtimes'); - $query = DowntimeView::fromRequest($this->_request)->getQuery()->order('downtime_is_in_effect', 'DESC')->order('downtime_scheduled_start_time', 'DESC'); + $this->setAutorefreshInterval(12); + $query = DowntimeView::fromRequest( + $this->_request, + array( + 'id' => 'downtime_internal_id', + 'objecttype' => 'downtime_objecttype', + 'comment' => 'downtime_comment', + 'author' => 'downtime_author', + 'start' => 'downtime_start', + 'end' => 'downtime_end', + 'duration' => 'downtime_duration', + 'is_flexible' => 'downtime_is_flexible', + 'is_in_effect' => 'downtime_is_in_effect', + 'entry_time' => 'downtime_entry_time', + 'host' => 'downtime_host', + 'service' => 'downtime_service' + ) + )->getQuery()->order('downtime_is_in_effect', 'DESC')->order('downtime_scheduled_start_time', 'DESC'); $this->view->downtimes = $query->paginate(); $this->setupSortControl(array( diff --git a/modules/monitoring/application/views/scripts/list/downtimes.phtml b/modules/monitoring/application/views/scripts/list/downtimes.phtml index 224cc50cc..10ef53fc8 100644 --- a/modules/monitoring/application/views/scripts/list/downtimes.phtml +++ b/modules/monitoring/application/views/scripts/list/downtimes.phtml @@ -3,20 +3,24 @@ $helper = $this->getHelper('CommandForm'); ?>
tabs ?> +
sortControl->render($this); ?> +
paginationControl($downtimes, null, null, array('preserve' => $this->preserve)); ?>
+ +
- +downtimes as $downtime): ?>
- dateFormat()->formatDateTime((int) $downtime->downtime_start); ?> - - dateFormat()->formatDateTime((int) $downtime->downtime_end); ?> + dateFormat()->formatDateTime($downtime->start); ?> - + dateFormat()->formatDateTime($downtime->end); ?>
- Duration: util()->showHourMin((int) $downtime->downtime_duration); ?> + Duration: util()->showHourMin($downtime->duration); ?>
- The downtime_is_flexible): ?>flexiblefixed downtime is downtime_is_in_effect): ?>not in effect + The is_flexible): ?>flexiblefixed downtime is is_in_effect): ?>not in effect
service)): ?> @@ -31,14 +35,14 @@ $helper = $this->getHelper('CommandForm'); )); ?>">host ?>
- downtime_author ?>: downtime_comment ?> + author ?>: comment ?>
- Entry Time: downtime_entry_time) ? $this->dateFormat()->formatDateTime((int) $downtime->downtime_entry_time) : ''; ?> + Entry Time: entry_time) ? $this->dateFormat()->formatDateTime((int) $downtime->entry_time) : ''; ?> -
+ $downtime->downtime_internal_downtime_id, + 'downtimeid' => $downtime->id, 'host' => $downtime->host ); if (isset($downtime->service)) { @@ -47,7 +51,7 @@ $helper = $this->getHelper('CommandForm'); echo $helper->iconSubmitForm( 'img/icons/remove.png', 'Remove Downtime', - 'btn-small', + 'link-like', 'removedowntime', $data ); @@ -57,3 +61,4 @@ $helper = $this->getHelper('CommandForm');
+
diff --git a/modules/monitoring/application/views/scripts/show/components/downtime.phtml b/modules/monitoring/application/views/scripts/show/components/downtime.phtml index d13906adf..bb32f9c32 100644 --- a/modules/monitoring/application/views/scripts/show/components/downtime.phtml +++ b/modules/monitoring/application/views/scripts/show/components/downtime.phtml @@ -11,16 +11,16 @@ if ($object->service_description) { $list = array(); foreach ($object->downtimes as $downtime) { $deleteData = $data; - $deleteData['downtimeid'] = $object->downtime_internal_downtime_id; + $deleteData['downtimeid'] = $downtime->id; // TODO: This needs improvement - if ((int) $downtime->downtime_is_in_effect) { - $state = 'in downtime since ' . $this->timeSince($downtime->downtime_start); + if ((int) $downtime->is_in_effect) { + $state = 'in downtime since ' . $this->timeSince($downtime->start); } else { - if ($downtime->downtime_is_fixed) { - $state = 'scheduled ' . $this->timeUnless($downtime->downtime_start); + if ($downtime->is_fixed) { + $state = 'scheduled ' . $this->timeUnless($downtime->start); } else { - $state = 'scheduled flexible ' . $this->timeUnless($downtime->downtime_start); + $state = 'scheduled flexible ' . $this->timeUnless($downtime->start); } } @@ -35,9 +35,9 @@ foreach ($object->downtimes as $downtime) { $list[] = sprintf( "
%s [%s] (%s): %s\n", $iconForm, - $this->escape($downtime->downtime_author), + $this->escape($downtime->author), $state, - $this->escape($downtime->downtime_comment) + $this->escape($downtime->comment) ); } diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php index ba3bbbe0b..89686cee7 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/DowntimeQuery.php @@ -40,31 +40,22 @@ class DowntimeQuery extends IdoQuery */ protected $columnMap = array( 'downtime' => array( - 'downtime_objecttype_id' => 'sdo.objecttype_id', 'downtime_author' => 'sd.author_name', 'downtime_comment' => 'sd.comment_data', 'downtime_entry_time' => 'UNIX_TIMESTAMP(sd.entry_time)', 'downtime_is_fixed' => 'sd.is_fixed', 'downtime_is_flexible' => 'CASE WHEN sd.is_fixed = 0 THEN 1 ELSE 0 END', + 'downtime_triggered_by_id' => 'sd.triggered_by_id', 'downtime_scheduled_start_time' => 'UNIX_TIMESTAMP(sd.scheduled_start_time)', 'downtime_start' => "UNIX_TIMESTAMP(CASE WHEN sd.trigger_time != '0000-00-00 00:00:00' then sd.trigger_time ELSE sd.scheduled_start_time END)", 'downtime_end' => 'UNIX_TIMESTAMP(sd.scheduled_end_time)', 'downtime_duration' => 'sd.duration', 'downtime_is_in_effect' => 'sd.is_in_effect', - 'downtime_triggered_by_id' => 'sd.triggered_by_id', - 'downtime_internal_downtime_id' => 'sd.internal_downtime_id', + 'downtime_internal_id' => 'sd.internal_downtime_id', + 'downtime_host' => 'CASE WHEN ho.name1 IS NULL THEN so.name1 ELSE ho.name1 END COLLATE latin1_general_ci', + 'downtime_service' => 'so.name2 COLLATE latin1_general_ci', + 'downtime_objecttype' => "CASE WHEN ho.object_id IS NOT NULL THEN 'host' ELSE CASE WHEN so.object_id IS NOT NULL THEN 'service' ELSE NULL END END", ), - 'hosts' => array( - 'host_name' => 'ho.name1 COLLATE latin1_general_ci', - 'host' => 'ho.name1 COLLATE latin1_general_ci', - - ), - 'services' => array( - 'service_host_name' => 'so.name1 COLLATE latin1_general_ci', - 'service' => 'so.name2 COLLATE latin1_general_ci', - 'service_name' => 'so.name2 COLLATE latin1_general_ci', - 'service_description' => 'so.name2 COLLATE latin1_general_ci', - ) ); /** @@ -77,33 +68,18 @@ class DowntimeQuery extends IdoQuery array() ); - $this->baseQuery->join( - array( - 'sdo' => $this->prefix . 'objects' - ), - 'sd.object_id = sdo.' . $this->object_id . ' AND sdo.is_active = 1' + $this->baseQuery->joinLeft( + array('ho' => $this->prefix . 'objects'), + 'sd.object_id = ho.object_id AND ho.is_active = 1 AND ho.objecttype_id = 1', + array() + ); + + $this->baseQuery->joinLeft( + array('so' => $this->prefix . 'objects'), + 'sd.object_id = so.object_id AND so.is_active = 1 AND so.objecttype_id = 2', + array() ); $this->joinedVirtualTables = array('downtime' => true); } - - protected function joinHosts() - { - $this->conflictsWithVirtualTable('services'); - $this->baseQuery->join( - array('ho' => $this->prefix . 'objects'), - 'sdo.name1 = ho.name1 AND ho.is_active = 1 AND ho.objecttype_id = 1', - array() - ); - } - - protected function joinServices() - { - $this->conflictsWithVirtualTable('hosts'); - $this->baseQuery->joinLeft( - array('so' => $this->prefix . 'objects'), - 'sdo.name1 = so.name1 AND sdo.name2 = so.name2 AND so.is_active = 1 AND sdo.is_active = 1 AND so.objecttype_id = 2', - array() - ); - } } diff --git a/modules/monitoring/library/Monitoring/DataView/Downtime.php b/modules/monitoring/library/Monitoring/DataView/Downtime.php index fbde29fec..a982822f2 100644 --- a/modules/monitoring/library/Monitoring/DataView/Downtime.php +++ b/modules/monitoring/library/Monitoring/DataView/Downtime.php @@ -39,11 +39,7 @@ class Downtime extends DataView public function getColumns() { return array( - 'host', - 'host_name', - 'service', - 'service_description', - 'downtime_objecttype_id', + 'downtime_objecttype', 'downtime_author', 'downtime_comment', 'downtime_entry_time', @@ -54,7 +50,9 @@ class Downtime extends DataView 'downtime_duration', 'downtime_is_in_effect', 'downtime_triggered_by_id', - 'downtime_internal_downtime_id' + 'downtime_internal_id', + 'downtime_host', + 'downtime_service', ); } diff --git a/modules/monitoring/library/Monitoring/Object/AbstractObject.php b/modules/monitoring/library/Monitoring/Object/AbstractObject.php index 89f2c5816..eb70f752f 100644 --- a/modules/monitoring/library/Monitoring/Object/AbstractObject.php +++ b/modules/monitoring/library/Monitoring/Object/AbstractObject.php @@ -66,21 +66,26 @@ abstract class AbstractObject // WTF??? $query = Downtime::fromParams(array('backend' => null), array( - 'downtime_author', - 'downtime_comment', - 'downtime_entry_time', - 'downtime_is_fixed', - 'downtime_is_flexible', - 'downtime_scheduled_start_time', - 'downtime_start', - 'downtime_end', - 'downtime_duration', - 'downtime_is_in_effect', - 'downtime_triggered_by_id', - 'downtime_internal_downtime_id' + 'id' => 'downtime_internal_id', + 'objecttype' => 'downtime_objecttype', + 'comment' => 'downtime_comment', + 'author' => 'downtime_author', + 'start' => 'downtime_start', + 'end' => 'downtime_end', + 'duration' => 'downtime_duration', + 'is_flexible' => 'downtime_is_flexible', + 'is_in_effect' => 'downtime_is_in_effect', + 'entry_time' => 'downtime_entry_time', + 'host' => 'downtime_host', + 'service' => 'downtime_service' ))->getQuery(); - $query->where('downtime_objecttype_id', $this->type); - $this->applyObjectFilter($query); + + $query->where('downtime_objecttype', $this->type); + $query->where('downtime_host', $this->host_name); + if ($this->type === 'service') { + $query->where('downtime_service', $this->service_description); + } + $this->downtimes = $query->fetchAll(); return $this;