Skip to content

Commit

Permalink
Add support for IPv6 address
Browse files Browse the repository at this point in the history
refs #9645
  • Loading branch information
lazyfrosch committed Aug 4, 2015
1 parent ceb3267 commit a14f800
Show file tree
Hide file tree
Showing 16 changed files with 47 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ public function servicesAction()
'host_state_type',
'host_last_state_change',
'host_address',
'host_address6',
'host_handled',
'service_description',
'service_display_name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ protected function handleCommandForm(ObjectsCommandForm $form)
'host_icon_image_alt',
'host_name',
'host_address',
'host_address6',
'host_state',
'host_problem',
'host_handled',
Expand Down Expand Up @@ -91,6 +92,7 @@ public function showAction()
'host_icon_image_alt',
'host_name',
'host_address',
'host_address6',
'host_state',
'host_problem',
'host_handled',
Expand Down
2 changes: 2 additions & 0 deletions modules/monitoring/application/controllers/ListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ public function hostsAction()
'host_display_name',
'host_state' => $stateColumn,
'host_address',
'host_address6',
'host_acknowledged',
'host_output',
'host_attempt',
Expand Down Expand Up @@ -151,6 +152,7 @@ public function servicesAction()
'host_state_type',
'host_last_state_change',
'host_address',
'host_address6',
'host_handled',
'service_description',
'service_display_name',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ protected function handleCommandForm(ObjectsCommandForm $form)
'host_icon_image_alt',
'host_name',
'host_address',
'host_address6',
'host_output',
'host_state',
'host_problem',
Expand Down Expand Up @@ -101,6 +102,7 @@ public function showAction()
'host_icon_image_alt',
'host_name',
'host_address',
'host_address6',
'host_output',
'host_state',
'host_problem',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,14 @@ use Icinga\Module\Monitoring\Object\Host;
<?php if ($object->host_display_name !== $object->host_name): ?>
<small>(<?= $this->escape($object->host_name); ?>)</small>
<?php endif ?>
<?= $this->render('partials/host/statusicons.phtml'); ?>
<br/>
<?php if ($object->host_address6 && $object->host_address6 !== $object->host_name): ?>
<span class="address padded" title="IPv6 address"><?= $this->escape($object->host_address6); ?></span>
<?php endif ?>
<?php if ($object->host_address && $object->host_address !== $object->host_name): ?>
<br>
<?= $this->escape($object->host_address); ?>
<span class="address padded" title="IPv4 address"><?= $this->escape($object->host_address); ?></span>
<?php endif ?>
<?= $this->render('partials/host/statusicons.phtml'); ?>
</td>
</tr>
</table>
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ use Icinga\Module\Monitoring\Object\Service;
<?php if ($object->host_display_name !== $object->host_name): ?>
<small>(<?= $this->escape($object->host_name); ?>)</small>
<?php endif ?>
<br/>
<?php if ($object->host_address6 && $object->host_address6 !== $object->host_name): ?>
<span class="address padded" title="IPv6 address"><?= $this->escape($object->host_address6); ?></span>
<?php endif ?>
<?php if ($object->host_address && $object->host_address !== $object->host_name): ?>
<br>
<?= $this->escape($object->host_address); ?>
<span class="address padded" title="IPv4 address"><?= $this->escape($object->host_address); ?></span>
<?php endif ?>
<?= $this->render('partials/host/statusicons.phtml'); ?>
</td>
</tr>
<tr class="state <?= Service::getStateText($object->service_state); ?><?= $object->service_handled ? ' handled' : ''; ?>">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class HoststatusQuery extends IdoQuery
'host' => 'ho.name1 COLLATE latin1_general_ci',
'host_action_url' => 'h.action_url',
'host_address' => 'h.address',
'host_address6' => 'h.address6',
'host_alias' => 'h.alias',
'host_display_name' => 'h.display_name COLLATE latin1_general_ci',
'host_icon_image' => 'h.icon_image',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class ServicestatusQuery extends IdoQuery
'hosts' => array(
'host_action_url' => 'h.action_url',
'host_address' => 'h.address',
'host_address6' => 'h.address6',
'host_alias' => 'h.alias COLLATE latin1_general_ci',
'host_display_name' => 'h.display_name COLLATE latin1_general_ci',
'host_icon_image' => 'h.icon_image',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public function setMode($mode)
'host_display_name' => 'h.display_name COLLATE latin1_general_ci',
'host_alias' => 'h.alias',
'host_address' => 'h.address',
'host_address6' => 'h.address6',
'host_ipv4' => 'INET_ATON(h.address)',
'host_icon_image' => 'h.icon_image',
'host_icon_image_alt' => 'h.icon_image_alt',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public function getColumns()
'host_display_name',
'host_alias',
'host_address',
'host_address6',
'host_state',
'host_state_type',
'host_handled',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function getColumns()
'host_state_type',
'host_last_state_change',
'host_address',
'host_address6',
'host_problem',
'host_handled',
'service_description',
Expand Down
1 change: 1 addition & 0 deletions modules/monitoring/library/Monitoring/Object/Host.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ protected function getDataView()
'host_active_checks_enabled',
'host_active_checks_enabled_changed',
'host_address',
'host_address6',
'host_alias',
'host_check_command',
'host_check_execution_time',
Expand Down
12 changes: 7 additions & 5 deletions modules/monitoring/library/Monitoring/Object/Macro.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ class Macro
* @var array
*/
private static $icingaMacros = array(
'HOSTNAME' => 'host_name',
'HOSTADDRESS' => 'host_address',
'SERVICEDESC' => 'service_description',
'host.name' => 'host_name',
'host.address' => 'host_address',
'HOSTNAME' => 'host_name',
'HOSTADDRESS' => 'host_address',
'HOSTADDRESS6' => 'host_address6',
'SERVICEDESC' => 'service_description',
'host.name' => 'host_name',
'host.address' => 'host_address',
'host.address6' => 'host_address6',
'service.description' => 'service_description'
);

Expand Down
1 change: 1 addition & 0 deletions modules/monitoring/library/Monitoring/Object/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ protected function getDataView()
'host_acknowledged',
'host_active_checks_enabled',
'host_address',
'host_address6',
'host_alias',
'host_display_name',
'host_handled',
Expand Down
11 changes: 9 additions & 2 deletions modules/monitoring/public/css/module.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@
width: 16em;
}

