Add support for IPv6 address

refs #9645
This commit is contained in:
Markus Frosch 2015-07-16 10:35:28 +02:00
parent ceb32679d8
commit a14f800d9e
16 changed files with 49 additions and 15 deletions

View File

@ -77,6 +77,7 @@ class Monitoring_HostController extends MonitoredObjectController
'host_state_type',
'host_last_state_change',
'host_address',
'host_address6',
'host_handled',
'service_description',
'service_display_name',

View File

@ -52,6 +52,7 @@ class Monitoring_HostsController extends Controller
'host_icon_image_alt',
'host_name',
'host_address',
'host_address6',
'host_state',
'host_problem',
'host_handled',
@ -91,6 +92,7 @@ class Monitoring_HostsController extends Controller
'host_icon_image_alt',
'host_name',
'host_address',
'host_address6',
'host_state',
'host_problem',
'host_handled',

View File

@ -75,6 +75,7 @@ class Monitoring_ListController extends Controller
'host_display_name',
'host_state' => $stateColumn,
'host_address',
'host_address6',
'host_acknowledged',
'host_output',
'host_attempt',
@ -151,6 +152,7 @@ class Monitoring_ListController extends Controller
'host_state_type',
'host_last_state_change',
'host_address',
'host_address6',
'host_handled',
'service_description',
'service_display_name',

View File

@ -54,6 +54,7 @@ class Monitoring_ServicesController extends Controller
'host_icon_image_alt',
'host_name',
'host_address',
'host_address6',
'host_output',
'host_state',
'host_problem',
@ -101,6 +102,7 @@ class Monitoring_ServicesController extends Controller
'host_icon_image_alt',
'host_name',
'host_address',
'host_address6',
'host_output',
'host_state',
'host_problem',

View File

@ -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 ?>
<?php if ($object->host_address && $object->host_address !== $object->host_name): ?>
<br>
<?= $this->escape($object->host_address); ?>
<?= $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): ?>
<span class="address padded" title="IPv4 address"><?= $this->escape($object->host_address); ?></span>
<?php endif ?>
<?= $this->render('partials/host/statusicons.phtml'); ?>
</td>
</tr>
</table>

View File

@ -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 ?>
<?php if ($object->host_address && $object->host_address !== $object->host_name): ?>
<br>
<?= $this->escape($object->host_address); ?>
<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): ?>
<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' : ''; ?>">

View File

@ -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',

View File

@ -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',

View File

@ -39,6 +39,7 @@ class StatusQuery extends IdoQuery
'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',

View File

@ -15,6 +15,7 @@ class HostStatus extends DataView
'host_display_name',
'host_alias',
'host_address',
'host_address6',
'host_state',
'host_state_type',
'host_handled',

View File

@ -29,6 +29,7 @@ class ServiceStatus extends DataView
'host_state_type',
'host_last_state_change',
'host_address',
'host_address6',
'host_problem',
'host_handled',
'service_description',

View File

@ -96,6 +96,7 @@ class Host extends MonitoredObject
'host_active_checks_enabled',
'host_active_checks_enabled_changed',
'host_address',
'host_address6',
'host_alias',
'host_check_command',
'host_check_execution_time',

View File

@ -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'
);

View File

@ -111,6 +111,7 @@ class Service extends MonitoredObject
'host_acknowledged',
'host_active_checks_enabled',
'host_address',
'host_address6',
'host_alias',
'host_display_name',
'host_handled',

View File

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

View File

@ -16,11 +16,14 @@ class MacroTest extends BaseTestCase
$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()
@ -28,13 +31,16 @@ class MacroTest extends BaseTestCase
$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);
}