Add more information to host and service list

This commit is contained in:
Eric Lippmann 2013-09-26 16:29:48 +02:00
parent c56771baa3
commit 61bfcd495b
10 changed files with 199 additions and 196 deletions

View File

@ -111,7 +111,10 @@ class Monitoring_ListController extends ActionController
'host_unhandled_service_count',
'host_action_url',
'host_notes_url',
'host_last_comment'
'host_last_comment',
'host_active_checks_enabled',
'host_passive_checks_enabled'
)
)->getQuery();
$this->view->hosts = $query->paginate();
@ -159,7 +162,9 @@ class Monitoring_ListController extends ActionController
'service_notifications_enabled',
'service_action_url',
'service_notes_url',
'service_last_comment'
'service_last_comment',
'service_active_checks_enabled',
'service_passive_checks_enabled'
)
)->getQuery();
$this->view->services = $query->paginate();

View File

@ -86,6 +86,7 @@ class Monitoring_ShowController extends ActionController
public function serviceAction()
{
$this->view->object->prefetch();
$this->view->preserve = array();
}
/**
@ -94,6 +95,7 @@ class Monitoring_ShowController extends ActionController
public function hostAction()
{
$this->view->object->prefetch();
$this->view->preserve = array();
}
/**

View File

@ -107,7 +107,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
* @param stdClass $object
* @return string
*/
private function buildAttempt(stdClass $object)
private function buildAttempt(AbstractObject $object)
{
return sprintf(
'%s/%s (%s state)',
@ -132,7 +132,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
* @param stdClass $object
* @return string
*/
private function buildCheckType(stdClass $object)
private function buildCheckType(AbstractObject $object)
{
if ($object->passive_checks_enabled === '1' && $object->active_checks_enabled === '0') {
return self::CHECK_PASSIVE;
@ -148,7 +148,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
* @param stdClass $object
* @return string
*/
private function buildLatency(stdClass $object)
private function buildLatency(AbstractObject $object)
{
$val = '';
if ($this->buildCheckType($object) === self::CHECK_PASSIVE) {
@ -171,7 +171,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
* @param stdClass $object
* @return string
*/
private function buildNextCheck(stdClass $object)
private function buildNextCheck(AbstractObject $object)
{
if ($this->buildCheckType($object) === self::CHECK_PASSIVE) {
return self::VALUE_NA;
@ -185,7 +185,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
* @param stdClass $object
* @return string
*/
private function buildLastStateChange(stdClass $object)
private function buildLastStateChange(AbstractObject $object)
{
return strftime('%Y-%m-%d %H:%M:%S', $object->last_state_change);
}
@ -195,7 +195,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
* @param stdClass $object
* @return string
*/
private function buildLastNotification(stdClass $object)
private function buildLastNotification(AbstractObject $object)
{
$val = '';
@ -215,7 +215,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
* @param stdClass $object
* @return string
*/
private function buildFlapping(stdClass $object)
private function buildFlapping(AbstractObject $object)
{
$val = '';
@ -235,7 +235,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
* @param stdClass $object
* @return string
*/
private function buildScheduledDowntime(stdClass $object)
private function buildScheduledDowntime(AbstractObject $object)
{
if ($object->in_downtime === '1') {
return self::VALUE_YES;
@ -253,10 +253,9 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
public function monitoringProperties(AbstractObject $object)
{
$type = $this->getObjectType($object);
$object = $this->dropObjectType($object, $type);
//$object = $this->dropObjectType($object, $type);
$out = array();
foreach (self::$keys as $property => $label) {
$label = sprintf($label, ucfirst($type));
if (is_callable(array(&$this, $property))) {
@ -269,7 +268,7 @@ class Zend_View_Helper_MonitoringProperties extends Zend_View_Helper_Abstract
return $out;
}
public function getNotificationType(stdClass $notification)
public function getNotificationType(AbstractObject $notification)
{
$reason = intval($notification->notification_reason);
if (!isset(self::$notificationReasons[$reason])) {

View File

@ -12,7 +12,7 @@ $viewHelper = $this->getHelper('MonitoringState');
<table class="table table-condensed">
<thead>
<tr>
<th colspan="2">Status</th>
<th colspan="3">Status</th>
<th>Host</th>
<th>Output</th>
</tr>
@ -24,67 +24,102 @@ $viewHelper = $this->getHelper('MonitoringState');
<tr <?= ($this->activeRowHref === $hostLink) ? 'class="active"' : ''; ?> >
<td>
<a style="visibility:hidden" href="<?= $hostLink; ?>"></a>
<div>
<form class="reschedule">
</form>
<?php if ($host->host_icon_image) : ?>
<?php if ($host->host_icon_image) : ?>
<img src="<?= $host->host_icon_image; ?>"/>
<?php endif; ?>
</div>
<?php endif; ?>
</td>
<td>
<div>
<?php if (!$host->host_handled && $host->host_state > 0): ?>
<a href="#" title="<?= 'Unhandled host' ?>">
<i>{{UNHANDLED_ICON}}</i>
</a>
<?php endif; ?>
<?php if (!$host->host_handled && $host->host_state > 0): ?>
<a href="#" title="Unhandled">
<i>{{UNHANDLED_ICON}}</i>
</a>
<?php endif; ?>
<?php if ($host->host_acknowledged && !$host->host_in_downtime): ?>
<a href="#" title="<?= 'Acknowledged' ?>">
<i>{{ACKNOWLEDGED_ICON}}</i>
</a>
<?php endif; ?>
<?php if ($host->host_acknowledged && !$host->host_in_downtime): ?>
<a href="#" title="Acknowledged">
<i>{{ACKNOWLEDGED_ICON}}</i>
</a>
<?php endif; ?>
<?php if ($host->host_is_flapping): ?>
<a href="#" title="<?= 'Flapping' ?>">
<i>{{FLAPPING_ICON}}</i>
</a>
<?php if ($host->host_is_flapping): ?>
<a href="#" title="Flapping">
<i>{{FLAPPING_ICON}}</i>
</a>
<?php endif; ?>
<?php if (!$host->host_notifications_enabled): ?>
<a href="#" title="Notifications Disabled">
<i>{{NOTIFICATIONS_DISABLED_ICON}}</i>
</a>
<?php endif; ?>
<?php if ($host->host_in_downtime): ?>
<a href="#" title="In Downtime">
<i>{{IN_DOWNTIME_ICON}}</i>
</a>
<?php endif; ?>
<?php if (!$host->host_active_checks_enabled): ?>
<?php if (!$host->host_passive_checks_enabled): ?>
<a href="#" title="Active And Passive Checks Disabled">
<i>{{ACTIVE_PASSIVE_CHECKS_DISABLED_ICON}}</i>
</a>
<?php else: ?>
<a href="#" title="Active Checks Disabled">
<i>{{ACTIVE_CHECKS_DISABLED_ICON}}</i>
</a>
<?php endif; ?>
</div>
</td>
<td>
<?php endif; ?>
<?php if ($host->host_last_comment !== null): ?>
<a href="#" title="<?= 'Comments' ?>">
<a href="#" title="Comments">
<i>{{COMMENT_ICON}}</i>
</a>
<?php endif; ?>
</td>
<td title="<?= $viewHelper->getStateTitle($host, 'host'); ?>">
<div>
<?php if ($host->host_state_type == 0): ?>
<a href="#" title="Soft State">
<i>{{SOFTSTATE_ICON}}</i>
</a>
<?php endif; ?>
<b><?= ucfirst($viewHelper->monitoringState($host, 'host')); ?></b>
Since&nbsp;
<?= $this->timeSince($host->host_last_state_change); ?>
</div>
</td>
<td>
<?php if ($host->host_unhandled_service_count): ?>
<span class="badge pull-right">
<a href="<?= $this->href('monitoring/list/services', array('host' => $host->host_name, 'problem' => 1)); ?>">
<?= $host->host_unhandled_service_count; ?>
</a>
</span>
<?php endif; ?>
<a href="<?= $hostLink ?>">
<b> <?= $host->host_name ?></b><br/>
<i> <?= $host->host_address ?></i>
<b><?= $host->host_name ?></b><br/>
<i><?= $host->host_address ?></i>
</a>
<?php if ($host->host_action_url != ""): ?>
<?php if (!empty($host->host_action_url)): ?>
<a href="<?= $host->host_action_url; ?>">Action</a>
<?php endif; ?>
<?php if ($host->host_notes_url != ""): ?>
<a href="<?= $host->host_notes_url; ?>">Notes</a>
<?php if (!empty($host->host_notes_url)): ?>
<a href="<?= $host->host_notes_url; ?>">Notes</a>
<?php endif; ?>
</td>
<td>
<?= $this->escape(substr(strip_tags($host->host_output), 0, 10000)); ?>
</td>
</tr>
<?php endforeach; ?>
</tbody>
</table>
<?= $this->paginationControl($hosts, null, null, array('preserve' => $this->preserve)); ?>
<?= $this->paginationControl($hosts, null, null, array('preserve' => $this->preserve)); ?>
</div>

View File

@ -3,10 +3,11 @@
<?php
$viewHelper = $this->getHelper('MonitoringState');
?>
<div data-icinga-component="app/mainDetailGrid">
<?= $this->sortControl->render($this); ?>
<?= $this->paginationControl($this->services, null, null, array('preserve' => $this->preserve)) ?>
<?= $this->sortControl->render($this); ?>
<?= $this->paginationControl($this->services, null, null, array('preserve' => $this->preserve)); ?>
<table class="table table-condensed">
<thead>
@ -30,100 +31,106 @@ $viewHelper = $this->getHelper('MonitoringState');
'host' => $service->host_name,
)
);
?>
?>
<tr <?= ($this->activeRowHref === $serviceLink) ? 'class="active"' : ''; ?>>
<td>
<a style="visibility:hidden" href="<?= $serviceLink; ?>"></a>
<div>
<?php if ($service->service_icon_image) : ?>
<?php if ($service->service_icon_image) : ?>
<img src="<?= $service->service_icon_image; ?>"/>
<?php endif; ?>
</div>
<?php endif; ?>
</td>
<td>
<div>
<?php if (!$service->service_handled && $service->service_state > 0): ?>
<a href="#" title="<?= 'Unhandled service' ?>">
<i>{{UNHANDLED_ICON}}</i>
</a>
<?php endif; ?>
<?php if (!$service->service_handled && $service->service_state > 0): ?>
<a href="#" title="Unhandled">
<i>{{UNHANDLED_ICON}}</i>
</a>
<?php endif; ?>
<?php if ($service->service_acknowledged && !$service->service_in_downtime): ?>
<a href="#" title="<?= 'Acknowledged' ?>">
<i>{{ACKNOWLEDGED_ICON}}</i>
</a>
<?php endif; ?>
<?php if ($service->service_acknowledged && !$service->service_in_downtime): ?>
<a href="#" title="Acknowledged">
<i>{{ACKNOWLEDGED_ICON}}</i>
</a>
<?php endif; ?>
<?php if ($service->service_is_flapping): ?>
<a href="#" title="<?= 'Flapping' ?>">
<i>{{FLAPPING_ICON}}</i>
</a>
<?php endif; ?>
<?php if ($service->service_is_flapping): ?>
<a href="#" title="Flapping">
<i>{{FLAPPING_ICON}}</i>
</a>
<?php endif; ?>
<?php if (!$service->service_notifications_enabled): ?>
<a href="#" title="<?= 'Notifications disabled' ?>">
<i>{{NOTIFICATIONS_DISABLED_ICON}}</i>
</a>
<?php endif; ?>
<?php if (!$service->service_notifications_enabled): ?>
<a href="#" title="Notifications Disabled">
<i>{{NOTIFICATIONS_DISABLED_ICON}}</i>
</a>
<?php endif; ?>
<?php if ($service->service_in_downtime): ?>
<a href="#" title="<?= 'In downtime' ?>">
<i>{{IN_DOWNTIME_ICON}}</i>
</a>
<?php endif; ?>
<?php if ($service->service_in_downtime): ?>
<a href="#" title="In Downtime">
<i>{{IN_DOWNTIME_ICON}}</i>
</a>
<?php endif; ?>
</div>
</td>
<td title="<?= $viewHelper->getStateTitle($service, 'service'); ?>">
<div>
<b><?= ucfirst($viewHelper->monitoringState($service, 'service')); ?></b>
<div> Since&nbsp;
<?= $this->timeSince($service->service_last_state_change); ?>
<?php if ($service->service_state_type == 0): ?>
<a href="#" title="<?= 'Soft state' ?>">
<i>{{SOFTSTATE_ICON}}</i>
<?php if (!$service->service_active_checks_enabled): ?>
<?php if (!$service->service_passive_checks_enabled): ?>
<a href="#" title="Active And Passive Checks Disabled">
<i>{{ACTIVE_PASSIVE_CHECKS_DISABLED_ICON}}</i>
</a>
<?php else: ?>
<a href="#" title="Active Checks Disabled">
<i>{{ACTIVE_CHECKS_DISABLED_ICON}}</i>
</a>
<?php endif; ?>
</div>
</div>
</td>
<?php endif; ?>
<td>
<?php if ($service->service_last_comment !== null): ?>
<a href="#" title="<?= 'Comments' ?>">
<a href="#" title="Comments">
<i>{{COMMENT_ICON}}</i>
</a>
<?php endif; ?>
</td>
<td title="<?= $viewHelper->getStateTitle($service, 'service'); ?>">
<div>
<?php if ($service->service_state_type == 0): ?>
<a href="#" title="Soft State">
<i>{{SOFTSTATE_ICON}}</i>
</a>
<?php endif; ?>
<b><?= ucfirst($viewHelper->monitoringState($service, 'service')); ?></b>
Since&nbsp;
<?= $this->timeSince($service->service_last_state_change); ?>
</div>
</td>
<td>
<a href="<?= $serviceLink; ?>">
<b> <?= $service->service_display_name; ?></b>
</a>
<br/>
<?php if ($service->service_action_url != ""): ?>
<?php if (!empty($service->service_action_url)): ?>
<a href="<?= $service->service_action_url; ?>">Action</a>
<?php endif; ?>
<?php if ($service->service_notes_url != ""): ?>
<?php if (!empty($service->service_notes_url)): ?>
<a href="<?= $service->service_notes_url; ?>">Notes</a>
<?php endif; ?>
</td>
<td title="<?= $viewHelper->getStateTitle($service, 'host'); ?>">
<a href="<?= $hostLink; ?>">
<?= $service->host_name; ?>
<?php if (!$service->host_handled && $service->host_state > 0): ?>
<a href="#" title="Unhandled Host">
<i>{{UNHANDLED_ICON}}</i>
</a>
<?php endif; ?>
<a href="<?= $hostLink; ?>">
<b><?= $service->host_name; ?></b>
<?php if ($service->host_state != 0): ?>
(<?= ucfirst($viewHelper->monitoringState($service, 'host')); ?>)
<?php endif; ?>
<br /><?= $service->host_address ?>
</a>
<div>
(<?= ucfirst($viewHelper->monitoringState($service, 'host')); ?>)
</div>
<span>
<?= $service->host_address ?>
</span>
</td>
<td>
@ -133,4 +140,5 @@ $viewHelper = $this->getHelper('MonitoringState');
<?php endforeach; ?>
</tbody>
</table>
</div>
<?= $this->paginationControl($this->services, null, null, array('preserve' => $this->preserve)); ?>
</div>

View File

@ -4,83 +4,4 @@ $history->limit(10);
$hhistory = $this->history->paginate();
?>
<?php if (empty($hhistory)): ?>
There are no matching history entries right now
<?php else: ?>
<?= $this->paginationControl($hhistory, null, null, array('preserve' => $preserve)); ?>
<table class="table table-condensed">
<tbody>
<?php foreach ($hhistory as $event): ?>
<?php
if ($event->object_type == 'host') {
$states = array('up', 'down', 'unreachable', 'unknown', 99 => 'pending', null => 'pending');
} else {
$states = array('ok', 'warning', 'critical', 'unknown', 99 => 'pending', null => 'pending');
}
?>
<tr>
<td><?= date('d.m. H:i', $event->timestamp ) ?></td>
<? if (! $object): ?>
<td><?= $this->escape($event->host_name) ?></td>
<? endif ?>
<? if (! $object instanceof Icinga\Module\Monitoring\Object\Service): ?>
<td>
<? if ($object): ?>
<a href="<?= $this->href('monitoring/show/service',array(
'host' => $object->host_name,
'service' => $event->service_description
)); ?>"><?php $event->service_description; ?></a>
</a>
<? else: ?>
<?= $this->escape($event->service_description) ?>
<? endif ?>
</td>
<? endif ?>
<td>
<?php
switch ($event->type) {
case 'notify':
echo 'NOTIFICATION_ICON';
break;
case 'comment':
echo 'COMMENT_ICON';
break;
case 'ack':
echo 'ACKNOWLEDGEMENT_ICON';
break;
case 'dt_comment':
echo 'IN_DOWNTIME_ICON';
break;
case 'flapping':
echo 'FLAPPING_ICON';
break;
case 'hard_state':
echo 'HARDSTATE_ICON';
break;
case 'soft_state':
echo 'SOFTSTATE_ICON';
break;
case 'dt_start':
echo 'DOWNTIME_START_ICON';
echo ' Downtime start';
break;
case 'dt_end':
echo 'DOWNTIME_END_ICON';
echo ' Downtime end';
break;
}
?>
<? if ($event->attempt !== null): ?>
[ <?= $event->attempt ?>/<?=$event->max_attempts ?> ]
<? endif ?>
</td>
</tr>
<? endforeach ?>
</tbody>
</table>
<? endif ?>

View File

@ -15,3 +15,5 @@
<?= $this->render('show/components/perfdata.phtml'); ?>
<?= $this->render('show/components/properties.phtml'); ?>
<?= $this->render('show/components/eventHistory.phtml'); ?>

View File

@ -76,6 +76,8 @@ class HostAndServiceStatus extends DataView
'service_last_time_warning',
'service_last_time_critical',
'service_last_time_unknown',
'service_current_check_attempt',
'service_max_check_attempts'
// 'object_type',
// 'problems',
// 'handled',
@ -116,7 +118,7 @@ class HostAndServiceStatus extends DataView
public function getFilterColumns()
{
return array('hostgroups', 'servicegroups');
return array('hostgroups', 'servicegroups', 'service_problems');
}
protected function isValidFilterColumn($column)

View File

@ -142,4 +142,22 @@ abstract class AbstractObject
)->fetchPairs();
return $this;
}
protected function fetchEventHisoty()
{
$this->foreign['eventHistory'] = $this->applyObjectFilter(
$this->backend->select()->from('eventHistory', array(
'object_type',
'host_name',
'service_description',
'timestamp',
'state',
'attempt',
'max_attempts',
'output',
'type'
))
);
return $this;
}
}

View File

@ -31,7 +31,8 @@ class Service extends AbstractObject
->fetchContacts()
->fetchContactgroups()
->fetchCustomvars()
->fetchComments();
->fetchComments()
->fetchEventHisoty();
}
protected function fetchObject()
@ -59,6 +60,16 @@ class Service extends AbstractObject
'long_output' => 'service_long_output',
'check_command' => 'service_check_command',
'perfdata' => 'service_perfdata',
'current_check_attempt' => 'service_current_check_attempt',
'max_check_attemt' => 'service_max_check_attempts',
'state_type' => 'service_state_type',
'passive_checks_enabled' => 'service_passive_checks_enabled',
'last_state_change' => 'service_last_state_change',
'last_notification' => 'service_last_notification',
'current_notification_number' => 'service_current_notification_number',
'is_flapping' => 'service_is_flapping',
'percent_state_change' => 'service_percent_state_change',
'in_downtime' => 'service_in_downtime'
))
->where('host_name', $this->name1)
->where('service_description', $this->name2)