Cleaning up object downtimes. What a mess... :(
This commit is contained in:
parent
485222492b
commit
740df4ccac
|
@ -624,6 +624,7 @@ class Monitoring_CommandController extends ActionController
|
||||||
|
|
||||||
if ($form->IsSubmittedAndValid() === true) {
|
if ($form->IsSubmittedAndValid() === true) {
|
||||||
$this->target->sendCommand($form->createCommand(), $this->view->objects);
|
$this->target->sendCommand($form->createCommand(), $this->view->objects);
|
||||||
|
Notification::success('Downtime scheduling requested, result should be shown soon');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -641,6 +642,7 @@ class Monitoring_CommandController extends ActionController
|
||||||
|
|
||||||
if ($form->IsSubmittedAndValid() === true) {
|
if ($form->IsSubmittedAndValid() === true) {
|
||||||
$this->target->sendCommand($form->createCommand(), $this->view->objects);
|
$this->target->sendCommand($form->createCommand(), $this->view->objects);
|
||||||
|
Notification::success('Downtime scheduling requested, result should be shown soon');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,6 +661,7 @@ class Monitoring_CommandController extends ActionController
|
||||||
|
|
||||||
if ($form->IsSubmittedAndValid() === true) {
|
if ($form->IsSubmittedAndValid() === true) {
|
||||||
$this->target->sendCommand($form->createCommand(), $this->view->objects);
|
$this->target->sendCommand($form->createCommand(), $this->view->objects);
|
||||||
|
Notification::success('Downtime removal requested, result should be shown soon');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,8 @@ use Icinga\Protocol\Commandpipe\Comment;
|
||||||
use Icinga\Util\DateTimeFactory;
|
use Icinga\Util\DateTimeFactory;
|
||||||
use Icinga\Module\Monitoring\Backend;
|
use Icinga\Module\Monitoring\Backend;
|
||||||
use Icinga\Module\Monitoring\Command\ScheduleDowntimeCommand;
|
use Icinga\Module\Monitoring\Command\ScheduleDowntimeCommand;
|
||||||
|
use Icinga\Module\Monitoring\Object\AbstractObject;
|
||||||
|
use Icinga\Module\Monitoring\Object\Service;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Form for scheduling downtimes
|
* Form for scheduling downtimes
|
||||||
|
@ -89,6 +91,11 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm
|
||||||
|
|
||||||
$cfg = $this->getConfiguration();
|
$cfg = $this->getConfiguration();
|
||||||
$preferences = $this->getUserPreferences();
|
$preferences = $this->getUserPreferences();
|
||||||
|
$object = AbstractObject::fromRequest($this->getRequest());
|
||||||
|
$object->fetchDowntimes();
|
||||||
|
$downtimes = $object->downtimes;
|
||||||
|
/*
|
||||||
|
|
||||||
$downtimes = Backend::createBackend($this->getRequest()->getParam('backend'))->select()
|
$downtimes = Backend::createBackend($this->getRequest()->getParam('backend'))->select()
|
||||||
->from(
|
->from(
|
||||||
'downtime',
|
'downtime',
|
||||||
|
@ -100,7 +107,7 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm
|
||||||
'downtime_internal_downtime_id'
|
'downtime_internal_downtime_id'
|
||||||
)
|
)
|
||||||
)->fetchAll();
|
)->fetchAll();
|
||||||
|
*/
|
||||||
$options = array(
|
$options = array(
|
||||||
'0' => 'No Triggered Downtime'
|
'0' => 'No Triggered Downtime'
|
||||||
);
|
);
|
||||||
|
@ -109,8 +116,8 @@ class ScheduleDowntimeForm extends WithChildrenCommandForm
|
||||||
$label = sprintf(
|
$label = sprintf(
|
||||||
'ID %s: %s%s Starting @ %s',
|
'ID %s: %s%s Starting @ %s',
|
||||||
$downtime->downtime_internal_downtime_id,
|
$downtime->downtime_internal_downtime_id,
|
||||||
$downtime->host,
|
$object->host_name,
|
||||||
!empty($downtime->service_description) ? ' (' . $downtime->service_description . ')' : '',
|
$object instanceof Service ? ' (' . $object->service_description . ')' : '',
|
||||||
$dateFormat->formatDateTime($downtime->downtime_scheduled_start_time)
|
$dateFormat->formatDateTime($downtime->downtime_scheduled_start_time)
|
||||||
);
|
);
|
||||||
$options[$downtime->downtime_internal_downtime_id] = $label;
|
$options[$downtime->downtime_internal_downtime_id] = $label;
|
||||||
|
|
|
@ -1,66 +1,51 @@
|
||||||
<div>
|
<?php
|
||||||
<div class="panel-heading">
|
|
||||||
<div class="panel-hostname">
|
|
||||||
|
|
||||||
<div class="pull-right">
|
$cf = $this->getHelper('CommandForm');
|
||||||
<?php
|
|
||||||
$scheduleDowntimeData = array(
|
|
||||||
'host' => $this->object->host_name,
|
|
||||||
'service' => $this->object->service_description
|
|
||||||
);
|
|
||||||
|
|
||||||
$scheduleDowntimeHref = $this->href('monitoring/command/scheduleDowntime', $scheduleDowntimeData);
|
$data = array('host' => $object->host_name);
|
||||||
?>
|
if ($object->service_description) {
|
||||||
<a href="<?= $scheduleDowntimeHref; ?>" class="btn-common btn-small button" title="Schedule downtime">
|
$data['service'] = $object->service_description;
|
||||||
<?= $this->icon('in_downtime.png') ?>
|
}
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
Downtimes
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<hr class="separator" />
|
|
||||||
<div class="panel-body">
|
|
||||||
<table class="table table-condensed table-detail">
|
|
||||||
<tbody>
|
|
||||||
<?php if (empty($this->object->downtimes)): ?>
|
|
||||||
<tr>
|
|
||||||
<td>No Downtimes</td>
|
|
||||||
</tr>
|
|
||||||
<?php else: ?>
|
|
||||||
<?php foreach ($this->object->downtimes as $downtime): ?>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<div class="pull-right">
|
|
||||||
<?= $this->getHelper('CommandForm')->iconSubmitForm(
|
|
||||||
'img/icons/remove.png',
|
|
||||||
'Remove Downtime',
|
|
||||||
'btn-small',
|
|
||||||
'removedowntime',
|
|
||||||
array(
|
|
||||||
'downtimeid' => $downtime->downtime_internal_downtime_id,
|
|
||||||
'host' => $downtime->host,
|
|
||||||
'service' => $downtime->service
|
|
||||||
)
|
|
||||||
); ?>
|
|
||||||
</div>
|
|
||||||
<?php if ($downtime->downtime_is_in_effect === '1'): ?>
|
|
||||||
In scheduled downtime since <?= $this->timeSince($downtime->downtime_start); ?>
|
|
||||||
<?php else: ?>
|
|
||||||
<?php if ($downtime->downtime_is_fixed): ?>
|
|
||||||
Downtime scheduled for <?= $downtime->downtime_start; ?>
|
|
||||||
<?php else: ?>
|
|
||||||
Waiting
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<div class="small-row">
|
|
||||||
<?= $downtime->downtime_author; ?>: <?= $downtime->downtime_comment; ?>
|
$list = array();
|
||||||
</div>
|
foreach ($object->downtimes as $downtime) {
|
||||||
</td>
|
$deleteData = $data;
|
||||||
</tr>
|
$deleteData['downtimeid'] = $object->downtime_internal_downtime_id;
|
||||||
<?php endforeach; ?>
|
|
||||||
<?php endif; ?>
|
// TODO: This needs improvement
|
||||||
</tbody>
|
if ((int) $downtime->downtime_is_in_effect) {
|
||||||
</table>
|
$state = 'in downtime since ' . $this->timeSince($downtime->downtime_start);
|
||||||
</div>
|
} else {
|
||||||
</div>
|
if ($downtime->downtime_is_fixed) {
|
||||||
|
$state = 'scheduled ' . $this->timeUnless($downtime->downtime_start);
|
||||||
|
} else {
|
||||||
|
$state = 'scheduled flexible ' . $this->timeUnless($downtime->downtime_start);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$iconForm = $cf->iconSubmitForm(
|
||||||
|
'img/icons/remove_petrol.png',
|
||||||
|
'Remove Downtime',
|
||||||
|
'link-like',
|
||||||
|
'removedowntime',
|
||||||
|
$deleteData
|
||||||
|
);
|
||||||
|
|
||||||
|
$list[] = sprintf(
|
||||||
|
"<br />%s [%s] (%s): %s\n",
|
||||||
|
$iconForm,
|
||||||
|
$this->escape($downtime->downtime_author),
|
||||||
|
$state,
|
||||||
|
$this->escape($downtime->downtime_comment)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<th><?= $this->translate('Downtimes') ?></th>
|
||||||
|
<td>
|
||||||
|
<a href="<?= $this->href('monitoring/command/scheduleDowntime', $data) ?>"><?= $this->icon('in_downtime_petrol.png') ?> <?= $this->translate('Schedule downtime') ?></a>
|
||||||
|
<?= implode('', $list) ?>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
|
@ -6,11 +6,9 @@
|
||||||
<?= $this->render('show/components/output.phtml') ?>
|
<?= $this->render('show/components/output.phtml') ?>
|
||||||
<?= $this->render('show/components/status.phtml') ?>
|
<?= $this->render('show/components/status.phtml') ?>
|
||||||
|
|
||||||
|
|
||||||
<?= $this->render('show/components/downtime.phtml') ?>
|
|
||||||
|
|
||||||
<table class="avp">
|
<table class="avp">
|
||||||
<?= $this->render('show/components/comments.phtml') ?>
|
<?= $this->render('show/components/comments.phtml') ?>
|
||||||
|
<?= $this->render('show/components/downtime.phtml') ?>
|
||||||
<?= $this->render('show/components/flapping.phtml') ?>
|
<?= $this->render('show/components/flapping.phtml') ?>
|
||||||
<?= $this->render('show/components/perfdata.phtml') ?>
|
<?= $this->render('show/components/perfdata.phtml') ?>
|
||||||
<?= $this->render('show/components/command.phtml') ?>
|
<?= $this->render('show/components/command.phtml') ?>
|
||||||
|
|
|
@ -6,11 +6,9 @@
|
||||||
<?= $this->render('show/components/status.phtml') ?>
|
<?= $this->render('show/components/status.phtml') ?>
|
||||||
<?= $this->render('show/components/output.phtml') ?>
|
<?= $this->render('show/components/output.phtml') ?>
|
||||||
|
|
||||||
<?= $this->render('show/components/downtime.phtml') ?>
|
|
||||||
|
|
||||||
|
|
||||||
<table class="avp">
|
<table class="avp">
|
||||||
<?= $this->render('show/components/comments.phtml') ?>
|
<?= $this->render('show/components/comments.phtml') ?>
|
||||||
|
<?= $this->render('show/components/downtime.phtml') ?>
|
||||||
<?= $this->render('show/components/flapping.phtml') ?>
|
<?= $this->render('show/components/flapping.phtml') ?>
|
||||||
<?= $this->render('show/components/perfdata.phtml') ?>
|
<?= $this->render('show/components/perfdata.phtml') ?>
|
||||||
<?= $this->render('show/components/command.phtml') ?>
|
<?= $this->render('show/components/command.phtml') ?>
|
||||||
|
|
|
@ -40,6 +40,7 @@ class DowntimeQuery extends IdoQuery
|
||||||
*/
|
*/
|
||||||
protected $columnMap = array(
|
protected $columnMap = array(
|
||||||
'downtime' => array(
|
'downtime' => array(
|
||||||
|
'downtime_objecttype_id' => 'sdo.objecttype_id',
|
||||||
'downtime_author' => 'sd.author_name',
|
'downtime_author' => 'sd.author_name',
|
||||||
'downtime_comment' => 'sd.comment_data',
|
'downtime_comment' => 'sd.comment_data',
|
||||||
'downtime_entry_time' => 'UNIX_TIMESTAMP(sd.entry_time)',
|
'downtime_entry_time' => 'UNIX_TIMESTAMP(sd.entry_time)',
|
||||||
|
@ -53,12 +54,16 @@ class DowntimeQuery extends IdoQuery
|
||||||
'downtime_triggered_by_id' => 'sd.triggered_by_id',
|
'downtime_triggered_by_id' => 'sd.triggered_by_id',
|
||||||
'downtime_internal_downtime_id' => 'sd.internal_downtime_id',
|
'downtime_internal_downtime_id' => 'sd.internal_downtime_id',
|
||||||
),
|
),
|
||||||
'objects' => array(
|
'hosts' => array(
|
||||||
'host' => 'o.name1 COLLATE latin1_general_ci',
|
'host_name' => 'ho.name1 COLLATE latin1_general_ci',
|
||||||
'host_name' => 'o.name1 COLLATE latin1_general_ci',
|
'host' => 'ho.name1 COLLATE latin1_general_ci',
|
||||||
'service' => 'o.name2 COLLATE latin1_general_ci',
|
|
||||||
'service_description' => 'o.name2 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',
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -72,17 +77,32 @@ class DowntimeQuery extends IdoQuery
|
||||||
array()
|
array()
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->joinedVirtualTables = array('downtime' => true, 'services' => true);
|
$this->baseQuery->join(
|
||||||
|
array(
|
||||||
|
'sdo' => $this->prefix . 'objects'
|
||||||
|
),
|
||||||
|
'sd.object_id = sdo.' . $this->object_id . ' AND sdo.is_active = 1'
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->joinedVirtualTables = array('downtime' => true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
protected function joinHosts()
|
||||||
* Join if host needed
|
|
||||||
*/
|
|
||||||
protected function joinObjects()
|
|
||||||
{
|
{
|
||||||
|
$this->conflictsWithVirtualTable('services');
|
||||||
$this->baseQuery->join(
|
$this->baseQuery->join(
|
||||||
array('o' => $this->prefix . 'objects'),
|
array('ho' => $this->prefix . 'objects'),
|
||||||
'sd.object_id = o.object_id AND o.is_active = 1 AND o.objecttype_id IN (1, 2)',
|
'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()
|
array()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,6 +43,7 @@ class Downtime extends DataView
|
||||||
'host_name',
|
'host_name',
|
||||||
'service',
|
'service',
|
||||||
'service_description',
|
'service_description',
|
||||||
|
'downtime_objecttype_id',
|
||||||
'downtime_author',
|
'downtime_author',
|
||||||
'downtime_comment',
|
'downtime_comment',
|
||||||
'downtime_entry_time',
|
'downtime_entry_time',
|
||||||
|
|
|
@ -44,11 +44,13 @@ abstract class AbstractObject
|
||||||
{
|
{
|
||||||
// WTF???
|
// WTF???
|
||||||
$query = Comment::fromParams(array('backend' => null), array(
|
$query = Comment::fromParams(array('backend' => null), array(
|
||||||
|
'comment_internal_id',
|
||||||
'comment_timestamp',
|
'comment_timestamp',
|
||||||
'comment_author',
|
'comment_author',
|
||||||
'comment_data',
|
'comment_data',
|
||||||
'comment_type',
|
'comment_type',
|
||||||
))->getQuery();
|
))->getQuery();
|
||||||
|
$query->where('comment_type', array('comment', 'ack'));
|
||||||
$query->where('comment_objecttype_id', $this->type);
|
$query->where('comment_objecttype_id', $this->type);
|
||||||
$this->applyObjectFilter($query);
|
$this->applyObjectFilter($query);
|
||||||
$this->comments = $query->fetchAll();
|
$this->comments = $query->fetchAll();
|
||||||
|
@ -73,6 +75,28 @@ abstract class AbstractObject
|
||||||
|
|
||||||
public function fetchDowntimes()
|
public function fetchDowntimes()
|
||||||
{
|
{
|
||||||
|
// TODO: We want to check for objecttype = 'host', not type_id = 1
|
||||||
|
|
||||||
|
// 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'
|
||||||
|
))->getQuery();
|
||||||
|
$query->where('downtime_objecttype_id', $this->type);
|
||||||
|
$this->applyObjectFilter($query);
|
||||||
|
$this->downtimes = $query->fetchAll();
|
||||||
|
return $this;
|
||||||
|
|
||||||
$this->downtimes = Downtime::fromRequest($this->request)->getQuery()->fetchAll();
|
$this->downtimes = Downtime::fromRequest($this->request)->getQuery()->fetchAll();
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,8 @@ class Host extends AbstractObject
|
||||||
->fetchHostgroups()
|
->fetchHostgroups()
|
||||||
->fetchContacts()
|
->fetchContacts()
|
||||||
->fetchContactGroups()
|
->fetchContactGroups()
|
||||||
->fetchCustomvars();
|
->fetchCustomvars()
|
||||||
|
->fetchDowntimes();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getProperties()
|
protected function getProperties()
|
||||||
|
|
|
@ -24,7 +24,8 @@ class Service extends AbstractObject
|
||||||
->fetchServicegroups()
|
->fetchServicegroups()
|
||||||
->fetchContacts()
|
->fetchContacts()
|
||||||
->fetchContactGroups()
|
->fetchContactGroups()
|
||||||
->fetchCustomvars();
|
->fetchCustomvars()
|
||||||
|
->fetchDowntimes();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function getProperties()
|
protected function getProperties()
|
||||||
|
|
Loading…
Reference in New Issue