Host detail view

Fix psr, adapt output for layouting, add fields to adapt original
views from icinga.

refs #4182
This commit is contained in:
Marius Hein 2013-07-02 16:00:41 +02:00
parent 3bcef9af9b
commit a0f96379a9
10 changed files with 658 additions and 361 deletions

View File

@ -1,14 +1,27 @@
<?php <?php
// {{{ICINGA_LICENSE_HEADER}}}
// {{{ICINGA_LICENSE_HEADER}}}
use Icinga\Monitoring\Backend; use Icinga\Monitoring\Backend;
use Icinga\Web\ModuleActionController; use Icinga\Web\ModuleActionController;
use Icinga\Web\Hook; use Icinga\Web\Hook;
use Icinga\Application\Benchmark; use Icinga\Application\Benchmark;
/**
* Class Monitoring_ShowController
*
* Actions for show context
*/
class Monitoring_ShowController extends ModuleActionController class Monitoring_ShowController extends ModuleActionController
{ {
/**
* @var Backend
*/
protected $backend; protected $backend;
/**
* Initialize the controller
*/
public function init() public function init()
{ {
$host = $this->_getParam('host'); $host = $this->_getParam('host');
@ -26,7 +39,7 @@ class Monitoring_ShowController extends ModuleActionController
$this->view->service = $this->backend->fetchService($host, $service); $this->view->service = $this->backend->fetchService($host, $service);
} }
if ($host !== null) { 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->compact = $this->_getParam('view') === 'compact';
$this->view->tabs = $this->createTabs(); $this->view->tabs = $this->createTabs();
@ -44,7 +57,8 @@ class Monitoring_ShowController extends ModuleActionController
$this->view->ticket_link = preg_replace( $this->view->ticket_link = preg_replace(
'~__ID__~', '~__ID__~',
'\$1', '\$1',
$this->view->qlink('#__ID__', $this->view->qlink(
'#__ID__',
'monitoring/show/ticket', 'monitoring/show/ticket',
$params $params
) )
@ -54,6 +68,9 @@ class Monitoring_ShowController extends ModuleActionController
} }
} }
/**
* Service overview
*/
public function serviceAction() public function serviceAction()
{ {
Benchmark::measure('Entered service action'); Benchmark::measure('Entered service action');
@ -64,7 +81,8 @@ class Monitoring_ShowController extends ModuleActionController
if ($grapher->hasGraph( if ($grapher->hasGraph(
$this->view->host->host_name, $this->view->host->host_name,
$this->view->service->service_description $this->view->service->service_description
)) { )
) {
$this->view->preview_image = $grapher->getPreviewImage( $this->view->preview_image = $grapher->getPreviewImage(
$this->view->host->host_name, $this->view->host->host_name,
$this->view->service->service_description $this->view->service->service_description
@ -73,41 +91,53 @@ class Monitoring_ShowController extends ModuleActionController
} }
$this->view->contacts = $this->backend->select() $this->view->contacts = $this->backend->select()
->from('contact', array( ->from(
'contact',
array(
'contact_name', 'contact_name',
'contact_alias', 'contact_alias',
'contact_email', 'contact_email',
'contact_pager', 'contact_pager',
)) )
)
->where('service_host_name', $this->view->host->host_name) ->where('service_host_name', $this->view->host->host_name)
->where('service_description', $this->view->service->service_description) ->where('service_description', $this->view->service->service_description)
->fetchAll(); ->fetchAll();
$this->view->contactgroups = $this->backend->select() $this->view->contactgroups = $this->backend->select()
->from('contactgroup', array( ->from(
'contactgroup',
array(
'contactgroup_name', 'contactgroup_name',
'contactgroup_alias', 'contactgroup_alias',
)) )
)
->where('service_host_name', $this->view->host->host_name) ->where('service_host_name', $this->view->host->host_name)
->where('service_description', $this->view->service->service_description) ->where('service_description', $this->view->service->service_description)
->fetchAll(); ->fetchAll();
$this->view->comments = $this->backend->select() $this->view->comments = $this->backend->select()
->from('comment', array( ->from(
'comment',
array(
'comment_timestamp', 'comment_timestamp',
'comment_author', 'comment_author',
'comment_data', 'comment_data',
'comment_type', 'comment_type',
)) )
)
->where('service_host_name', $this->view->host->host_name) ->where('service_host_name', $this->view->host->host_name)
->where('service_description', $this->view->service->service_description) ->where('service_description', $this->view->service->service_description)
->fetchAll(); ->fetchAll();
$this->view->customvars = $this->backend->select() $this->view->customvars = $this->backend->select()
->from('customvar', array( ->from(
'customvar',
array(
'varname', 'varname',
'varvalue' 'varvalue'
)) )
)
->where('varname', '-*PW*,-*PASS*') ->where('varname', '-*PW*,-*PASS*')
->where('host_name', $this->view->host->host_name) ->where('host_name', $this->view->host->host_name)
->where('service_description', $this->view->service->service_description) ->where('service_description', $this->view->service->service_description)
@ -116,6 +146,9 @@ class Monitoring_ShowController extends ModuleActionController
Benchmark::measure('Service action done'); Benchmark::measure('Service action done');
} }
/**
* Host overview
*/
public function hostAction() public function hostAction()
{ {
$this->view->active = 'host'; $this->view->active = 'host';
@ -130,59 +163,79 @@ class Monitoring_ShowController extends ModuleActionController
} }
$this->view->hostgroups = $this->backend->select() $this->view->hostgroups = $this->backend->select()
->from('hostgroup', array( ->from(
'hostgroup',
array(
'hostgroup_name', 'hostgroup_name',
'hostgroup_alias' 'hostgroup_alias'
)) )
)
->where('host_name', $this->view->host->host_name) ->where('host_name', $this->view->host->host_name)
->fetchPairs(); ->fetchPairs();
$this->view->contacts = $this->backend->select() $this->view->contacts = $this->backend->select()
->from('contact', array( ->from(
'contact',
array(
'contact_name', 'contact_name',
'contact_alias', 'contact_alias',
'contact_email', 'contact_email',
'contact_pager', 'contact_pager',
)) )
)
->where('host_name', $this->view->host->host_name) ->where('host_name', $this->view->host->host_name)
->fetchAll(); ->fetchAll();
$this->view->contactgroups = $this->backend->select() $this->view->contactgroups = $this->backend->select()
->from('contactgroup', array( ->from(
'contactgroup',
array(
'contactgroup_name', 'contactgroup_name',
'contactgroup_alias', 'contactgroup_alias',
)) )
)
->where('host_name', $this->view->host->host_name) ->where('host_name', $this->view->host->host_name)
->fetchAll(); ->fetchAll();
$this->view->comments = $this->backend->select() $this->view->comments = $this->backend->select()
->from('comment', array( ->from(
'comment',
array(
'comment_timestamp', 'comment_timestamp',
'comment_author', 'comment_author',
'comment_data', 'comment_data',
'comment_type', 'comment_type',
)) )
)
->where('host_name', $this->view->host->host_name) ->where('host_name', $this->view->host->host_name)
->fetchAll(); ->fetchAll();
$this->view->customvars = $this->backend->select() $this->view->customvars = $this->backend->select()
->from('customvar', array( ->from(
'customvar',
array(
'varname', 'varname',
'varvalue' 'varvalue'
)) )
)
->where('varname', '-*PW*,-*PASS*') ->where('varname', '-*PW*,-*PASS*')
->where('host_name', $this->view->host->host_name) ->where('host_name', $this->view->host->host_name)
->where('object_type', 'host') ->where('object_type', 'host')
->fetchPairs(); ->fetchPairs();
} }
/**
* History entries for objects
*/
public function historyAction() public function historyAction()
{ {
if ($this->view->host) { if ($this->view->host) {
$this->view->tabs->activate('history')->enableSpecialActions(); $this->view->tabs->activate('history')->enableSpecialActions();
} }
$this->view->history = $this->backend->select() $this->view->history = $this->backend->select()
->from('eventHistory', array( ->from(
'eventHistory',
array(
'object_type', 'object_type',
'host_name', 'host_name',
'service_description', 'service_description',
@ -192,7 +245,8 @@ class Monitoring_ShowController extends ModuleActionController
'max_attempts', 'max_attempts',
'output', 'output',
'type' 'type'
))->applyRequest($this->_request); )
)->applyRequest($this->_request);
$this->view->preserve = $this->view->history->getAppliedFilter()->toParams(); $this->view->preserve = $this->view->history->getAppliedFilter()->toParams();
@ -205,15 +259,26 @@ class Monitoring_ShowController extends ModuleActionController
} }
} }
/**
* Service overview
*/
public function servicesAction() public function servicesAction()
{ {
// Ugly and slow: // 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, 'host_name' => $this->view->host->host_name,
//'sort', 'service_description' //'sort', 'service_description'
)); )
);
} }
/**
* Ticets actions
*/
public function ticketAction() public function ticketAction()
{ {
$this->view->tabs->activate('ticket')->enableSpecialActions(); $this->view->tabs->activate('ticket')->enableSpecialActions();
@ -222,16 +287,25 @@ class Monitoring_ShowController extends ModuleActionController
if (Hook::has('ticket')) { if (Hook::has('ticket')) {
$ticketModule = 'rt'; $ticketModule = 'rt';
$this->render(); $this->render();
$this->_forward('ticket', 'show', $ticketModule, array( $this->_forward(
'ticket',
'show',
$ticketModule,
array(
'id' => $id 'id' => $id
)); )
);
} }
} }
/**
* Creating tabs for this controller
* @return \Icinga\Web\Widget\AbstractWidget
*/
protected function createTabs() protected function createTabs()
{ {
$tabs = $this->widget('tabs'); $tabs = $this->widget('tabs');
if ( ! $this->view->host) { if (!$this->view->host) {
return $tabs; return $tabs;
} }
$params = array( $params = array(
@ -246,48 +320,63 @@ class Monitoring_ShowController extends ModuleActionController
} else { } else {
$hostParams = $params; $hostParams = $params;
} }
$tabs->add('host', array( $tabs->add(
'host',
array(
'title' => 'Host', 'title' => 'Host',
'icon' => 'img/classic/server.png', 'icon' => 'img/classic/server.png',
'url' => 'monitoring/show/host', 'url' => 'monitoring/show/host',
'urlParams' => $hostParams, 'urlParams' => $hostParams,
)); )
$tabs->add('services', array( );
$tabs->add(
'services',
array(
'title' => 'Services', 'title' => 'Services',
'icon' => 'img/classic/service.png', 'icon' => 'img/classic/service.png',
'url' => 'monitoring/show/services', 'url' => 'monitoring/show/services',
'urlParams' => $params, 'urlParams' => $params,
)); )
);
if (isset($params['service'])) { if (isset($params['service'])) {
$tabs->add('service', array( $tabs->add(
'service',
array(
'title' => 'Service', 'title' => 'Service',
'icon' => 'img/classic/service.png', 'icon' => 'img/classic/service.png',
'url' => 'monitoring/show/service', 'url' => 'monitoring/show/service',
'urlParams' => $params, 'urlParams' => $params,
)); )
);
} }
$tabs->add('history', array( $tabs->add(
'history',
array(
'title' => 'History', 'title' => 'History',
'icon' => 'img/classic/history.gif', 'icon' => 'img/classic/history.gif',
'url' => 'monitoring/show/history', 'url' => 'monitoring/show/history',
'urlParams' => $params, 'urlParams' => $params,
)); )
);
if ($this->action_name === 'ticket') { if ($this->action_name === 'ticket') {
$tabs->add('ticket', array( $tabs->add(
'ticket',
array(
'title' => 'Ticket', 'title' => 'Ticket',
'icon' => 'img/classic/ticket.gif', 'icon' => 'img/classic/ticket.gif',
'url' => 'monitoring/show/ticket', 'url' => 'monitoring/show/ticket',
'urlParams' => $params + array('ticket' => $this->_getParam('ticket')), 'urlParams' => $params + array('ticket' => $this->_getParam('ticket')),
)); )
);
} }
/* /*
$tabs->add('contacts', array( $tabs->add('contacts', array(
'title' => 'Contacts', 'title' => 'Contacts',
'icon' => 'img/classic/customer.png', 'icon' => 'img/classic/customer.png',
'url' => 'monitoring/detail/contacts', 'url' => 'monitoring/detail/contacts',
'urlParams' => $params, 'urlParams' => $params,
)); ));
*/ */
// TODO: Inventory 'img/classic/facts.gif' // TODO: Inventory 'img/classic/facts.gif'
// Ticket 'img/classic/ticket.gif' // Ticket 'img/classic/ticket.gif'
// Customer 'img/classic/customer.png' // Customer 'img/classic/customer.png'

View File

@ -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; ?> <?php endif; ?>

View File

@ -1,24 +1,33 @@
<?php if (! empty($this->contacts)): ?> <?php
<? if (!empty($this->contacts)) {
$list = array(); $contactList = array();
foreach ($this->contacts as $contact) { foreach ($this->contacts as $contact) {
$list[] = $this->qlink($contact->contact_alias, 'monitoring/show/contact', array( $contactList[] = $this->qlink(
$contact->contact_alias,
'monitoring/show/contact',
array(
'contact_name' => $contact->contact_name 'contact_name' => $contact->contact_name
)); )
} );
?> }
<b>Contacts:</b> <?= implode(', ', $list) ?><br />
<?php endif; ?>
<?php if (! empty($this->contactgroups)): ?> echo '<strong>Contacts:</strong> ';
<? echo implode(', ', $contactList);
$list = array(); }
foreach ($this->contactgroups as $contactgroup) {
$list[] = $this->qlink($contactgroup->contactgroup_alias, 'monitoring/show/contactgroup', array( 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 'contactgroup_name' => $contactgroup->contactgroup_name
)); )
} );
?> }
<b>Contactgroups:</b> <?= implode(', ', $list) ?><br />
<?php endif; ?>
echo '<strong>Contactgroups:</strong> ';
echo implode(', ', $contactGroupList);
}
?>

