diff --git a/.puppet/modules/openldap/manifests/init.pp b/.puppet/modules/openldap/manifests/init.pp index a0480632e..ee62e9b64 100644 --- a/.puppet/modules/openldap/manifests/init.pp +++ b/.puppet/modules/openldap/manifests/init.pp @@ -14,11 +14,12 @@ # class openldap { - package { ['openldap-servers', 'openldap-clients']: + package { [ 'openldap-servers', 'openldap-clients', ]: ensure => latest, } service { 'slapd': + enable => true, ensure => running, require => Package['openldap-servers'], } diff --git a/.puppet/modules/pgsql/manifests/init.pp b/.puppet/modules/pgsql/manifests/init.pp index 4b48cf895..dfa105d65 100644 --- a/.puppet/modules/pgsql/manifests/init.pp +++ b/.puppet/modules/pgsql/manifests/init.pp @@ -1,7 +1,7 @@ # Class: pgsql # -# This class installs the postgresql server and client software. -# Further it configures pg_hba.conf to trus the local icinga user. +# This class installs the PostgreSQL server and client software. +# Further it configures pg_hba.conf to trust the local icinga user. # # Parameters: # @@ -17,26 +17,25 @@ class pgsql { Exec { path => '/sbin:/bin:/usr/bin' } - package { [ - 'postgresql', 'postgresql-server' - ]: - ensure => latest, + package { [ 'postgresql', 'postgresql-server', ]: + ensure => latest, } exec { 'initdb': - creates => '/var/lib/pgsql/data/pg_xlog', command => 'service postgresql initdb', - require => Package['postgresql-server'] + creates => '/var/lib/pgsql/data/pg_xlog', + require => Package['postgresql-server'], } service { 'postgresql': + enable => true, ensure => running, - require => [Package['postgresql-server'], Exec['initdb']] + require => [ Package['postgresql-server'], Exec['initdb'], ] } file { '/var/lib/pgsql/data/pg_hba.conf': content => template('pgsql/pg_hba.conf.erb'), - require => [Package['postgresql-server'], Exec['initdb']], - notify => Service['postgresql'] + require => [ Package['postgresql-server'], Exec['initdb'], ], + notify => Service['postgresql'], } } diff --git a/application/forms/Config/Resource/DbResourceForm.php b/application/forms/Config/Resource/DbResourceForm.php index d79ad248b..2487ef375 100644 --- a/application/forms/Config/Resource/DbResourceForm.php +++ b/application/forms/Config/Resource/DbResourceForm.php @@ -3,8 +3,8 @@ namespace Icinga\Forms\Config\Resource; -use Icinga\Web\Form; use Icinga\Application\Platform; +use Icinga\Web\Form; /** * Form class for adding/modifying database resources @@ -43,12 +43,30 @@ class DbResourceForm extends Form $dbChoices['oci'] = 'Oracle (OCI8)'; } $offerPostgres = false; + $offerMysql = false; if (isset($formData['db'])) { if ($formData['db'] === 'pgsql') { $offerPostgres = true; + } elseif ($formData['db'] === 'mysql') { + $offerMysql = true; } - } elseif (key($dbChoices) === 'pgsql') { - $offerPostgres = true; + } else { + $dbChoice = key($dbChoices); + if ($dbChoice === 'pgsql') { + $offerPostgres = true; + } elseif ($dbChoices === 'mysql') { + $offerMysql = true; + } + } + $socketInfo = ''; + if ($offerPostgres) { + $socketInfo = $this->translate( + 'For using unix domain sockets, specify the path to the unix domain socket directory' + ); + } elseif ($offerMysql) { + $socketInfo = $this->translate( + 'For using unix domain sockets, specify localhost' + ); } $this->addElement( 'text', @@ -76,7 +94,8 @@ class DbResourceForm extends Form array ( 'required' => true, 'label' => $this->translate('Host'), - 'description' => $this->translate('The hostname of the database'), + 'description' => $this->translate('The hostname of the database') + . ($socketInfo ? '. ' . $socketInfo : ''), 'value' => 'localhost' ) ); diff --git a/doc/resources.md b/doc/resources.md index a2bfb66af..6b43ca3d3 100644 --- a/doc/resources.md +++ b/doc/resources.md @@ -19,21 +19,38 @@ to handle authentication and authorization, monitoring data or user preferences. Directive | Description ----------------|------------ **type** | `db` -**db** | Database management system. Either `mysql` or `pgsql`. -**host** | Connect to the database server on the given host. -**port** | Port number to use for the connection. +**db** | Database management system. In most cases `mysql` or `pgsql`. +**host** | Connect to the database server on the given host. For using unix domain sockets, specify `localhost` for MySQL and the path to the unix domain socket directory for PostgreSQL. +**port** | Port number to use. Mandatory for connections to a PostgreSQL database. **username** | The username to use when connecting to the server. **password** | The password to use when connecting to the server. **dbname** | The database to use. **Example:** -``` -[icingaweb] +```` +[icingaweb-mysql-tcp] +type = db +db = mysql +host = 127.0.0.1 +port = 3306 +username = icingaweb +password = icingaweb +dbname = icingaweb + +[icingaweb-mysql-socket] type = db db = mysql host = localhost -port = 3306 +username = icingaweb +password = icingaweb +dbname = icingaweb + +[icingaweb-pgsql-socket] +type = db +db = pgsql +host = /var/run/postgresql +port = 5432 username = icingaweb password = icingaweb dbname = icingaweb diff --git a/library/Icinga/Web/FileCache.php b/library/Icinga/Web/FileCache.php index 57c0c0964..208640868 100644 --- a/library/Icinga/Web/FileCache.php +++ b/library/Icinga/Web/FileCache.php @@ -1,5 +1,6 @@ $stateColumn, - 'host_address', 'host_acknowledged', 'host_output', 'host_attempt', @@ -66,15 +65,10 @@ class ListController extends Controller 'host_is_flapping', 'host_state_type', 'host_handled', - 'host_last_check', 'host_last_state_change' => $stateChangeColumn, 'host_notifications_enabled', - 'host_action_url', - 'host_notes_url', 'host_active_checks_enabled', - 'host_passive_checks_enabled', - 'host_current_check_attempt', - 'host_max_check_attempts' + 'host_passive_checks_enabled' ), $this->addColumns())); $this->applyRestriction('monitoring/filter/objects', $query); $this->filterQuery($query); @@ -132,10 +126,6 @@ class ListController extends Controller 'host_name', 'host_display_name', 'host_state', - 'host_state_type', - 'host_last_state_change', - 'host_address', - 'host_handled', 'service_description', 'service_display_name', 'service_state' => $stateColumn, @@ -152,14 +142,9 @@ class ListController extends Controller 'service_state_type', 'service_handled', 'service_severity', - 'service_last_check', 'service_notifications_enabled', - 'service_action_url', - 'service_notes_url', 'service_active_checks_enabled', - 'service_passive_checks_enabled', - 'current_check_attempt' => 'service_current_check_attempt', - 'max_check_attempts' => 'service_max_check_attempts' + 'service_passive_checks_enabled' ), $this->addColumns()); $query = $this->backend->select()->from('servicestatus', $columns); $this->applyRestriction('monitoring/filter/objects', $query); diff --git a/modules/monitoring/application/controllers/ServicesController.php b/modules/monitoring/application/controllers/ServicesController.php index 26561f8ff..6d9342d19 100644 --- a/modules/monitoring/application/controllers/ServicesController.php +++ b/modules/monitoring/application/controllers/ServicesController.php @@ -56,6 +56,7 @@ class ServicesController extends Controller 'host_icon_image_alt', 'host_name', 'host_address', + 'host_address6', 'host_output', 'host_state', 'host_problem', @@ -101,6 +102,7 @@ class ServicesController extends Controller 'host_icon_image_alt', 'host_name', 'host_address', + 'host_address6', 'host_output', 'host_state', 'host_problem', diff --git a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml index 1a2fc356d..6b8cbc8d1 100644 --- a/modules/monitoring/application/views/scripts/partials/host/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/host/object-header.phtml @@ -10,15 +10,18 @@ use Icinga\Module\Monitoring\Object\Host; iconImage()->host($object) ?> - escape($object->host_display_name); ?> + escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> - (escape($object->host_name); ?>) + (escape($object->host_name); ?>) + + render('partials/host/statusicons.phtml'); ?> +
+ host_address6 && $object->host_address6 !== $object->host_name): ?> + escape($object->host_address6); ?> host_address && $object->host_address !== $object->host_name): ?> -
- escape($object->host_address); ?> + escape($object->host_address); ?> - render('partials/host/statusicons.phtml'); ?> diff --git a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml index c3df4044b..908ddb37f 100644 --- a/modules/monitoring/application/views/scripts/partials/service/object-header.phtml +++ b/modules/monitoring/application/views/scripts/partials/service/object-header.phtml @@ -11,15 +11,17 @@ use Icinga\Module\Monitoring\Object\Service; iconImage()->service($object) ?> - escape($object->host_display_name); ?> + escape($object->host_display_name); ?> host_display_name !== $object->host_name): ?> - (escape($object->host_name); ?>) + (escape($object->host_name); ?>) + +
+ host_address6 && $object->host_address6 !== $object->host_name): ?> + escape($object->host_address6); ?> host_address && $object->host_address !== $object->host_name): ?> -
- escape($object->host_address); ?> + escape($object->host_address); ?> - render('partials/host/statusicons.phtml'); ?> @@ -29,7 +31,7 @@ use Icinga\Module\Monitoring\Object\Service; iconImage()->host($object) ?> - translate('Service'); ?>: escape($object->service_display_name); ?> + translate('Service'); ?>: escape($object->service_display_name); ?> service_display_name !== $object->service_description): ?> (escape($object->service_description); ?>) diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php index 02a2fb8fb..d888daa78 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/HoststatusQuery.php @@ -28,6 +28,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', diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php index 122e13dc0..1480e2834 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/IdoQuery.php @@ -832,7 +832,7 @@ abstract class IdoQuery extends DbQuery list($type, $name) = $this->customvarNameToTypeName($customvar); $alias = ($type === 'host' ? 'hcv_' : 'scv_') . $name; - $this->customVars[$customvar] = $alias; + $this->customVars[strtolower($customvar)] = $alias; if ($this->hasJoinedVirtualTable('services')) { $leftcol = 's.' . $type . '_object_id'; diff --git a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php index a4b1d7272..f2582d211 100644 --- a/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php +++ b/modules/monitoring/library/Monitoring/Backend/Ido/Query/ServicestatusQuery.php @@ -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', diff --git a/modules/monitoring/library/Monitoring/Controller.php b/modules/monitoring/library/Monitoring/Controller.php index 1dc1d28eb..e1c16c854 100644 --- a/modules/monitoring/library/Monitoring/Controller.php +++ b/modules/monitoring/library/Monitoring/Controller.php @@ -82,7 +82,7 @@ class Controller extends IcingaWebController 'service_description', 'servicegroup_name', function ($c) { - return preg_match('/^_(?:host|service)_/', $c); + return preg_match('/^_(?:host|service)_/i', $c); } )); foreach ($this->getRestrictions($name) as $filter) { diff --git a/modules/monitoring/library/Monitoring/DataView/DataView.php b/modules/monitoring/library/Monitoring/DataView/DataView.php index 845aa4db4..50cd436fd 100644 --- a/modules/monitoring/library/Monitoring/DataView/DataView.php +++ b/modules/monitoring/library/Monitoring/DataView/DataView.php @@ -185,7 +185,11 @@ abstract class DataView implements QueryInterface, SortRules, FilterColumns, Ite */ public function isValidFilterTarget($column) { - return in_array($column, $this->getFilterColumns()); + // Customvar + if ($column[0] === '_' && preg_match('/^_(?:host|service)_/i', $column)) { + return true; + } + return in_array($column, $this->getColumns()) || in_array($column, $this->getStaticFilterColumns()); } /** diff --git a/modules/monitoring/library/Monitoring/DataView/Hoststatus.php b/modules/monitoring/library/Monitoring/DataView/Hoststatus.php index f30e00193..f2fe139ec 100644 --- a/modules/monitoring/library/Monitoring/DataView/Hoststatus.php +++ b/modules/monitoring/library/Monitoring/DataView/Hoststatus.php @@ -16,6 +16,7 @@ class HostStatus extends DataView 'host_display_name', 'host_alias', 'host_address', + 'host_address6', 'host_state', 'host_state_type', 'host_handled', diff --git a/modules/monitoring/library/Monitoring/DataView/Servicestatus.php b/modules/monitoring/library/Monitoring/DataView/Servicestatus.php index 8c19cb1ab..ff63e8604 100644 --- a/modules/monitoring/library/Monitoring/DataView/Servicestatus.php +++ b/modules/monitoring/library/Monitoring/DataView/Servicestatus.php @@ -18,6 +18,7 @@ class ServiceStatus extends DataView 'host_state_type', 'host_last_state_change', 'host_address', + 'host_address6', 'host_problem', 'host_handled', 'service_description', diff --git a/modules/monitoring/library/Monitoring/Object/Host.php b/modules/monitoring/library/Monitoring/Object/Host.php index 75c31c3ea..49f2f4306 100644 --- a/modules/monitoring/library/Monitoring/Object/Host.php +++ b/modules/monitoring/library/Monitoring/Object/Host.php @@ -95,6 +95,7 @@ class Host extends MonitoredObject 'host_active_checks_enabled', 'host_active_checks_enabled_changed', 'host_address', + 'host_address6', 'host_alias', 'host_attempt', 'host_check_command', diff --git a/modules/monitoring/library/Monitoring/Object/Macro.php b/modules/monitoring/library/Monitoring/Object/Macro.php index 0a6f3a8c0..45ea761ac 100644 --- a/modules/monitoring/library/Monitoring/Object/Macro.php +++ b/modules/monitoring/library/Monitoring/Object/Macro.php @@ -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' ); diff --git a/modules/monitoring/library/Monitoring/Object/Service.php b/modules/monitoring/library/Monitoring/Object/Service.php index f4f3ce748..ee75706ea 100644 --- a/modules/monitoring/library/Monitoring/Object/Service.php +++ b/modules/monitoring/library/Monitoring/Object/Service.php @@ -112,6 +112,7 @@ class Service extends MonitoredObject 'host_acknowledged', 'host_active_checks_enabled', 'host_address', + 'host_address6', 'host_alias', 'host_display_name', 'host_handled', diff --git a/modules/monitoring/test/php/library/Monitoring/Object/MacroTest.php b/modules/monitoring/test/php/library/Monitoring/Object/MacroTest.php index e1b3595e3..89dae3b4d 100644 --- a/modules/monitoring/test/php/library/Monitoring/Object/MacroTest.php +++ b/modules/monitoring/test/php/library/Monitoring/Object/MacroTest.php @@ -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); } diff --git a/public/js/icinga/behavior/selectable.js b/public/js/icinga/behavior/selectable.js new file mode 100644 index 000000000..a628ed729 --- /dev/null +++ b/public/js/icinga/behavior/selectable.js @@ -0,0 +1,36 @@ +/*! Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */ + +;(function(Icinga, $) { + 'use strict'; + + Icinga.Behaviors = Icinga.Behaviors || {}; + + var Selectable = function(icinga) { + Icinga.EventListener.call(this, icinga); + this.on('rendered', this.onRendered, this); + }; + + $.extend(Selectable.prototype, new Icinga.EventListener(), { + onRendered: function(e) { + $('.selectable', e.target).on('dblclick', e.data.self.selectText); + }, + + selectText: function(e) { + var b = document.body, + r; + if (b.createTextRange) { + r = b.createTextRange(); + r.moveToElementText(e.target); + r.select(); + } else if (window.getSelection) { + var s = window.getSelection(); + r = document.createRange(); + r.selectNodeContents(e.target); + s.removeAllRanges(); + s.addRange(r); + } + } + }); + + Icinga.Behaviors.Selectable = Selectable; +})(Icinga, jQuery);