Host detail view
Fix psr, adapt output for layouting, add fields to adapt original views from icinga. refs #4182
This commit is contained in:
parent
3bcef9af9b
commit
a0f96379a9
|
@ -1,14 +1,27 @@
|
|||
<?php
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
// {{{ICINGA_LICENSE_HEADER}}}
|
||||
|
||||
use Icinga\Monitoring\Backend;
|
||||
use Icinga\Web\ModuleActionController;
|
||||
use Icinga\Web\Hook;
|
||||
use Icinga\Application\Benchmark;
|
||||
|
||||
/**
|
||||
* Class Monitoring_ShowController
|
||||
*
|
||||
* Actions for show context
|
||||
*/
|
||||
class Monitoring_ShowController extends ModuleActionController
|
||||
{
|
||||
/**
|
||||
* @var Backend
|
||||
*/
|
||||
protected $backend;
|
||||
|
||||
/**
|
||||
* Initialize the controller
|
||||
*/
|
||||
public function init()
|
||||
{
|
||||
$host = $this->_getParam('host');
|
||||
|
@ -26,7 +39,7 @@ class Monitoring_ShowController extends ModuleActionController
|
|||
$this->view->service = $this->backend->fetchService($host, $service);
|
||||
}
|
||||
if ($host !== null) {
|
||||
$this->view->host = $this->backend->fetchHost($host);
|
||||
$this->view->host = $this->backend->fetchHost($host, true);
|
||||
}
|
||||
$this->view->compact = $this->_getParam('view') === 'compact';
|
||||
$this->view->tabs = $this->createTabs();
|
||||
|
@ -44,7 +57,8 @@ class Monitoring_ShowController extends ModuleActionController
|
|||
$this->view->ticket_link = preg_replace(
|
||||
'~__ID__~',
|
||||
'\$1',
|
||||
$this->view->qlink('#__ID__',
|
||||
$this->view->qlink(
|
||||
'#__ID__',
|
||||
'monitoring/show/ticket',
|
||||
$params
|
||||
)
|
||||
|
@ -54,6 +68,9 @@ class Monitoring_ShowController extends ModuleActionController
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Service overview
|
||||
*/
|
||||
public function serviceAction()
|
||||
{
|
||||
Benchmark::measure('Entered service action');
|
||||
|
@ -64,7 +81,8 @@ class Monitoring_ShowController extends ModuleActionController
|
|||
if ($grapher->hasGraph(
|
||||
$this->view->host->host_name,
|
||||
$this->view->service->service_description
|
||||
)) {
|
||||
)
|
||||
) {
|
||||
$this->view->preview_image = $grapher->getPreviewImage(
|
||||
$this->view->host->host_name,
|
||||
$this->view->service->service_description
|
||||
|
@ -73,41 +91,53 @@ class Monitoring_ShowController extends ModuleActionController
|
|||
}
|
||||
|
||||
$this->view->contacts = $this->backend->select()
|
||||
->from('contact', array(
|
||||
->from(
|
||||
'contact',
|
||||
array(
|
||||
'contact_name',
|
||||
'contact_alias',
|
||||
'contact_email',
|
||||
'contact_pager',
|
||||
))
|
||||
)
|
||||
)
|
||||
->where('service_host_name', $this->view->host->host_name)
|
||||
->where('service_description', $this->view->service->service_description)
|
||||
->fetchAll();
|
||||
|
||||
$this->view->contactgroups = $this->backend->select()
|
||||
->from('contactgroup', array(
|
||||
->from(
|
||||
'contactgroup',
|
||||
array(
|
||||
'contactgroup_name',
|
||||
'contactgroup_alias',
|
||||
))
|
||||
)
|
||||
)
|
||||
->where('service_host_name', $this->view->host->host_name)
|
||||
->where('service_description', $this->view->service->service_description)
|
||||
->fetchAll();
|
||||
|
||||
$this->view->comments = $this->backend->select()
|
||||
->from('comment', array(
|
||||
->from(
|
||||
'comment',
|
||||
array(
|
||||
'comment_timestamp',
|
||||
'comment_author',
|
||||
'comment_data',
|
||||
'comment_type',
|
||||
))
|
||||
)
|
||||
)
|
||||
->where('service_host_name', $this->view->host->host_name)
|
||||
->where('service_description', $this->view->service->service_description)
|
||||
->fetchAll();
|
||||
|
||||
$this->view->customvars = $this->backend->select()
|
||||
->from('customvar', array(
|
||||
->from(
|
||||
'customvar',
|
||||
array(
|
||||
'varname',
|
||||
'varvalue'
|
||||
))
|
||||
)
|
||||
)
|
||||
->where('varname', '-*PW*,-*PASS*')
|
||||
->where('host_name', $this->view->host->host_name)
|
||||
->where('service_description', $this->view->service->service_description)
|
||||
|
@ -116,6 +146,9 @@ class Monitoring_ShowController extends ModuleActionController
|
|||
Benchmark::measure('Service action done');
|
||||
}
|
||||
|
||||
/**
|
||||
* Host overview
|
||||
*/
|
||||
public function hostAction()
|
||||
{
|
||||
$this->view->active = 'host';
|
||||
|
@ -130,59 +163,79 @@ class Monitoring_ShowController extends ModuleActionController
|
|||
}
|
||||
|
||||
$this->view->hostgroups = $this->backend->select()
|
||||
->from('hostgroup', array(
|
||||
->from(
|
||||
'hostgroup',
|
||||
array(
|
||||
'hostgroup_name',
|
||||
'hostgroup_alias'
|
||||
))
|
||||
)
|
||||
)
|
||||
->where('host_name', $this->view->host->host_name)
|
||||
->fetchPairs();
|
||||
|
||||
$this->view->contacts = $this->backend->select()
|
||||
->from('contact', array(
|
||||
->from(
|
||||
'contact',
|
||||
array(
|
||||
'contact_name',
|
||||
'contact_alias',
|
||||
'contact_email',
|
||||
'contact_pager',
|
||||
))
|
||||
)
|
||||
)
|
||||
->where('host_name', $this->view->host->host_name)
|
||||
->fetchAll();
|
||||
|
||||
$this->view->contactgroups = $this->backend->select()
|
||||
->from('contactgroup', array(
|
||||
->from(
|
||||
'contactgroup',
|
||||
array(
|
||||
'contactgroup_name',
|
||||
'contactgroup_alias',
|
||||
))
|
||||
)
|
||||
)
|
||||
->where('host_name', $this->view->host->host_name)
|
||||
->fetchAll();
|
||||
|
||||
$this->view->comments = $this->backend->select()
|
||||
->from('comment', array(
|
||||
->from(
|
||||
'comment',
|
||||
array(
|
||||
'comment_timestamp',
|
||||
'comment_author',
|
||||
'comment_data',
|
||||
'comment_type',
|
||||
))
|
||||
)
|
||||
)
|
||||
->where('host_name', $this->view->host->host_name)
|
||||
->fetchAll();
|
||||
|
||||
$this->view->customvars = $this->backend->select()
|
||||
->from('customvar', array(
|
||||
->from(
|
||||
'customvar',
|
||||
array(
|
||||
'varname',
|
||||
'varvalue'
|
||||
))
|
||||
)
|
||||
)
|
||||
->where('varname', '-*PW*,-*PASS*')
|
||||
->where('host_name', $this->view->host->host_name)
|
||||
->where('object_type', 'host')
|
||||
->fetchPairs();
|
||||
}
|
||||
|
||||
/**
|
||||
* History entries for objects
|
||||
*/
|
||||
public function historyAction()
|
||||
{
|
||||
if ($this->view->host) {
|
||||
$this->view->tabs->activate('history')->enableSpecialActions();
|
||||
}
|
||||
$this->view->history = $this->backend->select()
|
||||
->from('eventHistory', array(
|
||||
->from(
|
||||
'eventHistory',
|
||||
array(
|
||||
'object_type',
|
||||
'host_name',
|
||||
'service_description',
|
||||
|
@ -192,7 +245,8 @@ class Monitoring_ShowController extends ModuleActionController
|
|||
'max_attempts',
|
||||
'output',
|
||||
'type'
|
||||
))->applyRequest($this->_request);
|
||||
)
|
||||
)->applyRequest($this->_request);
|
||||
|
||||
|
||||
$this->view->preserve = $this->view->history->getAppliedFilter()->toParams();
|
||||
|
@ -205,15 +259,26 @@ class Monitoring_ShowController extends ModuleActionController
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Service overview
|
||||
*/
|
||||
public function servicesAction()
|
||||
{
|
||||
// Ugly and slow:
|
||||
$this->view->services = $this->view->action('services', 'list', 'monitoring', array(
|
||||
$this->view->services = $this->view->action(
|
||||
'services',
|
||||
'list',
|
||||
'monitoring',
|
||||
array(
|
||||
'host_name' => $this->view->host->host_name,
|
||||
//'sort', 'service_description'
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ticets actions
|
||||
*/
|
||||
public function ticketAction()
|
||||
{
|
||||
$this->view->tabs->activate('ticket')->enableSpecialActions();
|
||||
|
@ -222,16 +287,25 @@ class Monitoring_ShowController extends ModuleActionController
|
|||
if (Hook::has('ticket')) {
|
||||
$ticketModule = 'rt';
|
||||
$this->render();
|
||||
$this->_forward('ticket', 'show', $ticketModule, array(
|
||||
$this->_forward(
|
||||
'ticket',
|
||||
'show',
|
||||
$ticketModule,
|
||||
array(
|
||||
'id' => $id
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Creating tabs for this controller
|
||||
* @return \Icinga\Web\Widget\AbstractWidget
|
||||
*/
|
||||
protected function createTabs()
|
||||
{
|
||||
$tabs = $this->widget('tabs');
|
||||
if ( ! $this->view->host) {
|
||||
if (!$this->view->host) {
|
||||
return $tabs;
|
||||
}
|
||||
$params = array(
|
||||
|
@ -246,48 +320,63 @@ class Monitoring_ShowController extends ModuleActionController
|
|||
} else {
|
||||
$hostParams = $params;
|
||||
}
|
||||
$tabs->add('host', array(
|
||||
$tabs->add(
|
||||
'host',
|
||||
array(
|
||||
'title' => 'Host',
|
||||
'icon' => 'img/classic/server.png',
|
||||
'url' => 'monitoring/show/host',
|
||||
'urlParams' => $hostParams,
|
||||
));
|
||||
$tabs->add('services', array(
|
||||
)
|
||||
);
|
||||
$tabs->add(
|
||||
'services',
|
||||
array(
|
||||
'title' => 'Services',
|
||||
'icon' => 'img/classic/service.png',
|
||||
'url' => 'monitoring/show/services',
|
||||
'urlParams' => $params,
|
||||
));
|
||||
)
|
||||
);
|
||||
if (isset($params['service'])) {
|
||||
$tabs->add('service', array(
|
||||
$tabs->add(
|
||||
'service',
|
||||
array(
|
||||
'title' => 'Service',
|
||||
'icon' => 'img/classic/service.png',
|
||||
'url' => 'monitoring/show/service',
|
||||
'urlParams' => $params,
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
$tabs->add('history', array(
|
||||
$tabs->add(
|
||||
'history',
|
||||
array(
|
||||
'title' => 'History',
|
||||
'icon' => 'img/classic/history.gif',
|
||||
'url' => 'monitoring/show/history',
|
||||
'urlParams' => $params,
|
||||
));
|
||||
)
|
||||
);
|
||||
if ($this->action_name === 'ticket') {
|
||||
$tabs->add('ticket', array(
|
||||
$tabs->add(
|
||||
'ticket',
|
||||
array(
|
||||
'title' => 'Ticket',
|
||||
'icon' => 'img/classic/ticket.gif',
|
||||
'url' => 'monitoring/show/ticket',
|
||||
'urlParams' => $params + array('ticket' => $this->_getParam('ticket')),
|
||||
));
|
||||
)
|
||||
);
|
||||
}
|
||||
/*
|
||||
/*
|
||||
$tabs->add('contacts', array(
|
||||
'title' => 'Contacts',
|
||||
'icon' => 'img/classic/customer.png',
|
||||
'url' => 'monitoring/detail/contacts',
|
||||
'urlParams' => $params,
|
||||
));
|
||||
*/
|
||||
*/
|
||||
// TODO: Inventory 'img/classic/facts.gif'
|
||||
// Ticket 'img/classic/ticket.gif'
|
||||
// Customer 'img/classic/customer.png'
|
||||
|
|
|
@ -21,5 +21,11 @@ foreach ($this->comments as $comment) {
|
|||
);
|
||||
}
|
||||
?>
|
||||
<b>Comments:</b><blockquote> <?= implode('<br />', $list) ?></blockquote>
|
||||
<div class="information-container">
|
||||
<div class="head">
|
||||
<span>Comments</span>
|
||||
</div>
|
||||
|
||||
<blockquote> <?= implode('<br />', $list) ?></blockquote>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
|
|
@ -1,24 +1,33 @@
|
|||
<?php if (! empty($this->contacts)): ?>
|
||||
<?
|
||||
$list = array();
|
||||
foreach ($this->contacts as $contact) {
|
||||
$list[] = $this->qlink($contact->contact_alias, 'monitoring/show/contact', array(
|
||||
<?php
|
||||
if (!empty($this->contacts)) {
|
||||
$contactList = array();
|
||||
foreach ($this->contacts as $contact) {
|
||||
$contactList[] = $this->qlink(
|
||||
$contact->contact_alias,
|
||||
'monitoring/show/contact',
|
||||
array(
|
||||
'contact_name' => $contact->contact_name
|
||||
));
|
||||
}
|
||||
?>
|
||||
<b>Contacts:</b> <?= implode(', ', $list) ?><br />
|
||||
<?php endif; ?>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
<?php if (! empty($this->contactgroups)): ?>
|
||||
<?
|
||||
$list = array();
|
||||
foreach ($this->contactgroups as $contactgroup) {
|
||||
$list[] = $this->qlink($contactgroup->contactgroup_alias, 'monitoring/show/contactgroup', array(
|
||||
echo '<strong>Contacts:</strong> ';
|
||||
echo implode(', ', $contactList);
|
||||
}
|
||||
|
||||
if (!empty($this->contactgroups)) {
|
||||
$contactGroupList = array();
|
||||
foreach ($this->contactgroups as $contactgroup) {
|
||||
$contactGroupList[] = $this->qlink(
|
||||
$contactgroup->contactgroup_alias,
|
||||
'monitoring/show/contactgroup',
|
||||
array(
|
||||
'contactgroup_name' => $contactgroup->contactgroup_name
|
||||
));
|
||||
}
|
||||
?>
|
||||
<b>Contactgroups:</b> <?= implode(', ', $list) ?><br />
|
||||
<?php endif; ?>
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
echo '<strong>Contactgroups:</strong> ';
|
||||
echo implode(', ', $contactGroupList);
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,22 @@
|
|||
<?php if (isset($this->customvars) && count($this->customvars)) { ?>
|
||||
<div class="information-container">
|
||||
<div class="head">
|
||||
<span>Customvariables</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Value</th>
|
||||
</tr>
|
||||
<?php foreach ($this->customvars as $name => $value) { ?>
|
||||
<tr>
|
||||
<td><?= $this->escape($name) ?></td>
|
||||
<td><?= $this->escape($value) ?></td>
|
||||
</tr>
|
||||
<?php } ?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
|
@ -1,30 +1,72 @@
|
|||
<?php
|
||||
$showService = isset($this->service) && $this->tabs->getActiveName() !== 'host';
|
||||
/** @var boolean $showService */
|
||||
$showService = false;
|
||||
if (isset($this->service) && $this->tabs->getActiveName() !== 'host') {
|
||||
$showService = true;
|
||||
}
|
||||
|
||||
/** @var boolean $inlineCommands */
|
||||
$inlineCommands = true;
|
||||
if ($this->tabs->getActiveName() === 'history') {
|
||||
$inlineCommands = false;
|
||||
}
|
||||
|
||||
if (!$this->compact) {
|
||||
echo $this->tabs;
|
||||
}
|
||||
?>
|
||||
<?php if (! $this->compact): ?>
|
||||
<?= $this->tabs ?>
|
||||
<?php endif; ?>
|
||||
<table style="margin-bottom: 1em">
|
||||
<div class="information-container">
|
||||
<?php if ($inlineCommands === true) { ?>
|
||||
<div class="pull-right">
|
||||
<div>
|
||||
<button type="button" class="btn btn-primary">
|
||||
<span>Check now</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="container-spacer">
|
||||
<button type="button" class="btn btn-danger">
|
||||
<span>Acknowledge</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<?php } ?>
|
||||
|
||||
<table>
|
||||
<tr class="<?= $this->monitoringState($this->host, 'host') ?><?= $this->host->host_handled ? ' handled' : '' ?>">
|
||||
<td><b><?= $this->escape($this->host->host_name) ?><?
|
||||
if ($this->host->host_address && $this->host->host_address !== $this->host->host_name): ?>
|
||||
(<?= $this->escape($this->host->host_address) ?>)
|
||||
<?php endif; ?>
|
||||
</b></td>
|
||||
<td class="state"<?= $showService ? '' : ' rowspan="2"' ?>>
|
||||
<?= $this->util()->getHostStateName($this->host->host_state); ?><br />
|
||||
since <?= $this->timeSince($this->host->host_last_state_change) ?>
|
||||
<td>
|
||||
<strong>
|
||||
<?= $this->escape($this->host->host_name); ?>
|
||||
<?php if ($this->host->host_address && $this->host->host_address !== $this->host->host_name) { ?>
|
||||
(<?= $this->escape($this->host->host_address); ?>)
|
||||
<?php } ?>
|
||||
</strong>
|
||||
|
||||
<?php if (isset($this->host->host_alias) && $this->host->host_alias !== $this->host->host_name) { ?>
|
||||
<br />
|
||||
<sup>(<?= $this->host->host_alias; ?>)</sup>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td class="state"<?= $showService ? '' : ' rowspan="2"'; ?>>
|
||||
<?= $this->util()->getHostStateName($this->host->host_state); ?>
|
||||
since <?= $this->timeSince($this->host->host_last_state_change); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php if ($showService): ?>
|
||||
<?php if ($showService === true) { ?>
|
||||
<tr class="<?= $this->monitoringState($this->service, 'service'); ?><?= $this->service->service_handled ? ' handled' : '' ?>">
|
||||
<td><b>Service: <?= $this->escape($this->service->service_description) ?></b></td>
|
||||
<td>
|
||||
<strong>
|
||||
Service: <?= $this->escape($this->service->service_description); ?>
|
||||
</strong>
|
||||
</td>
|
||||
<td class="state">
|
||||
<?= $this->util()->getServiceStateName($this->service->service_state); ?><br />
|
||||
since <?= $this->timeSince($this->service->service_last_state_change) ?>
|
||||
<?= $this->util()->getServiceStateName($this->service->service_state); ?>
|
||||
since <?= $this->timeSince($this->service->service_last_state_change); ?>
|
||||
</td>
|
||||
</tr>
|
||||
<?php else: ?>
|
||||
<tr><td><b>Host state</b></td></tr>
|
||||
<?php endif; ?>
|
||||
</table>
|
||||
<?php } else { ?>
|
||||
<?php // BYPASS ?>
|
||||
<?php } ?>
|
||||
</table>
|
||||
|
||||
<div class="clearfix"></div>
|
||||
</div>
|
|
@ -1,40 +1,78 @@
|
|||
<?= $this->partial('show/header.phtml', array(
|
||||
<?php
|
||||
$hostgroupLinkList = array();
|
||||
if (!empty($this->hostgroups)) {
|
||||
foreach ($this->hostgroups as $name => $alias) {
|
||||
$hostgroupLinkList[] = $this->qlink(
|
||||
$alias,
|
||||
'monitoring/list/services',
|
||||
array(
|
||||
'hostgroups' => $name
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
var_dump($this->host);
|
||||
?>
|
||||
<?=
|
||||
$this->partial(
|
||||
'show/header.phtml',
|
||||
array(
|
||||
'host' => $this->host,
|
||||
'service' => $this->service,
|
||||
'tabs' => $this->tabs,
|
||||
'compact' => $this->compact
|
||||
)); ?>
|
||||
<?= $this->expandable(
|
||||
$this->pluginOutput($this->host->host_output),
|
||||
$this->pluginOutput($this->host->host_long_output)
|
||||
) ?>
|
||||
<?= $this->expandable(
|
||||
'<b>Command:</b> ' . array_shift(preg_split('|!|', $this->host->host_check_command)),
|
||||
$this->commandArguments($this->host->host_check_command)
|
||||
) ?>
|
||||
<?php if (! empty($this->hostgroups)): ?>
|
||||
<?
|
||||
$list = array();
|
||||
foreach ($this->hostgroups as $name => $alias) {
|
||||
$list[] = $this->qlink($alias, 'monitoring/list/services', array(
|
||||
'hostgroups' => $name
|
||||
));
|
||||
}
|
||||
)
|
||||
);
|
||||
?>
|
||||
<b>Hostgroups:</b> <?= implode(', ', $list) ?><br />
|
||||
<?php endif; ?>
|
||||
<?= $this->render('show/components/contacts.phtml') ?>
|
||||
<?= $this->render('show/components/comments.phtml') ?>
|
||||
|
||||
<?php foreach ($this->customvars as $name => $value): ?>
|
||||
<b><?= $this->escape($name) ?>:</b> <?= $this->escape($value) ?><br />
|
||||
<?php endforeach; ?>
|
||||
<?php if ($this->host->host_perfdata): ?>
|
||||
<?= $this->expandable(
|
||||
'<b>Performance data</b>',
|
||||
$this->perfdata($this->host->host_perfdata),
|
||||
array('collapsed' => false)
|
||||
) ?>
|
||||
<?php endif; ?>
|
||||
<?= $this->preview_image ?>
|
||||
|
||||
<div class="information-container">
|
||||
<div class="head">
|
||||
<span>Plugin output</span>
|
||||
</div>
|
||||
<div>
|
||||
<?= $this->pluginOutput($this->host->host_output); ?>
|
||||
<?= $this->pluginOutput($this->host->host_long_output); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="information-container">
|
||||
<div class="head">
|
||||
<span>Command</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<strong>Command:</strong>
|
||||
<?= array_shift(explode('!', $this->host->host_check_command, 2)); ?>
|
||||
<?= $this->commandArguments($this->host->host_check_command); ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="information-container">
|
||||
<div class="head">
|
||||
<span>Groups and Contacts</span>
|
||||
</div>
|
||||
<?php if (count($hostgroupLinkList)) { ?>
|
||||
<strong>Hostgroups:</strong>
|
||||
<?= implode(' ', $hostgroupLinkList); ?>
|
||||
<?php } ?>
|
||||
|
||||
<?= $this->render('show/components/contacts.phtml') ?>
|
||||
</div>
|
||||
|
||||
<?= $this->render('show/components/comments.phtml'); ?>
|
||||
|
||||
<?= $this->render('show/components/customvars.phtml'); ?>
|
||||
|
||||
<?php if ($this->host->host_perfdata): ?>
|
||||
<div class="information-container">
|
||||
<div class="head">
|
||||
<span>Perfdata</span>
|
||||
</div>
|
||||
<div>
|
||||
<?= $this->perfdata($this->host->host_perfdata); ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
|
@ -46,7 +46,7 @@ class AbstractBackend implements DatasourceInterface
|
|||
public function from($virtual_table, $fields = array())
|
||||
{
|
||||
$classname = $this->tableToClassName($virtual_table);
|
||||
if (! class_exists($classname)) {
|
||||
if (!class_exists($classname)) {
|
||||
throw new ProgrammingError(
|
||||
sprintf(
|
||||
'Asking for invalid virtual table %s',
|
||||
|
@ -84,12 +84,10 @@ class AbstractBackend implements DatasourceInterface
|
|||
}
|
||||
|
||||
|
||||
|
||||
// UGLY temporary host fetch
|
||||
public function fetchHost($host)
|
||||
public function fetchHost($host, $fetchAll = false)
|
||||
{
|
||||
$select = $this->select()
|
||||
->from('status', array(
|
||||
$fields = array(
|
||||
'host_name',
|
||||
'host_address',
|
||||
'host_state',
|
||||
|
@ -101,45 +99,72 @@ class AbstractBackend implements DatasourceInterface
|
|||
'host_alias',
|
||||
'host_output',
|
||||
'host_long_output',
|
||||
'host_perfdata',
|
||||
))
|
||||
'host_perfdata'
|
||||
);
|
||||
|
||||
$fields = array_merge(
|
||||
$fields,
|
||||
array(
|
||||
'current_check_attempt',
|
||||
'max_check_attempts',
|
||||
'attempt',
|
||||
'last_check',
|
||||
'next_check',
|
||||
'check_type',
|
||||
'last_state_change',
|
||||
'last_hard_state_change',
|
||||
'last_hard_state',
|
||||
'last_time_up',
|
||||
'last_time_down',
|
||||
'last_time_unreachable',
|
||||
'state_type',
|
||||
'last_notification',
|
||||
'next_notification',
|
||||
'no_more_notifications',
|
||||
'notifications_enabled',
|
||||
'problem_has_been_acknowledged',
|
||||
'acknowledgement_type',
|
||||
'current_notification_number',
|
||||
'passive_checks_enabled',
|
||||
'active_checks_enabled',
|
||||
'event_handler_enabled',
|
||||
'flap_detection_enabled',
|
||||
'is_flapping',
|
||||
'percent_state_change',
|
||||
'latency',
|
||||
'execution_time',
|
||||
'scheduled_downtime_depth',
|
||||
'failure_prediction_enabled',
|
||||
'process_performance_data',
|
||||
'obsess_over_host',
|
||||
'modified_host_attributes',
|
||||
'event_handler',
|
||||
'check_command',
|
||||
'normal_check_interval',
|
||||
'retry_check_interval',
|
||||
'check_timeperiod_object_id'
|
||||
)
|
||||
);
|
||||
|
||||
$select = $this->select()
|
||||
->from('status', $fields)
|
||||
->where('host_name', $host);
|
||||
return $select->fetchRow();
|
||||
$object = \Icinga\Objects\Host::fromBackend(
|
||||
$this->select()
|
||||
->from('status', array(
|
||||
'host_name',
|
||||
'host_address',
|
||||
'host_state',
|
||||
'host_handled',
|
||||
'host_in_downtime',
|
||||
'host_acknowledged',
|
||||
'host_check_command',
|
||||
'host_last_state_change',
|
||||
'host_alias',
|
||||
'host_output',
|
||||
'host_long_output',
|
||||
'host_perfdata',
|
||||
))
|
||||
->where('host_name', $host)
|
||||
->fetchRow()
|
||||
);
|
||||
// $object->customvars = $this->fetchCustomvars($host);
|
||||
return $object;
|
||||
}
|
||||
|
||||
// UGLY temporary service fetch
|
||||
public function fetchService($host, $service)
|
||||
{
|
||||
Benchmark::measure('Preparing service select');
|
||||
Benchmark::measure('Preparing service select');
|
||||
$select = $this->select()
|
||||
->from('status', array(
|
||||
->from(
|
||||
'status',
|
||||
array(
|
||||
|
||||
'host_name',
|
||||
'host_state',
|
||||
'host_check_command',
|
||||
'host_last_state_change',
|
||||
|
||||
'service_description',
|
||||
'service_state',
|
||||
'service_acknowledged',
|
||||
|
@ -155,22 +180,24 @@ Benchmark::measure('Preparing service select');
|
|||
'service_check_execution_time',
|
||||
'service_check_latency',
|
||||
// 'service_
|
||||
))
|
||||
)
|
||||
)
|
||||
->where('host_name', $host)
|
||||
->where('service_description', $service);
|
||||
// Benchmark::measure((string) $select->getQuery());
|
||||
Benchmark::measure('Prepared service select');
|
||||
Benchmark::measure('Prepared service select');
|
||||
|
||||
return $select->fetchRow();
|
||||
$object = \Icinga\Objects\Service::fromBackend(
|
||||
$this->select()
|
||||
->from('status', array(
|
||||
->from(
|
||||
'status',
|
||||
array(
|
||||
|
||||
'host_name',
|
||||
'host_state',
|
||||
'host_check_command',
|
||||
'host_last_state_change',
|
||||
|
||||
'service_description',
|
||||
'service_state',
|
||||
'service_acknowledged',
|
||||
|
@ -186,7 +213,8 @@ Benchmark::measure('Prepared service select');
|
|||
'service_check_execution_time',
|
||||
'service_check_latency',
|
||||
// 'service_
|
||||
))
|
||||
)
|
||||
)
|
||||
->where('host_name', $host)
|
||||
->where('service_description', $service)
|
||||
->fetchRow()
|
||||
|
|
|
@ -28,6 +28,46 @@ class StatusQuery extends AbstractQuery
|
|||
'host_accepts_passive_checks' => 'hs.passive_checks_enabled',
|
||||
'host_last_state_change' => 'UNIX_TIMESTAMP(hs.last_state_change)',
|
||||
'host_check_command' => 'hs.check_command',
|
||||
|
||||
'current_check_attempt' => 'hs.current_check_attempt',
|
||||
'max_check_attempts' => 'hs.max_check_attempts',
|
||||
'attempt' => 'CONCAT(hs.current_check_attempt, "/", hs.max_check_attempts)',
|
||||
'last_check' => 'hs.last_check',
|
||||
'next_check' => 'hs.next_check',
|
||||
'check_type' => 'hs.check_type',
|
||||
'last_state_change' => 'hs.last_state_change',
|
||||
'last_hard_state_change' => 'hs.last_hard_state_change',
|
||||
'last_hard_state' => 'hs.last_hard_state',
|
||||
'last_time_up' => 'hs.last_time_up',
|
||||
'last_time_down' => 'hs.last_time_down',
|
||||
'last_time_unreachable' => 'hs.last_time_unreachable',
|
||||
'state_type' => 'hs.state_type',
|
||||
'last_notification' => 'hs.last_notification',
|
||||
'next_notification' => 'hs.next_notification',
|
||||
'no_more_notifications' => 'hs.no_more_notifications',
|
||||
'notifications_enabled' => 'hs.notifications_enabled',
|
||||
'problem_has_been_acknowledged' => 'hs.problem_has_been_acknowledged',
|
||||
'acknowledgement_type' => 'hs.acknowledgement_type',
|
||||
'current_notification_number' => 'hs.current_notification_number',
|
||||
'passive_checks_enabled' => 'hs.passive_checks_enabled',
|
||||
'active_checks_enabled' => 'hs.active_checks_enabled',
|
||||
'event_handler_enabled' => 'hs.event_handler_enabled',
|
||||
'flap_detection_enabled' => 'hs.flap_detection_enabled',
|
||||
'is_flapping' => 'hs.is_flapping',
|
||||
'percent_state_change' => 'hs.percent_state_change',
|
||||
'latency' => 'hs.latency',
|
||||
'execution_time' => 'hs.execution_time',
|
||||
'scheduled_downtime_depth' => 'hs.scheduled_downtime_depth',
|
||||
'failure_prediction_enabled' => 'hs.failure_prediction_enabled',
|
||||
'process_performance_data' => 'hs.process_performance_data',
|
||||
'obsess_over_host' => 'hs.obsess_over_host',
|
||||
'modified_host_attributes' => 'hs.modified_host_attributes',
|
||||
'event_handler' => 'hs.event_handler',
|
||||
'check_command' => 'hs.check_command',
|
||||
'normal_check_interval' => 'hs.normal_check_interval',
|
||||
'retry_check_interval' => 'hs.retry_check_interval',
|
||||
'check_timeperiod_object_id' => 'hs.check_timeperiod_object_id',
|
||||
|
||||
'host_problems' => 'CASE WHEN hs.current_state = 0 THEN 0 ELSE 1 END',
|
||||
'host_severity' => 'CASE WHEN hs.current_state = 0
|
||||
THEN
|
||||
|
@ -129,10 +169,12 @@ class StatusQuery extends AbstractQuery
|
|||
END',
|
||||
)
|
||||
);
|
||||
public function group($col)
|
||||
{
|
||||
|
||||
public function group($col)
|
||||
{
|
||||
$this->baseQuery->group($col);
|
||||
}
|
||||
}
|
||||
|
||||
protected function getDefaultColumns()
|
||||
{
|
||||
return $this->columnMap['hosts'];
|
||||
|
@ -228,7 +270,7 @@ public function group($col)
|
|||
array()
|
||||
)->join(
|
||||
array('hgo' => $this->prefix . 'objects'),
|
||||
'hgo.' . $this->object_id. ' = hg.hostgroup_object_id'
|
||||
'hgo.' . $this->object_id . ' = hg.hostgroup_object_id'
|
||||
. ' AND hgo.is_active = 1',
|
||||
array()
|
||||
);
|
||||
|
@ -248,7 +290,7 @@ public function group($col)
|
|||
array()
|
||||
)->join(
|
||||
array('hgo' => $this->prefix . 'objects'),
|
||||
'hgo.' . $this->object_id. ' = hg.' . $this->hostgroup_id
|
||||
'hgo.' . $this->object_id . ' = hg.' . $this->hostgroup_id
|
||||
. ' AND hgo.is_active = 1',
|
||||
array()
|
||||
);
|
||||
|
|
|
@ -178,3 +178,4 @@ body {
|
|||
@import 'dataviews';
|
||||
@import 'components/layouts';
|
||||
@import 'components/tables';
|
||||
@import 'components/details';
|
||||
|
|
|
@ -85,3 +85,23 @@ font-size: 12px;
|
|||
font-weight:bold;
|
||||
}
|
||||
}
|
||||
|
||||
.information-container {
|
||||
margin: 0 0 5px 0;
|
||||
|
||||
border: 1px #fa4600 solid;
|
||||
padding: 5px;
|
||||
|
||||
.head {
|
||||
top: -5px;
|
||||
left: -5px;
|
||||
position: relative;
|
||||
display: table-cell;
|
||||
background-color: yellow;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.container-spacer {
|
||||
margin: 10px 0 0 0;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue