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
// {{{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,17 +68,21 @@ class Monitoring_ShowController extends ModuleActionController
}
}
/**
* Service overview
*/
public function serviceAction()
{
Benchmark::measure('Entered service action');
$this->view->active = 'service';
$this->view->tabs->activate('service')->enableSpecialActions();
if ($grapher = Hook::get('grapher')) {
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(
'contact_name',
'contact_alias',
'contact_email',
'contact_pager',
))
->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(
'contactgroup_name',
'contactgroup_alias',
))
->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(
'comment_timestamp',
'comment_author',
'comment_data',
'comment_type',
))
->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(
'varname',
'varvalue'
))
->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,11 +146,14 @@ class Monitoring_ShowController extends ModuleActionController
Benchmark::measure('Service action done');
}
/**
* Host overview
*/
public function hostAction()
{
$this->view->active = 'host';
$this->view->tabs->activate('host')->enableSpecialActions();
if ($grapher = Hook::get('grapher')) {
if ($grapher->hasGraph($this->view->host->host_name)) {
$this->view->preview_image = $grapher->getPreviewImage(
@ -130,90 +163,122 @@ class Monitoring_ShowController extends ModuleActionController
}
$this->view->hostgroups = $this->backend->select()
->from('hostgroup', array(
'hostgroup_name',
'hostgroup_alias'
))
->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(
'contact_name',
'contact_alias',
'contact_email',
'contact_pager',
))
->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(
'contactgroup_name',
'contactgroup_alias',
))
->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(
'comment_timestamp',
'comment_author',
'comment_data',
'comment_type',
))
->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(
'varname',
'varvalue'
))
->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(
'object_type',
'host_name',
'service_description',
'timestamp',
'state',
'attempt',
'max_attempts',
'output',
'type'
))->applyRequest($this->_request);
->from(
'eventHistory',
array(
'object_type',
'host_name',
'service_description',
'timestamp',
'state',
'attempt',
'max_attempts',
'output',
'type'
)
)->applyRequest($this->_request);
$this->view->preserve = $this->view->history->getAppliedFilter()->toParams();
if ($this->_getParam('dump') === 'sql') {
echo '<pre>' . htmlspecialchars($this->view->history->getQuery()->dump()) . '</pre>';
exit;
}
$this->view->preserve = $this->view->history->getAppliedFilter()->toParams();
if ($this->_getParam('dump') === 'sql') {
echo '<pre>' . htmlspecialchars($this->view->history->getQuery()->dump()) . '</pre>';
exit;
}
if ($this->_getParam('sort')) {
$this->view->preserve['sort'] = $this->_getParam('sort');
}
}
/**
* Service overview
*/
public function servicesAction()
{
// Ugly and slow:
$this->view->services = $this->view->action('services', 'list', 'monitoring', array(
'host_name' => $this->view->host->host_name,
//'sort', 'service_description'
));
$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(
'id' => $id
));
$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(
'title' => 'Host',
'icon' => 'img/classic/server.png',
'url' => 'monitoring/show/host',
'urlParams' => $hostParams,
));
$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(
'title' => 'Service',
'icon' => 'img/classic/service.png',
'url' => 'monitoring/show/service',
$tabs->add(
'host',
array(
'title' => 'Host',
'icon' => 'img/classic/server.png',
'url' => 'monitoring/show/host',
'urlParams' => $hostParams,
)
);
$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(
'title' => 'Service',
'icon' => 'img/classic/service.png',
'url' => 'monitoring/show/service',
'urlParams' => $params,
)
);
}
$tabs->add('history', array(
'title' => 'History',
'icon' => 'img/classic/history.gif',
'url' => 'monitoring/show/history',
'urlParams' => $params,
));
$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(
'title' => 'Ticket',
'icon' => 'img/classic/ticket.gif',
'url' => 'monitoring/show/ticket',
'urlParams' => $params + array('ticket' => $this->_getParam('ticket')),
));
$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,
));
*/
/*
$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'

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; ?>

View File

@ -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(
'contact_name' => $contact->contact_name
));
}
?>
<b>Contacts:</b> <?= implode(', ', $list) ?><br />
<?php endif; ?>
<?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
)
);
}
<?php if (! empty($this->contactgroups)): ?>
<?
$list = array();
foreach ($this->contactgroups as $contactgroup) {
$list[] = $this->qlink($contactgroup->contactgroup_alias, 'monitoring/show/contactgroup', array(
'contactgroup_name' => $contactgroup->contactgroup_name
));
}
?>
<b>Contactgroups:</b> <?= implode(', ', $list) ?><br />
<?php endif; ?>
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
)
);
}
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
$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">
<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>
</tr>
<?php if ($showService): ?>
<tr class="<?= $this->monitoringState($this->service, 'service'); ?><?= $this->service->service_handled ? ' handled' : '' ?>">
<td><b>Service: <?= $this->escape($this->service->service_description) ?></b></td>
<td class="state">
<?= $this->util()->getServiceStateName($this->service->service_state); ?><br />
since <?= $this->timeSince($this->service->service_last_state_change) ?>
</td>
</tr>
<?php else: ?>
<tr><td><b>Host state</b></td></tr>
<?php endif; ?>
</table>
<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>
<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 === true) { ?>
<tr class="<?= $this->monitoringState($this->service, 'service'); ?><?= $this->service->service_handled ? ' handled' : '' ?>">
<td>
<strong>
Service: <?= $this->escape($this->service->service_description); ?>
</strong>
</td>
<td class="state">
<?= $this->util()->getServiceStateName($this->service->service_state); ?>
since <?= $this->timeSince($this->service->service_last_state_change); ?>
</td>
</tr>
<?php } else { ?>
<?php // BYPASS ?>
<?php } ?>
</table>
<div class="clearfix"></div>
</div>

View File

@ -1,40 +1,78 @@
<?= $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
$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
)
);
?>
<?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; ?>

View File

@ -23,7 +23,7 @@ class AbstractBackend implements DatasourceInterface
protected function init()
{
}
/**
* Dummy function for fluent code
*
@ -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',
@ -67,10 +67,10 @@ class AbstractBackend implements DatasourceInterface
protected function tableToClassName($virtual_table)
{
return 'Icinga\\Monitoring\\View\\'
// . $this->getName()
// . '\\'
. ucfirst($virtual_table)
. 'View';
// . $this->getName()
// . '\\'
. ucfirst($virtual_table)
. 'View';
}
public function getName()
@ -84,62 +84,87 @@ class AbstractBackend implements DatasourceInterface
}
// UGLY temporary host fetch
public function fetchHost($host)
public function fetchHost($host, $fetchAll = false)
{
$select = $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);
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()
$fields = 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'
);
// $object->customvars = $this->fetchCustomvars($host);
return $object;
$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();
}
// 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',
@ -154,39 +179,42 @@ Benchmark::measure('Preparing service select');
'service_next_check',
'service_check_execution_time',
'service_check_latency',
// 'service_
))
->where('host_name', $host)
->where('service_description', $service);
// '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',
'service_handled',
'service_output',
'service_long_output',
'service_perfdata',
// '_host_satellite',
'service_check_command',
'service_last_state_change',
'service_last_check',
'service_next_check',
'service_check_execution_time',
'service_check_latency',
// 'service_
))
'host_name',
'host_state',
'host_check_command',
'host_last_state_change',
'service_description',
'service_state',
'service_acknowledged',
'service_handled',
'service_output',
'service_long_output',
'service_perfdata',
// '_host_satellite',
'service_check_command',
'service_last_state_change',
'service_last_check',
'service_next_check',
'service_check_execution_time',
'service_check_latency',
// 'service_
)
)
->where('host_name', $host)
->where('service_description', $service)
->fetchRow()

View File

@ -8,27 +8,67 @@ class StatusQuery extends AbstractQuery
protected $columnMap = array(
'hosts' => array(
'host' => 'ho.name1',
'host_name' => 'ho.name1',
'host_display_name' => 'h.display_name',
'host_alias' => 'h.alias',
'host_address' => 'h.address',
'host_ipv4' => 'INET_ATON(h.address)',
'host_icon_image' => 'h.icon_image',
'host' => 'ho.name1',
'host_name' => 'ho.name1',
'host_display_name' => 'h.display_name',
'host_alias' => 'h.alias',
'host_address' => 'h.address',
'host_ipv4' => 'INET_ATON(h.address)',
'host_icon_image' => 'h.icon_image',
),
'hoststatus' => array(
'host_state' => 'CASE WHEN hs.has_been_checked = 0 OR hs.has_been_checked IS NULL THEN 99 ELSE hs.current_state END',
'host_output' => 'hs.output',
'host_long_output' => 'hs.long_output',
'host_perfdata' => 'hs.perfdata',
'host_acknowledged' => 'hs.problem_has_been_acknowledged',
'host_in_downtime' => 'CASE WHEN (hs.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END',
'host_handled' => 'CASE WHEN (hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth) > 0 THEN 1 ELSE 0 END',
'host_does_active_checks' => 'hs.active_checks_enabled',
'host_state' => 'CASE WHEN hs.has_been_checked = 0 OR hs.has_been_checked IS NULL THEN 99 ELSE hs.current_state END',
'host_output' => 'hs.output',
'host_long_output' => 'hs.long_output',
'host_perfdata' => 'hs.perfdata',
'host_acknowledged' => 'hs.problem_has_been_acknowledged',
'host_in_downtime' => 'CASE WHEN (hs.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END',
'host_handled' => 'CASE WHEN (hs.problem_has_been_acknowledged + hs.scheduled_downtime_depth) > 0 THEN 1 ELSE 0 END',
'host_does_active_checks' => 'hs.active_checks_enabled',
'host_accepts_passive_checks' => 'hs.passive_checks_enabled',
'host_last_state_change' => 'UNIX_TIMESTAMP(hs.last_state_change)',
'host_check_command' => 'hs.check_command',
'host_problems' => 'CASE WHEN hs.current_state = 0 THEN 0 ELSE 1 END',
'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
CASE WHEN hs.has_been_checked = 0 OR hs.has_been_checked IS NULL
@ -65,36 +105,36 @@ class StatusQuery extends AbstractQuery
'hostgroups' => 'hgo.name1',
),
'services' => array(
'service_host_name' => 'so.name1',
'service' => 'so.name2',
'service_description' => 'so.name2',
'service_display_name' => 's.display_name',
'service_icon_image' => 's.icon_image',
'service_host_name' => 'so.name1',
'service' => 'so.name2',
'service_description' => 'so.name2',
'service_display_name' => 's.display_name',
'service_icon_image' => 's.icon_image',
),
'servicestatus' => array(
'current_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END',
'service_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END',
'service_hard_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE CASE WHEN ss.state_type = 1 THEN ss.current_state ELSE ss.last_hard_state END END',
'service_state_type' => 'ss.state_type',
'service_output' => 'ss.output',
'service_long_output' => 'ss.long_output',
'service_perfdata' => 'ss.perfdata',
'service_acknowledged' => 'ss.problem_has_been_acknowledged',
'service_in_downtime' => 'CASE WHEN (ss.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END',
'service_handled' => 'CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) > 0 THEN 1 ELSE 0 END',
'service_does_active_checks' => 'ss.active_checks_enabled',
'current_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END',
'service_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE ss.current_state END',
'service_hard_state' => 'CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL THEN 99 ELSE CASE WHEN ss.state_type = 1 THEN ss.current_state ELSE ss.last_hard_state END END',
'service_state_type' => 'ss.state_type',
'service_output' => 'ss.output',
'service_long_output' => 'ss.long_output',
'service_perfdata' => 'ss.perfdata',
'service_acknowledged' => 'ss.problem_has_been_acknowledged',
'service_in_downtime' => 'CASE WHEN (ss.scheduled_downtime_depth = 0) THEN 0 ELSE 1 END',
'service_handled' => 'CASE WHEN (ss.problem_has_been_acknowledged + ss.scheduled_downtime_depth + COALESCE(hs.current_state, 0)) > 0 THEN 1 ELSE 0 END',
'service_does_active_checks' => 'ss.active_checks_enabled',
'service_accepts_passive_checks' => 'ss.passive_checks_enabled',
'service_last_state_change' => 'UNIX_TIMESTAMP(ss.last_state_change)',
'service_last_state_change' => 'UNIX_TIMESTAMP(ss.last_state_change)',
'service_last_hard_state_change' => 'UNIX_TIMESTAMP(ss.last_hard_state_change)',
'service_check_command' => 'ss.check_command',
'service_last_check' => 'UNIX_TIMESTAMP(ss.last_check)',
'service_next_check' => 'CASE WHEN ss.should_be_scheduled THEN UNIX_TIMESTAMP(ss.next_check) ELSE NULL END',
'service_check_execution_time' => 'ss.execution_time',
'service_check_latency' => 'ss.latency',
'service_check_command' => 'ss.check_command',
'service_last_check' => 'UNIX_TIMESTAMP(ss.last_check)',
'service_next_check' => 'CASE WHEN ss.should_be_scheduled THEN UNIX_TIMESTAMP(ss.next_check) ELSE NULL END',
'service_check_execution_time' => 'ss.execution_time',
'service_check_latency' => 'ss.latency',
),
'status' => array(
'problems' => 'CASE WHEN ss.current_state = 0 THEN 0 ELSE 1 END',
'handled' => 'CASE WHEN ss.problem_has_been_acknowledged = 1 OR ss.scheduled_downtime_depth > 0 THEN 1 ELSE 0 END',
'handled' => 'CASE WHEN ss.problem_has_been_acknowledged = 1 OR ss.scheduled_downtime_depth > 0 THEN 1 ELSE 0 END',
'severity' => 'CASE WHEN ss.current_state = 0
THEN
CASE WHEN ss.has_been_checked = 0 OR ss.has_been_checked IS NULL
@ -129,10 +169,12 @@ class StatusQuery extends AbstractQuery
END',
)
);
public function group($col)
{
$this->baseQuery->group($col);
}
public function group($col)
{
$this->baseQuery->group($col);
}
protected function getDefaultColumns()
{
return $this->columnMap['hosts'];
@ -150,25 +192,25 @@ public function group($col)
array('ho' => $this->prefix . 'objects'),
array()
)->join(
array('hs' => $this->prefix . 'hoststatus'),
'ho.object_id = hs.host_object_id AND ho.is_active = 1',
array()
)->join(
array('h' => $this->prefix . 'hosts'),
'hs.host_object_id = h.host_object_id',
array()
);
array('hs' => $this->prefix . 'hoststatus'),
'ho.object_id = hs.host_object_id AND ho.is_active = 1',
array()
)->join(
array('h' => $this->prefix . 'hosts'),
'hs.host_object_id = h.host_object_id',
array()
);
$this->joinedVirtualTables = array(
'hosts' => true,
'hosts' => true,
'hoststatus' => true,
);
}
protected function joinStatus()
{
$this->requireVirtualTable('services');
}
protected function joinServiceStatus()
{
$this->requireVirtualTable('services');
@ -181,16 +223,16 @@ public function group($col)
's.host_object_id = h.host_object_id',
array()
)->join(
array('so' => $this->prefix . 'objects'),
"so.$this->object_id = s.service_object_id AND so.is_active = 1",
array()
)->joinLeft(
array('ss' => $this->prefix . 'servicestatus'),
"so.$this->object_id = ss.service_object_id",
array()
);
array('so' => $this->prefix . 'objects'),
"so.$this->object_id = s.service_object_id AND so.is_active = 1",
array()
)->joinLeft(
array('ss' => $this->prefix . 'servicestatus'),
"so.$this->object_id = ss.service_object_id",
array()
);
}
// TODO: Test this one, doesn't seem to work right now
protected function joinHostgroups()
{
@ -208,10 +250,10 @@ public function group($col)
'hgm.host_object_id = h.host_object_id',
array()
)->join(
array('hg' => $this->prefix . 'hostgroups'),
"hgm.hostgroup_id = hg.$this->hostgroup_id",
array()
);
array('hg' => $this->prefix . 'hostgroups'),
"hgm.hostgroup_id = hg.$this->hostgroup_id",
array()
);
return $this;
}
@ -223,15 +265,15 @@ public function group($col)
'hgm.host_object_id = s.host_object_id',
array()
)->join(
array('hg' => $this->prefix . 'hostgroups'),
'hgm.hostgroup_id = hg.' . $this->hostgroup_id,
array()
)->join(
array('hgo' => $this->prefix . 'objects'),
'hgo.' . $this->object_id. ' = hg.hostgroup_object_id'
. ' AND hgo.is_active = 1',
array()
);
array('hg' => $this->prefix . 'hostgroups'),
'hgm.hostgroup_id = hg.' . $this->hostgroup_id,
array()
)->join(
array('hgo' => $this->prefix . 'objects'),
'hgo.' . $this->object_id . ' = hg.hostgroup_object_id'
. ' AND hgo.is_active = 1',
array()
);
return $this;
}
@ -243,15 +285,15 @@ public function group($col)
'sgm.service_object_id = s.service_object_id',
array()
)->join(
array('sg' => $this->prefix . 'servicegroups'),
'sgm.servicegroup_id = sg.' . $this->servicegroup_id,
array()
)->join(
array('hgo' => $this->prefix . 'objects'),
'hgo.' . $this->object_id. ' = hg.' . $this->hostgroup_id
. ' AND hgo.is_active = 1',
array()
);
array('sg' => $this->prefix . 'servicegroups'),
'sgm.servicegroup_id = sg.' . $this->servicegroup_id,
array()
)->join(
array('hgo' => $this->prefix . 'objects'),
'hgo.' . $this->object_id . ' = hg.' . $this->hostgroup_id
. ' AND hgo.is_active = 1',
array()
);
return $this;
}

View File

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

View File

@ -84,4 +84,24 @@ font-size: 12px;
clear:left;
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;
}
}