mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 15:54:03 +02:00
commit
e9b002bdcd
@ -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'));
|
||||
|
||||
|
0
config/backends.ini.in
Normal file → Executable file
0
config/backends.ini.in
Normal file → Executable file
0
config/menu.ini
Normal file → Executable file
0
config/menu.ini
Normal file → Executable file
1
config/modules/monitoring/menu.ini
Normal file → Executable file
1
config/modules/monitoring/menu.ini
Normal file → Executable file
@ -9,4 +9,5 @@ _1 = 1
|
||||
|
||||
Hosts = "/monitoring/list/hosts"
|
||||
Services = "/monitoring/list/services"
|
||||
Downtimes = "/monitoring/list/downtimes"
|
||||
Summaries = "/monitoring/summary/group/by/hostgroup"
|
||||
|
@ -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');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -0,0 +1,159 @@
|
||||
<?= $this->tabs ?>
|
||||
|
||||
<?php
|
||||
/**
|
||||
* Create a DateTime from a string and use the util helper to
|
||||
* format it
|
||||
*
|
||||
* @param $self Reference to the current view that contains the helper.
|
||||
* @param $dateString The String that will be converted.
|
||||
* @return String The formatted string.
|
||||
*/
|
||||
function formatDateString($self,$dateString){
|
||||
$d = new DateTime($dateString);
|
||||
return $self->util()->showTime($d->getTimestamp());
|
||||
}
|
||||
$paginator = $downtimes->paginate();
|
||||
$downtimes = $downtimes->fetchAll();
|
||||
?>
|
||||
<form method="get" action="<?= $this->qUrl(
|
||||
'monitoring/list/downtimes?',
|
||||
array(
|
||||
'action' => 'downtimes'
|
||||
));
|
||||
?>">
|
||||
Sort by <?= $this->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',
|
||||
)
|
||||
) ?>
|
||||
<input type="search" name="filter" placeholder="Type to filter" />
|
||||
<button class="btn btn-small"><i class="icon-refresh"></i></button>
|
||||
</form>
|
||||
<?=
|
||||
$this->paginationControl(
|
||||
$paginator,
|
||||
null,
|
||||
array(
|
||||
'mixedPagination.phtml',
|
||||
'default'),
|
||||
array('preserve' => $this->preserve))
|
||||
?>
|
||||
|
||||
<table class="statustable action">
|
||||
<thead>
|
||||
<th> Is In Effect </th>
|
||||
<th> Object </th>
|
||||
<th> Host Name </th>
|
||||
<th> Service Name </th>
|
||||
<th> Entry Time </th>
|
||||
<th> Author </th>
|
||||
<th> Comment </th>
|
||||
<th> Start Time </th>
|
||||
<th> End Time </th>
|
||||
<th> Type </th>
|
||||
<th> Trigger Time </th>
|
||||
<th> Downtime ID </th>
|
||||
<th> Trigger ID </th>
|
||||
<th> Duration </th>
|
||||
</thead>
|
||||
<?php foreach ($downtimes as $downtime): ?>
|
||||
<tr class="<?= $downtime->downtime_is_in_effect == 0 ? 'ok' : 'warning' ?>">
|
||||
<td>
|
||||
<?= $downtime->downtime_is_in_effect == 0 ? 'False' : '<b>True</b>'; ?>
|
||||
</td>
|
||||
<td>
|
||||
<div class="img-box">
|
||||
<?php if ($downtime->object_type == 'service'): ?>
|
||||
<img title="Service" src="<?='../../img/classic/service.png'?>"/>
|
||||
<?php endif; ?>
|
||||
<?php if ($downtime->object_type == 'host'): ?>
|
||||
<img title="Host" src="<?='../../img/classic/server.png'?>"/>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<?= $downtime->host_name ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= $downtime->service_description ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= formatDateString($this,$downtime->downtime_entry_time); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= $downtime->downtime_author_name ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= $downtime->downtime_comment_data ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= formatDateString($this,$downtime->downtime_scheduled_start_time); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= formatDateString($this,$downtime->downtime_scheduled_end_time); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= $downtime->downtime_is_fixed == 1 ? 'Fixed' : 'Not Fixed' ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
$date = formatDateString($this,$downtime->downtime_trigger_time);
|
||||
echo $date != 'undef' ? $date : 'N/A';
|
||||
?>
|
||||
</td>
|
||||
<td>
|
||||
<?= $downtime->downtime_internal_downtime_id ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= $downtime->downtime_triggered_by_id == 0 ?
|
||||
'N/A' : $downtime->downtime_triggered_by_id ?>
|
||||
</td>
|
||||
<td>
|
||||
<?= $this->util()->showHourMin(intval($downtime->downtime_duration)); ?>
|
||||
</td>
|
||||
<td>
|
||||
<?php
|
||||
if (empty($downtime->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'
|
||||
)
|
||||
);
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php endforeach ?>
|
||||
</table>
|
@ -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()
|
||||
);
|
||||
}
|
||||
|
@ -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'
|
||||
);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user