Skip to content

Commit

Permalink
Merge branch 'master' into feature/allow-to-list-groups-from-a-ldap-b…
Browse files Browse the repository at this point in the history
…ackend-9772
  • Loading branch information
Johannes Meyer committed Sep 29, 2015
2 parents e5f035c + e20d791 commit 35e62ae
Show file tree
Hide file tree
Showing 24 changed files with 150 additions and 60 deletions.
3 changes: 2 additions & 1 deletion .puppet/modules/openldap/manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -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'],
}
Expand Down
21 changes: 10 additions & 11 deletions .puppet/modules/pgsql/manifests/init.pp
Original file line number Diff line number Diff line change
@@ -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:
#
Expand All @@ -17,26 +17,25 @@

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'],
}
}
27 changes: 23 additions & 4 deletions application/forms/Config/Resource/DbResourceForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -43,12 +43,30 @@ public function createElements(array $formData)
$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',
Expand Down Expand Up @@ -76,7 +94,8 @@ public function createElements(array $formData)
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'
)
);
Expand Down
29 changes: 23 additions & 6 deletions doc/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,41 @@ 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 = localhost
host = 127.0.0.1
port = 3306
username = icingaweb
password = icingaweb
dbname = icingaweb
[icingaweb-mysql-socket]
type = db
db = mysql
host = localhost
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
```
### <a id="resources-configuration-ldap"></a> LDAP
Expand Down
6 changes: 5 additions & 1 deletion library/Icinga/Web/FileCache.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
/* Icinga Web 2 | (c) 2013-2015 Icinga Development Team | GPLv2+ */

namespace Icinga\Web;

class FileCache
Expand Down Expand Up @@ -191,7 +192,7 @@ public function etagForCachedFile($file)
* Whether the given ETag matchesspecific file(s) on disk
*
* If no ETag is given we'll try to fetch the one from the current
* HTTP request.
* HTTP request. Respects HTTP Cache-Control: no-cache, if set.
*
* @param string|array $files file(s) to check
* @param string $match ETag to match against
Expand All @@ -208,6 +209,9 @@ public static function etagMatchesFiles($files, $match = null)
if (! $match) {
return false;
}
if (isset($_SERVER['HTTP_CACHE_CONTROL']) && $_SERVER['HTTP_CACHE_CONTROL'] === 'no-cache') {
return false;
}

$etag = self::etagForFiles($files);
return $match === $etag ? $etag : false;
Expand Down
3 changes: 2 additions & 1 deletion library/Icinga/Web/JavaScript.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class JavaScript
'js/icinga/behavior/tristate.js',
'js/icinga/behavior/navigation.js',
'js/icinga/behavior/form.js',
'js/icinga/behavior/actiontable.js'
'js/icinga/behavior/actiontable.js',
'js/icinga/behavior/selectable.js'
);

protected static $vendorFiles = array(
Expand Down
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 @@ -55,6 +55,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 @@ -92,6 +93,7 @@ public function showAction()
'host_icon_image_alt',
'host_name',
'host_address',
'host_address6',
'host_state',
'host_problem',
'host_handled',
Expand Down
19 changes: 2 additions & 17 deletions modules/monitoring/application/controllers/ListController.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,23 +58,17 @@ public function hostsAction()
'host_name',
'host_display_name',
'host_state' => $stateColumn,
'host_address',
'host_acknowledged',
'host_output',
'host_attempt',
'host_in_downtime',
'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);
Expand Down Expand Up @@ -132,10 +126,6 @@ public function servicesAction()
'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,
Expand All @@ -152,14 +142,9 @@ public function servicesAction()
'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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,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 @@ -10,15 +10,18 @@ use Icinga\Module\Monitoring\Object\Host;
</td>
<td>
<?= $this->iconImage()->host($object) ?>
<strong><?= $this->escape($object->host_display_name); ?></strong>
<strong class="selectable"><?= $this->escape($object->host_display_name); ?></strong>
<?php if ($object->host_display_name !== $object->host_name): ?>
<small>(<?= $this->escape($object->host_name); ?>)</small>
<small class="selectable">(<?= $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="selectable" 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="selectable" 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 @@ -11,15 +11,17 @@ use Icinga\Module\Monitoring\Object\Service;
</td>
<td>
<?= $this->iconImage()->service($object) ?>
<strong><?= $this->escape($object->host_display_name); ?></strong>
<strong class="selectable"><?= $this->escape($object->host_display_name); ?></strong>
<?php if ($object->host_display_name !== $object->host_name): ?>
<small>(<?= $this->escape($object->host_name); ?>)</small>
<small class="selectable">(<?= $this->escape($object->host_name); ?>)</small>
<?php endif ?>
<br/>
<?php if ($object->host_address6 && $object->host_address6 !== $object->host_name): ?>
<span class="selectable" 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="selectable" 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 All @@ -29,7 +31,7 @@ use Icinga\Module\Monitoring\Object\Service;
</td>
<td>
<?= $this->iconImage()->host($object) ?>
<strong><?= $this->translate('Service'); ?>: <?= $this->escape($object->service_display_name); ?></strong>
<strong><?= $this->translate('Service'); ?>: <span class="selectable"><?= $this->escape($object->service_display_name); ?></span></strong>
<?php if ($object->service_display_name !== $object->service_description): ?>
<small>(<?= $this->escape($object->service_description); ?>)</small>
<?php endif ?>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -832,7 +832,7 @@ protected function joinCustomvar($customvar)
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';
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
2 changes: 1 addition & 1 deletion modules/monitoring/library/Monitoring/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ protected function getRestriction($name)
'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) {
Expand Down
6 changes: 5 additions & 1 deletion modules/monitoring/library/Monitoring/DataView/DataView.php
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,11 @@ public static function fromParams(array $params, array $columns = null)
*/
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());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ public function getColumns()
'host_display_name',
'host_alias',
'host_address',
'host_address6',
'host_state',
'host_state_type',
'host_handled',
Expand Down

0 comments on commit 35e62ae

Please sign in to comment.