p.pluginoutput {
width: 100%;
.padded {
padding: 0 5px;
}

.address, p.pluginoutput {
white-space: pre-wrap;
font-family: 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', 'DejaVu Sans Mono', 'Courier New', Courier, monospace;
}

p.pluginoutput {
width: 100%;
}

table.action td .pluginoutput {
font-size: 0.875em;
line-height: 1.2em;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,25 +16,31 @@ public function testHostMacros()
$hostMock = Mockery::mock('host');
$hostMock->host_name = 'test';
$hostMock->host_address = '1.1.1.1';
$hostMock->host_address6 = '::1';

$this->assertEquals(Macro::resolveMacros('$HOSTNAME$', $hostMock), $hostMock->host_name);
$this->assertEquals(Macro::resolveMacros('$HOSTADDRESS$', $hostMock), $hostMock->host_address);
$this->assertEquals(Macro::resolveMacros('$HOSTADDRESS6$', $hostMock), $hostMock->host_address6);
$this->assertEquals(Macro::resolveMacros('$host.name$', $hostMock), $hostMock->host_name);
$this->assertEquals(Macro::resolveMacros('$host.address$', $hostMock), $hostMock->host_address);
$this->assertEquals(Macro::resolveMacros('$host.address6$', $hostMock), $hostMock->host_address6);
}

public function testServiceMacros()
{
$svcMock = Mockery::mock('service');
$svcMock->host_name = 'test';
$svcMock->host_address = '1.1.1.1';
$svcMock->host_address6 = '::1';
$svcMock->service_description = 'a service';

$this->assertEquals(Macro::resolveMacros('$HOSTNAME$', $svcMock), $svcMock->host_name);
$this->assertEquals(Macro::resolveMacros('$HOSTADDRESS$', $svcMock), $svcMock->host_address);
$this->assertEquals(Macro::resolveMacros('$HOSTADDRESS6$', $svcMock), $svcMock->host_address6);
$this->assertEquals(Macro::resolveMacros('$SERVICEDESC$', $svcMock), $svcMock->service_description);
$this->assertEquals(Macro::resolveMacros('$host.name$', $svcMock), $svcMock->host_name);
$this->assertEquals(Macro::resolveMacros('$host.address$', $svcMock), $svcMock->host_address);
$this->assertEquals(Macro::resolveMacros('$host.address6$', $svcMock), $svcMock->host_address6);
$this->assertEquals(Macro::resolveMacros('$service.description$', $svcMock), $svcMock->service_description);
}

Expand Down

0 comments on commit a14f800

Please sign in to comment.