View File

@ -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 } ?>

View File

@ -1,30 +1,72 @@
<?php <?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): ?> <div class="information-container">
<?= $this->tabs ?> <?php if ($inlineCommands === true) { ?>
<?php endif; ?> <div class="pull-right">
<table style="margin-bottom: 1em"> <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' : '' ?>"> <tr class="<?= $this->monitoringState($this->host, 'host') ?><?= $this->host->host_handled ? ' handled' : '' ?>">
<td><b><?= $this->escape($this->host->host_name) ?><? <td>
if ($this->host->host_address && $this->host->host_address !== $this->host->host_name): ?> <strong>
(<?= $this->escape($this->host->host_address) ?>) <?= $this->escape($this->host->host_name); ?>
<?php endif; ?> <?php if ($this->host->host_address && $this->host->host_address !== $this->host->host_name) { ?>
</b></td> (<?= $this->escape($this->host->host_address); ?>)
<td class="state"<?= $showService ? '' : ' rowspan="2"' ?>> <?php } ?>
<?= $this->util()->getHostStateName($this->host->host_state); ?><br /> </strong>
since <?= $this->timeSince($this->host->host_last_state_change) ?>
<?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> </td>
</tr> </tr>
<?php if ($showService): ?> <?php if ($showService === true) { ?>
<tr class="<?= $this->monitoringState($this->service, 'service'); ?><?= $this->service->service_handled ? ' handled' : '' ?>"> <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"> <td class="state">
<?= $this->util()->getServiceStateName($this->service->service_state); ?><br /> <?= $this->util()->getServiceStateName($this->service->service_state); ?>
since <?= $this->timeSince($this->service->service_last_state_change) ?> since <?= $this->timeSince($this->service->service_last_state_change); ?>
</td> </td>
</tr> </tr>
<?php else: ?> <?php } else { ?>
<tr><td><b>Host state</b></td></tr> <?php // BYPASS ?>
<?php endif; ?> <?php } ?>
</table> </table>
<div class="clearfix"></div>
</div>

View File

@ -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, 'host' => $this->host,
'service' => $this->service, 'service' => $this->service,
'tabs' => $this->tabs, 'tabs' => $this->tabs,
'compact' => $this->compact '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 ?> <?= $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; ?>

View File

@ -46,7 +46,7 @@ class AbstractBackend implements DatasourceInterface
public function from($virtual_table, $fields = array()) public function from($virtual_table, $fields = array())
{ {
$classname = $this->tableToClassName($virtual_table); $classname = $this->tableToClassName($virtual_table);
if (! class_exists($classname)) { if (!class_exists($classname)) {
throw new ProgrammingError( throw new ProgrammingError(
sprintf( sprintf(
'Asking for invalid virtual table %s', 'Asking for invalid virtual table %s',
@ -84,12 +84,10 @@ class AbstractBackend implements DatasourceInterface
} }
// UGLY temporary host fetch // UGLY temporary host fetch
public function fetchHost($host) public function fetchHost($host, $fetchAll = false)
{ {
$select = $this->select() $fields = array(
->from('status', array(
'host_name', 'host_name',
'host_address', 'host_address',
'host_state', 'host_state',
@ -101,45 +99,72 @@ class AbstractBackend implements DatasourceInterface
'host_alias', 'host_alias',
'host_output', 'host_output',
'host_long_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); ->where('host_name', $host);
return $select->fetchRow(); 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 // UGLY temporary service fetch
public function fetchService($host, $service) public function fetchService($host, $service)
{ {
Benchmark::measure('Preparing service select'); Benchmark::measure('Preparing service select');
$select = $this->select() $select = $this->select()
->from('status', array( ->from(
'status',
array(
'host_name', 'host_name',
'host_state', 'host_state',
'host_check_command', 'host_check_command',
'host_last_state_change', 'host_last_state_change',
'service_description', 'service_description',
'service_state', 'service_state',
'service_acknowledged', 'service_acknowledged',
@ -155,22 +180,24 @@ Benchmark::measure('Preparing service select');
'service_check_execution_time', 'service_check_execution_time',
'service_check_latency', 'service_check_latency',
// 'service_ // 'service_
)) )
)
->where('host_name', $host) ->where('host_name', $host)
->where('service_description', $service); ->where('service_description', $service);
// Benchmark::measure((string) $select->getQuery()); // Benchmark::measure((string) $select->getQuery());
Benchmark::measure('Prepared service select'); Benchmark::measure('Prepared service select');
return $select->fetchRow(); return $select->fetchRow();
$object = \Icinga\Objects\Service::fromBackend( $object = \Icinga\Objects\Service::fromBackend(
$this->select() $this->select()
->from('status', array( ->from(
'status',
array(
'host_name', 'host_name',
'host_state', 'host_state',
'host_check_command', 'host_check_command',
'host_last_state_change', 'host_last_state_change',
'service_description', 'service_description',
'service_state', 'service_state',
'service_acknowledged', 'service_acknowledged',
@ -186,7 +213,8 @@ Benchmark::measure('Prepared service select');
'service_check_execution_time', 'service_check_execution_time',
'service_check_latency', 'service_check_latency',
// 'service_ // 'service_
)) )
)
->where('host_name', $host) ->where('host_name', $host)
->where('service_description', $service) ->where('service_description', $service)
->fetchRow() ->fetchRow()

View File

@ -28,6 +28,46 @@ class StatusQuery extends AbstractQuery
'host_accepts_passive_checks' => 'hs.passive_checks_enabled', 'host_accepts_passive_checks' => 'hs.passive_checks_enabled',
'host_last_state_change' => 'UNIX_TIMESTAMP(hs.last_state_change)', 'host_last_state_change' => 'UNIX_TIMESTAMP(hs.last_state_change)',
'host_check_command' => 'hs.check_command', '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_problems' => 'CASE WHEN hs.current_state = 0 THEN 0 ELSE 1 END',
'host_severity' => 'CASE WHEN hs.current_state = 0 'host_severity' => 'CASE WHEN hs.current_state = 0
THEN THEN
@ -129,10 +169,12 @@ class StatusQuery extends AbstractQuery
END', END',
) )
); );
public function group($col)
{ public function group($col)
{
$this->baseQuery->group($col); $this->baseQuery->group($col);
} }
protected function getDefaultColumns() protected function getDefaultColumns()
{ {
return $this->columnMap['hosts']; return $this->columnMap['hosts'];
@ -228,7 +270,7 @@ public function group($col)
array() array()
)->join( )->join(
array('hgo' => $this->prefix . 'objects'), 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', . ' AND hgo.is_active = 1',
array() array()
); );
@ -248,7 +290,7 @@ public function group($col)
array() array()
)->join( )->join(
array('hgo' => $this->prefix . 'objects'), 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', . ' AND hgo.is_active = 1',
array() array()
); );

View File

@ -178,3 +178,4 @@ body {
@import 'dataviews'; @import 'dataviews';
@import 'components/layouts'; @import 'components/layouts';
@import 'components/tables'; @import 'components/tables';
@import 'components/details';

View File

@ -85,3 +85,23 @@ font-size: 12px;
font-weight:bold; 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;
}
}