Add servicegroup and icon image to service overview

Add icon images for hosts and services, notes and action url
for hosts

refs #4181
This commit is contained in:
Jannis Moßhammer 2013-07-22 17:10:43 +02:00
parent a0839ea0da
commit 4ededd5179
5 changed files with 74 additions and 19 deletions

View File

@ -79,17 +79,30 @@ class Monitoring_ShowController extends ModuleActionController
if ($grapher = Hook::get('grapher')) { if ($grapher = Hook::get('grapher')) {
if ($grapher->hasGraph( if ($grapher->hasGraph(
$this->view->host->host_name, $this->view->service->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->service->host_name,
$this->view->service->service_description $this->view->service->service_description
); );
} }
} }
$this->view->servicegroups = $this->backend->select()
->from(
'servicegroup',
array(
'servicegroup_name',
'servicegroup_alias'
)
)
->where('host_name', $this->view->host->host_name)
->where('service_description', $this->view->service->service_description)
->fetchPairs();
$this->view->contacts = $this->backend->select() $this->view->contacts = $this->backend->select()
->from( ->from(
'contact', 'contact',
@ -350,15 +363,17 @@ class Monitoring_ShowController extends ModuleActionController
'urlParams' => $hostParams, 'urlParams' => $hostParams,
) )
); );
$tabs->add( if (!isset($this->view->service)) {
'services', $tabs->add(
array( 'services',
'title' => 'Services', array(
'icon' => 'img/classic/service.png', 'title' => 'Services',
'url' => 'monitoring/show/services', 'icon' => 'img/classic/service.png',
'urlParams' => $params, 'url' => 'monitoring/show/services',
) 'urlParams' => $params,
); )
);
}
if (isset($params['service'])) { if (isset($params['service'])) {
$tabs->add( $tabs->add(
'service', 'service',

View File

@ -6,6 +6,7 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
{ {
public function perfdata($perfdata, $compact = false, $float = 'right') public function perfdata($perfdata, $compact = false, $float = 'right')
{ {
if (empty($perfdata)) { if (empty($perfdata)) {
return ''; return '';
} }
@ -75,9 +76,15 @@ class Zend_View_Helper_Perfdata extends Zend_View_Helper_Abstract
. '</td></tr>'; . '</td></tr>';
} }
} }
if ($result == '') {
$result = $perfdata;
}
if (! $compact && $result !== '') { if (! $compact && $result !== '') {
$result = '<table style="width: 100%">' . $result . '</table>'; $result = '<table style="width: 100%">' . $result . '</table>';
} }
return $result; return $result;
} }
} }

View File

@ -1,6 +1,7 @@
<?php <?php
/** @var boolean $showService */ /** @var boolean $showService */
$showService = false; $showService = false;
if (isset($this->service) && $this->tabs->getActiveName() !== 'host') { if (isset($this->service) && $this->tabs->getActiveName() !== 'host') {
$showService = true; $showService = true;
} }
@ -30,9 +31,10 @@ if (!$this->compact) {
<table> <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> <td>
<?php if ($this->service->host_icon_image): ?>
<?php if ($this->host->host_icon_image) : ?>
<div class="monitoring_icon"> <div class="monitoring_icon">
<img src="<?= $this->service->host_icon_image; ?>" alt="Host image" /> <img src="<?= $this->host->host_icon_image; ?>" alt="Host image" />
</div> </div>
<?php endif; ?> <?php endif; ?>
<strong> <strong>
@ -55,6 +57,25 @@ if (!$this->compact) {
<?php } ?> <?php } ?>
</td> </td>
</tr> </tr>
<?php if ($this->host->host_action_url || $this->host->host_notes_url): ?>
<tr>
<td class="urls" rowspan="2">
<?php if ($this->host->host_action_url): ?>
<span class="url">
<a href='<?= $this->host->host_notes_url ?>'>Host actions </a>
</span>
<?php endif; ?>
<?php if ($this->host->host_notes_url): ?>
<span class="url">
<a href='<?= $this->host->host_notes_url ?>'>Host notes </a>
</span>
<?php endif; ?>
</td>
</tr>
<?php endif; ?>
<?php if ($showService === true): ?> <?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> <td>
@ -76,19 +97,25 @@ if (!$this->compact) {
</td> </td>
</tr> </tr>
<?php if ($this->service->service_action_url || $this->service->service_notes_url): ?> <?php if ($this->service->service_action_url || $this->service->service_notes_url): ?>
<tr> <tr>
<td class="urls" rowspan="2"> <td class="urls" rowspan="2">
<?php if ($this->service->service_action_url): ?>
<span class="url"> <span class="url">
<a href='<?= $this->service->service_notes_url ?>'>Actions </a> <a href='<?= $this->service->service_notes_url ?>'>Service actions </a>
</span> </span>
<?php endif; ?>
<?php if ($this->service->service_notes_url): ?>
<span class="url"> <span class="url">
<a href='<?= $this->service->service_notes_url ?>'>Notes </a> <a href='<?= $this->service->service_notes_url ?>'>Service notes </a>
</span> </span>
<?php endif; ?>
</td> </td>
</tr> </tr>
<?php endif; ?> <?php endif; ?>
<?php endif; ?> <?php endif; ?>
</table> </table>
<div class="clearfix"></div> <div class="clearfix"></div>

View File

@ -1,7 +1,8 @@
<?php <?php
$servicegroupLinkList = array(); $servicegroupLinkList = array();
if (!empty($this->hostgroups)) { if (!empty($this->servicegroups)) {
foreach ($this->hostgroups as $name => $alias) { foreach ($this->servicegroups as $name => $alias) {
$servicegroupLinkList[] = $this->qlink( $servicegroupLinkList[] = $this->qlink(
$alias, $alias,
'monitoring/list/services', 'monitoring/list/services',
@ -68,6 +69,7 @@ $this->partial(
<?php if ($this->service->service_perfdata): ?> <?php if ($this->service->service_perfdata): ?>
<div class="information-container"> <div class="information-container">
<div class="head"> <div class="head">
<span>Perfdata</span> <span>Perfdata</span>
</div> </div>

View File

@ -98,6 +98,7 @@ class AbstractBackend implements DatasourceInterface
'host_address', 'host_address',
'host_state', 'host_state',
'host_handled', 'host_handled',
'host_icon_image',
'host_in_downtime', 'host_in_downtime',
'host_acknowledged', 'host_acknowledged',
'host_check_command', 'host_check_command',
@ -105,7 +106,9 @@ class AbstractBackend implements DatasourceInterface
'host_alias', 'host_alias',
'host_output', 'host_output',
'host_long_output', 'host_long_output',
'host_perfdata' 'host_perfdata',
'host_notes_url',
'host_action_url'
); );
if ($fetchAll === true) { if ($fetchAll === true) {
@ -236,6 +239,7 @@ class AbstractBackend implements DatasourceInterface
$select = $this->select() $select = $this->select()
->from('status', $fields) ->from('status', $fields)
->where('service_description', $service)
->where('host_name', $host); ->where('host_name', $host);
return $select->fetchRow(); return $select->fetchRow();