parent
6b37fcf24f
commit
e817b9b790
|
@ -4,6 +4,15 @@ class Zend_View_Helper_TimeSince extends Zend_View_Helper_Abstract
|
|||
{
|
||||
public function timeSince($timestamp)
|
||||
{
|
||||
|
||||
if (!is_numeric($timestamp)) {
|
||||
$timestamp = strtotime($timestamp);
|
||||
}
|
||||
|
||||
if (!is_numeric($timestamp)) {
|
||||
return '?';
|
||||
}
|
||||
|
||||
if (! $timestamp) return '-';
|
||||
$duration = time() - $timestamp;
|
||||
$prefix = '';
|
||||
|
|
|
@ -210,6 +210,27 @@ class Monitoring_ShowController extends ModuleActionController
|
|||
->where('host_name', $this->view->host->host_name)
|
||||
->fetchAll();
|
||||
|
||||
$this->view->downtimes = $this->backend->select()
|
||||
->from(
|
||||
'downtime',
|
||||
array(
|
||||
'host_name',
|
||||
'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)
|
||||
->fetchAll();
|
||||
|
||||
$this->view->customvars = $this->backend->select()
|
||||
->from(
|
||||
'customvar',
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
|
||||
<?php if (! empty($this->comments)): ?>
|
||||
<?php if (! empty($this->comments)) { ?>
|
||||
<?
|
||||
$list = array();
|
||||
foreach ($this->comments as $comment) {
|
||||
|
@ -28,4 +28,4 @@ foreach ($this->comments as $comment) {
|
|||
|
||||
<blockquote> <?= implode('<br />', $list) ?></blockquote>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php } ?>
|
|
@ -0,0 +1,43 @@
|
|||
<?php if (!empty($this->downtimes)) { ?>
|
||||
<?php
|
||||
$list = array();
|
||||
foreach ($this->downtimes as $downtime) {
|
||||
$row = array();
|
||||
if ($downtime->downtime_is_in_effect === '1') {
|
||||
$row[] = 'Running<br />since '. $this->timeSince($downtime->downtime_actual_start_time);
|
||||
} else {
|
||||
if ($downtime->downtime_is_fixed) {
|
||||
$row[] = 'Scheduled<br />for '. $downtime->downtime_scheduled_start_time;
|
||||
} else {
|
||||
$row[] = 'Waiting';
|
||||
}
|
||||
}
|
||||
|
||||
$row[] = sprintf(
|
||||
'Triggered by %s: <em>%s</em>',
|
||||
$downtime->downtime_author_name,
|
||||
$downtime->downtime_comment_data
|
||||
);
|
||||
|
||||
$row[] = '<button type="button" data-target="command" class="btn btn-warning"'
|
||||
. ' data-command-id="29" data-command-info="'. $downtime->downtime_internal_downtime_id. '"'
|
||||
. '><i class="icon-delete"></i> Delete'
|
||||
. '</button>';
|
||||
|
||||
$list[] = '<td>'. implode('</td><td>', $row). '</td>';
|
||||
}
|
||||
?>
|
||||
<div class="information-container">
|
||||
<div class="head">
|
||||
<span>Downtimes</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<table>
|
||||
<tr>
|
||||
<?= implode('</tr><tr>', $list); ?>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
|
@ -62,6 +62,8 @@
|
|||
|
||||
<?= $this->render('show/components/comments.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/downtime.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/customvars.phtml'); ?>
|
||||
|
||||
<?php if ($this->host->host_perfdata): ?>
|
||||
|
|
|
@ -0,0 +1,98 @@
|
|||
<?php
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
/**
|
||||
* Icinga 2 Web - Head for multiple monitoring frontends
|
||||
* Copyright (C) 2013 Icinga Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||
* @author Icinga Development Team <info@icinga.org>
|
||||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
namespace Icinga\Monitoring\Backend\Ido\Query;
|
||||
|
||||
/**
|
||||
* Class DowntimeQuery
|
||||
*/
|
||||
class DowntimeQuery extends AbstractQuery
|
||||
{
|
||||
/**
|
||||
* Column map
|
||||
* @var array
|
||||
*/
|
||||
protected $columnMap = array(
|
||||
'downtime' => array(
|
||||
'downtime_type' => 'sd.downtime_type',
|
||||
'downtime_author_name' => 'sd.author_name',
|
||||
'downtime_comment_data' => 'sd.comment_data',
|
||||
'downtime_is_fixed' => 'sd.is_fixed',
|
||||
'downtime_duration' => 'sd.duration',
|
||||
'downtime_scheduled_start_time' => 'sd.scheduled_start_time',
|
||||
'downtime_scheduled_end_time' => 'sd.scheduled_end_time',
|
||||
'downtime_was_started' => 'sd.was_started',
|
||||
'downtime_actual_start_time' => 'sd.actual_start_time',
|
||||
'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_internal_downtime_id' => 'sd.internal_downtime_id'
|
||||
),
|
||||
'hosts' => array(
|
||||
'host_name' => 'ho.name1',
|
||||
),
|
||||
'services' => array(
|
||||
'service_host_name' => 'so.name1',
|
||||
'service_description' => 'so.name2',
|
||||
)
|
||||
);
|
||||
|
||||
/**
|
||||
* Join with scheduleddowntime
|
||||
*/
|
||||
protected function joinBaseTables()
|
||||
{
|
||||
$this->baseQuery = $this->db->select()->from(
|
||||
array('sd' => $this->prefix . 'scheduleddowntime'),
|
||||
array()
|
||||
);
|
||||
|
||||
$this->joinedVirtualTables = array('downtime' => true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Join if host needed
|
||||
*/
|
||||
protected function joinHosts()
|
||||
{
|
||||
$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()
|
||||
);
|
||||
}
|
||||
}
|
|
@ -82,6 +82,7 @@ class Meta
|
|||
const CMD_ACKNOWLEDGE_PROBLEM = 26;
|
||||
const CMD_REMOVE_ACKNOWLEDGEMENT = 27;
|
||||
const CMD_DELAY_NOTIFICATION = 28;
|
||||
const CMD_REMOVE_DOWNTIME = 29;
|
||||
|
||||
/**
|
||||
* Filter array for array displayed in small interfaces
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
/**
|
||||
* Icinga 2 Web - Head for multiple monitoring frontends
|
||||
* Copyright (C) 2013 Icinga Development Team
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* @copyright 2013 Icinga Development Team <info@icinga.org>
|
||||
* @author Icinga Development Team <info@icinga.org>
|
||||
*/
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
namespace Icinga\Monitoring\View;
|
||||
|
||||
/**
|
||||
* Class DowntimeView
|
||||
*/
|
||||
class DowntimeView extends MonitoringView
|
||||
{
|
||||
/**
|
||||
* Query object
|
||||
* @var mixed
|
||||
*/
|
||||
protected $query;
|
||||
|
||||
/**
|
||||
* Available columns
|
||||
* @var string[]
|
||||
*/
|
||||
protected $availableColumns = array(
|
||||
'downtime_type',
|
||||
'downtime_author_name',
|
||||
'downtime_comment_data',
|
||||
'downtime_is_fixed',
|
||||
'downtime_duration',
|
||||
'downtime_scheduled_start_time',
|
||||
'downtime_scheduled_end_time',
|
||||
'downtime_was_started',
|
||||
'downtime_actual_start_time',
|
||||
'downtime_actual_start_time_usec',
|
||||
'downtime_is_in_effect',
|
||||
'downtime_trigger_time',
|
||||
'downtime_internal_downtime_id'
|
||||
);
|
||||
|
||||
/**
|
||||
* Filters
|
||||
* @var array
|
||||
*/
|
||||
protected $specialFilters = array();
|
||||
|
||||
/**
|
||||
* Default sorting of data set
|
||||
* @var array
|
||||
*/
|
||||
protected $sortDefaults = array(
|
||||
'downtime_is_in_effect' => array(
|
||||
'default_dir' => self::SORT_DESC
|
||||
),
|
||||
'downtime_actual_start_time' => array(
|
||||
'default_dir' => self::SORT_DESC
|
||||
)
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue