From 8b9d446d2ed766f9c8793d6751969f642ca77940 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 29 Jul 2014 10:42:43 +0200 Subject: [PATCH 01/49] Autologin: Remove deprecated autologin methods Remove methods from manager because autologin is now handled with special backends (AutoLoginBackend). The session is used to store the status about a remote user authentication to send a 401 header to the client upon logout. refs #6461 --- .../controllers/AuthenticationController.php | 9 +++++- library/Icinga/Authentication/Manager.php | 31 ------------------- 2 files changed, 8 insertions(+), 32 deletions(-) diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index bbb475989..47825c210 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -14,6 +14,7 @@ use Icinga\Exception\AuthenticationException; use Icinga\Exception\NotReadableError; use Icinga\Exception\ConfigurationError; use Icinga\User; +use Icinga\Web\Session; use Icinga\Web\Url; /** @@ -67,6 +68,9 @@ class AuthenticationController extends ActionController $authenticated = $backend->authenticate($user); if ($authenticated === true) { $auth->setAuthenticated($user); + $session = Session::getSession()->getNamespace('authentication'); + $session->set('is_remote_user', true); + $session->write(); $this->rerenderLayout()->redirectNow($redirectUrl); } } @@ -131,9 +135,12 @@ class AuthenticationController extends ActionController public function logoutAction() { $auth = $this->Auth(); + + $session = Session::getSession()->getNamespace('authentication'); + $auth->removeAuthorization(); - if ($auth->isAuthenticatedFromRemoteUser()) { + if ($session->get('is_remote_user', false) === true) { $this->_helper->layout->setLayout('login'); $this->_response->setHttpResponseCode(401); } else { diff --git a/library/Icinga/Authentication/Manager.php b/library/Icinga/Authentication/Manager.php index 01964ef00..a0465d306 100644 --- a/library/Icinga/Authentication/Manager.php +++ b/library/Icinga/Authentication/Manager.php @@ -204,35 +204,4 @@ class Manager { return $this->user->getGroups(); } - - /** - * Tries to authenticate the user from the session, and then from the REMOTE_USER superglobal, that can be set by - * an external authentication provider. - */ - public function authenticateFromRemoteUser() - { - if (array_key_exists('REMOTE_USER', $_SERVER)) { - $this->fromRemoteUser = true; - } - $this->authenticateFromSession(); - if ($this->user !== null) { - if (array_key_exists('REMOTE_USER', $_SERVER) && $this->user->getUsername() !== $_SERVER["REMOTE_USER"]) { - // Remote user has changed, clear all sessions - $this->removeAuthorization(); - } - return; - } - if (array_key_exists('REMOTE_USER', $_SERVER) && $_SERVER["REMOTE_USER"]) { - $this->user = new User($_SERVER["REMOTE_USER"]); - $this->persistCurrentUser(); - } - } - - /** - * If the session was established from the REMOTE_USER server variable. - */ - public function isAuthenticatedFromRemoteUser() - { - return $this->fromRemoteUser; - } } From d05e3bfcca5a18bf862ef69af07a5014db3f997b Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 29 Jul 2014 11:11:52 +0200 Subject: [PATCH 02/49] Autologin: Fix javascript logout code Window onload event handler comes to late. Change part of the code to use jQuery. refs #6461 --- .../views/scripts/authentication/logout.phtml | 41 ++++--------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/application/views/scripts/authentication/logout.phtml b/application/views/scripts/authentication/logout.phtml index eb0d6dc44..9b03d190f 100644 --- a/application/views/scripts/authentication/logout.phtml +++ b/application/views/scripts/authentication/logout.phtml @@ -7,10 +7,7 @@ in every further request until the browser was closed. To allow logout and to allow the user to change the logged-in user this JavaScript provides a workaround to force a new authentication prompt in most browsers. --> - -
-
-
+

-
-
-
-
- +
-
- From 64954e99244f26cc6b6dccc7d60a253c105bd550 Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Tue, 29 Jul 2014 12:06:43 +0200 Subject: [PATCH 03/49] Autologin: Test logged session against remote user fixes #6462 --- library/Icinga/Authentication/Manager.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/Icinga/Authentication/Manager.php b/library/Icinga/Authentication/Manager.php index a0465d306..7009d51ab 100644 --- a/library/Icinga/Authentication/Manager.php +++ b/library/Icinga/Authentication/Manager.php @@ -117,6 +117,13 @@ class Manager public function authenticateFromSession() { $this->user = Session::getSession()->get('user'); + + if ($this->user + && array_key_exists('REMOTE_USER', $_SERVER) + && $this->user->getUsername() !== $_SERVER['REMOTE_USER'] + ) { + $this->removeAuthorization(); + } } /** From 0b1aee8a35a1b8fd0f88843bf2d12f997db7a951 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Tue, 29 Jul 2014 13:04:20 +0200 Subject: [PATCH 04/49] Vagrant: Fix Icinga 2 MySQL creation refs #6741 --- .vagrant-puppet/manifests/default.pp | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp index 68affd347..c05743719 100644 --- a/.vagrant-puppet/manifests/default.pp +++ b/.vagrant-puppet/manifests/default.pp @@ -5,8 +5,8 @@ include openldap Exec { path => '/bin:/usr/bin:/sbin' } -$icingaVersion = '1.11.2' -$icinga2Version = '2.0.0' +$icingaVersion = '1.11.5' +$icinga2Version = '2.0.1' exec { 'create-mysql-icinga-db': unless => 'mysql -uicinga -picinga icinga', @@ -421,11 +421,10 @@ package { 'icinga2-ido-mysql': exec { 'populate-icinga2-mysql-db': unless => 'mysql -uicinga2 -picinga2 icinga2 -e "SELECT * FROM icinga_dbversion;" &> /dev/null', - command => "mysql -uroot icinga2 < /usr/share/doc/icinga2-ido-mysql-$icinga2Version/schema/mysql.sql", + command => 'mysql -uroot icinga2 < /usr/share/doc/icinga2-ido-mysql-$(rpm -q icinga2-ido-mysql | cut -d\'-\' -f4)/schema/mysql.sql', require => [ Exec['create-mysql-icinga2-db'], Package['icinga2-ido-mysql'] ] } - file { '/etc/icinga2/features-available/ido-mysql.conf': source => 'puppet:////vagrant/.vagrant-puppet/files/etc/icinga2/features-available/ido-mysql.conf', owner => 'icinga', From 294728ac47df056121500ffe341c71a3de662ad5 Mon Sep 17 00:00:00 2001 From: Eric Lippmann Date: Tue, 29 Jul 2014 17:50:44 +0200 Subject: [PATCH 05/49] Revert "Autologin: Test logged session against remote user" This reverts commit 64954e99244f26cc6b6dccc7d60a253c105bd550. If the strip_username_regex is configured on the autologin backend and applies on a user's name, the authenticated user's username does never match the REMOTE_USER server variable. Thus the application will logout/login on every request which results in a redirect loop. refs #6462 --- library/Icinga/Authentication/Manager.php | 7 ------- 1 file changed, 7 deletions(-) diff --git a/library/Icinga/Authentication/Manager.php b/library/Icinga/Authentication/Manager.php index 7009d51ab..a0465d306 100644 --- a/library/Icinga/Authentication/Manager.php +++ b/library/Icinga/Authentication/Manager.php @@ -117,13 +117,6 @@ class Manager public function authenticateFromSession() { $this->user = Session::getSession()->get('user'); - - if ($this->user - && array_key_exists('REMOTE_USER', $_SERVER) - && $this->user->getUsername() !== $_SERVER['REMOTE_USER'] - ) { - $this->removeAuthorization(); - } } /** From e2c761a7aa9a7fe6f670862ddaf9945e983cf2ff Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Wed, 30 Jul 2014 12:35:55 +0200 Subject: [PATCH 06/49] AutoLogin/Logout: Remove own session namespace Store data in the user and implement interface to left backends store remote information. fixes #6461 --- .../controllers/AuthenticationController.php | 9 +--- .../Backend/AutoLoginBackend.php | 1 + library/Icinga/Authentication/Manager.php | 6 --- library/Icinga/User.php | 43 +++++++++++++++++++ 4 files changed, 46 insertions(+), 13 deletions(-) diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index 47825c210..7d4864d5a 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -68,9 +68,6 @@ class AuthenticationController extends ActionController $authenticated = $backend->authenticate($user); if ($authenticated === true) { $auth->setAuthenticated($user); - $session = Session::getSession()->getNamespace('authentication'); - $session->set('is_remote_user', true); - $session->write(); $this->rerenderLayout()->redirectNow($redirectUrl); } } @@ -135,12 +132,10 @@ class AuthenticationController extends ActionController public function logoutAction() { $auth = $this->Auth(); - - $session = Session::getSession()->getNamespace('authentication'); - + $isRemoteUser = $auth->getUser()->isRemoteUser(); $auth->removeAuthorization(); - if ($session->get('is_remote_user', false) === true) { + if ($isRemoteUser === true) { $this->_helper->layout->setLayout('login'); $this->_response->setHttpResponseCode(401); } else { diff --git a/library/Icinga/Authentication/Backend/AutoLoginBackend.php b/library/Icinga/Authentication/Backend/AutoLoginBackend.php index d793b50dd..16373bb6c 100644 --- a/library/Icinga/Authentication/Backend/AutoLoginBackend.php +++ b/library/Icinga/Authentication/Backend/AutoLoginBackend.php @@ -53,6 +53,7 @@ class AutoLoginBackend extends UserBackend { if (isset($_SERVER['REMOTE_USER'])) { $username = $_SERVER['REMOTE_USER']; + $user->setRemoteUserInformation($username, 'REMOTE_USER'); if ($this->stripUsernameRegexp !== null) { $stripped = preg_replace($this->stripUsernameRegexp, '', $username); if ($stripped !== false) { diff --git a/library/Icinga/Authentication/Manager.php b/library/Icinga/Authentication/Manager.php index a0465d306..3f381eaf9 100644 --- a/library/Icinga/Authentication/Manager.php +++ b/library/Icinga/Authentication/Manager.php @@ -30,12 +30,6 @@ class Manager */ private $user; - /** - * If the user was authenticated from the REMOTE_USER server variable - * - * @var Boolean - */ - private $fromRemoteUser = false; private function __construct() { diff --git a/library/Icinga/User.php b/library/Icinga/User.php index 848877850..13f62881a 100644 --- a/library/Icinga/User.php +++ b/library/Icinga/User.php @@ -58,6 +58,18 @@ class User */ protected $additionalInformation = array(); + /** + * Information if the user is external authenticated + * + * Keys: + * + * 0: origin username + * 1: origin field name + * + * @var array + */ + protected $remoteUserInformation = array(); + /** * Set of permissions * @@ -401,4 +413,35 @@ class User { $this->messages = null; } + + /** + * Set additional remote user information + * + * @param stirng $username + * @param string $field + */ + public function setRemoteUserInformation($username, $field) + { + $this->remoteUserInformation = array($username, $field); + } + + /** + * Get additional remote user information + * + * @return array + */ + public function getRemoteUserInformation() + { + return $this->remoteUserInformation; + } + + /** + * Return true if user has remote user information set + * + * @return bool + */ + public function isRemoteUser() + { + return (count($this->remoteUserInformation)) ? true : false; + } } From 56a29354d3e49c954b12aaefac101d5a589b648e Mon Sep 17 00:00:00 2001 From: Marius Hein Date: Wed, 30 Jul 2014 12:54:08 +0200 Subject: [PATCH 07/49] AutoLogin: Check the remote username against logged in user fixes #6462 --- library/Icinga/Authentication/Manager.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/library/Icinga/Authentication/Manager.php b/library/Icinga/Authentication/Manager.php index 3f381eaf9..ec49aa416 100644 --- a/library/Icinga/Authentication/Manager.php +++ b/library/Icinga/Authentication/Manager.php @@ -111,6 +111,13 @@ class Manager public function authenticateFromSession() { $this->user = Session::getSession()->get('user'); + + if ($this->user !== null && $this->user->isRemoteUser() === true) { + list($originUsername, $field) = $this->user->getRemoteUserInformation(); + if (array_key_exists($field, $_SERVER) && $_SERVER[$field] !== $originUsername) { + $this->removeAuthorization(); + } + } } /** From 3e4944c60a25e8c1015704cb1d87db051fd9c422 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Wed, 30 Jul 2014 14:04:57 +0200 Subject: [PATCH 08/49] Vagrant: Update monitoring-plugins/livestatus Move all hardcoded versions to the header too. fixes #6818 --- .vagrant-puppet/manifests/default.pp | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/.vagrant-puppet/manifests/default.pp b/.vagrant-puppet/manifests/default.pp index c05743719..3f77ab870 100644 --- a/.vagrant-puppet/manifests/default.pp +++ b/.vagrant-puppet/manifests/default.pp @@ -7,6 +7,10 @@ Exec { path => '/bin:/usr/bin:/sbin' } $icingaVersion = '1.11.5' $icinga2Version = '2.0.1' +$pluginVersion = '2.0' +$livestatusVersion = '1.2.4p5' +$phantomjsVersion = '1.9.1' +$casperjsVersion = '1.0.2' exec { 'create-mysql-icinga-db': unless => 'mysql -uicinga -picinga icinga', @@ -207,8 +211,8 @@ exec { 'icinga-htpasswd': } cmmi { 'icinga-plugins': - url => 'https://www.monitoring-plugins.org/download/nagios-plugins-1.5.tar.gz', - output => 'nagios-plugins-1.5.tar.gz', + url => "https://www.monitoring-plugins.org/download/monitoring-plugins-${pluginVersion}.tar.gz", + output => "monitoring-plugins-${pluginVersion}.tar.gz", flags => '--prefix=/usr/lib64/nagios/plugins \ --with-nagios-user=icinga --with-nagios-group=icinga \ --with-cgiurl=/icinga-mysql/cgi-bin', @@ -218,8 +222,8 @@ cmmi { 'icinga-plugins': } cmmi { 'mk-livestatus': - url => 'http://mathias-kettner.de/download/mk-livestatus-1.2.2p1.tar.gz', - output => 'mk-livestatus-1.2.2p1.tar.gz', + url => "http://mathias-kettner.de/download/mk-livestatus-${livestatusVersion}.tar.gz", + output => "mk-livestatus-${livestatusVersion}.tar.gz", flags => '--prefix=/usr/local/icinga-mysql --exec-prefix=/usr/local/icinga-mysql', creates => '/usr/local/icinga-mysql/lib/mk-livestatus', make => 'make && make install', @@ -262,14 +266,14 @@ exec { 'populate-openldap': } class { 'phantomjs': - url => 'https://phantomjs.googlecode.com/files/phantomjs-1.9.1-linux-x86_64.tar.bz2', - output => 'phantomjs-1.9.1-linux-x86_64.tar.bz2', + url => "https://phantomjs.googlecode.com/files/phantomjs-${phantomjsVersion}-linux-x86_64.tar.bz2", + output => "phantomjs-${phantomjsVersion}-linux-x86_64.tar.bz2", creates => '/usr/local/phantomjs' } class { 'casperjs': - url => 'https://github.com/n1k0/casperjs/tarball/1.0.2', - output => 'casperjs-1.0.2.tar.gz', + url => "https://github.com/n1k0/casperjs/tarball/${casperjsVersion}", + output => "casperjs-${casperjsVersion}.tar.gz", creates => '/usr/local/casperjs' } From 51484ebf88ec71b50acf60727b4a442543b9a9b0 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 31 Jul 2014 16:52:34 +0200 Subject: [PATCH 09/49] monitoring/Perfdata: ignore invalid min/max key=23;0;0;0;0 and key=23;;;; lead to division by zero exceptions This should fix this by ignoring empty strings for min/max (formerly it got "converted" to float(0)) and also ignores min == max. fixes #6828 --- .../monitoring/library/Monitoring/Plugin/Perfdata.php | 11 +++++++++-- .../php/library/Monitoring/Plugin/PerfdataTest.php | 8 ++++++++ 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php index a6eaddabd..6af3cde17 100644 --- a/modules/monitoring/library/Monitoring/Plugin/Perfdata.php +++ b/modules/monitoring/library/Monitoring/Plugin/Perfdata.php @@ -190,6 +190,9 @@ class Perfdata if ($this->maxValue !== null) { $minValue = $this->minValue !== null ? $this->minValue : 0; + if ($this->maxValue - $minValue === 0.0) { + return null; + } if ($this->value > $minValue) { return (($this->value - $minValue) / ($this->maxValue - $minValue)) * 100; @@ -267,9 +270,13 @@ class Perfdata switch (count($parts)) { case 5: - $this->maxValue = self::convert($parts[4], $this->unit); + if ($parts[4] !== '') { + $this->maxValue = self::convert($parts[4], $this->unit); + } case 4: - $this->minValue = self::convert($parts[3], $this->unit); + if ($parts[3] !== '') { + $this->minValue = self::convert($parts[3], $this->unit); + } case 3: // TODO(#6123): Tresholds have the same UOM and need to be converted as well! $this->criticalThreshold = trim($parts[2]) ? trim($parts[2]) : null; diff --git a/modules/monitoring/test/php/library/Monitoring/Plugin/PerfdataTest.php b/modules/monitoring/test/php/library/Monitoring/Plugin/PerfdataTest.php index 2d8a98b73..9cc132eb2 100644 --- a/modules/monitoring/test/php/library/Monitoring/Plugin/PerfdataTest.php +++ b/modules/monitoring/test/php/library/Monitoring/Plugin/PerfdataTest.php @@ -347,6 +347,14 @@ class PerfdataTest extends BaseTestCase Perfdata::fromString('test=25;;;50;100')->getPercentage(), 'Perfdata objects do return a percentage though their value is lower than it\'s allowed minimum' ); + $this->assertNull( + Perfdata::fromString('test=25;;;0;')->getPercentage(), + 'Perfdata objects do not ignore empty max values when returning percentages' + ); + $this->assertNull( + Perfdata::fromString('test=25;;;0;0')->getPercentage(), + 'Perfdata objects do not ignore impossible min/max combinations when returning percentages' + ); } /** From 8f729bfb6545cd07b659e9bf84ac20ab30de87cb Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 31 Jul 2014 17:04:26 +0200 Subject: [PATCH 10/49] ActionController: set a default window title In case a controller action didn't set a view title this fix restores the default title on XHR requests. fixes #6797 --- library/Icinga/Web/Controller/ActionController.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index b28bddc37..1c4111e4b 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -362,6 +362,8 @@ class ActionController extends Zend_Controller_Action 'X-Icinga-Title', rawurlencode($this->view->title . ' :: Icinga Web') ); + } else { + $resp->setHeader('X-Icinga-Title', rawurlencode('Icinga Web')); } if ($this->rerenderLayout) { From 96925487bddab8b9471d5ffe1e5042f76e140acc Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Thu, 31 Jul 2014 17:24:56 +0200 Subject: [PATCH 11/49] CLI/monitoring/list: fix DataView-related exception This uses the renamed DataView serviceStatus instead of the former status and fixes the problem that CLI still assumed to have fetch and count function on the DataView. fixes #6777 --- modules/monitoring/application/clicommands/ListCommand.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/modules/monitoring/application/clicommands/ListCommand.php b/modules/monitoring/application/clicommands/ListCommand.php index 42a377763..e6b86f4ef 100644 --- a/modules/monitoring/application/clicommands/ListCommand.php +++ b/modules/monitoring/application/clicommands/ListCommand.php @@ -72,6 +72,7 @@ class ListCommand extends Command protected function showFormatted($query, $format, $columns) { + $query = $query->getQuery(); switch($format) { case 'json': echo json_encode($query->fetchAll()); @@ -155,7 +156,7 @@ class ListCommand extends Command 'service_perfdata', 'service_last_state_change' ); - $query = $this->getQuery('status', $columns) + $query = $this->getQuery('serviceStatus', $columns) ->order('host_name'); echo $this->renderStatusQuery($query); } @@ -167,6 +168,7 @@ class ListCommand extends Command $screen = $this->screen; $utils = new CliUtils($screen); $maxCols = $screen->getColumns(); + $query = $query->getQuery(); $rows = $query->fetchAll(); $count = $query->count(); $count = count($rows); From d813bad2f8c9c58f5ad5646269a3268284c951fc Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Mon, 11 Aug 2014 17:21:43 +0200 Subject: [PATCH 12/49] Update README.md with general & install info We don't want users to install it in production environments but we certainly also want to prevent them from doing so by calling `vagrant up`. Therefore the native method described in doc/installation.md works for now until there are proper installation methods (packages, etc). Add support hints, and updated Icinga 2 paths as well. fixes #6880 --- README.md | 69 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 5974d5de0..16eb1444a 100644 --- a/README.md +++ b/README.md @@ -2,13 +2,59 @@ ## Table of Contents -1. [Vagrant - Virtual development environment](#vagrant) +0. [General Information](#general information) +1. [Installation](#installation) +2. [Support](#support) +3. [Vagrant - Virtual development environment](#vagrant) + +## General Information + +`Icinga Web 2` is the next generation monitoring web interface, framework +and CLI tool developed by the [Icinga Project](https://www.icinga.org/community/team/). + +Responsive and fast, rewritten from scratch supporting multiple backends and +providing a CLI tool. Compatible with Icinga Core 2.x and 1.x. + +Check the Icinga website for some [insights](https://www.icinga.org/icinga/screenshots/icinga-web-2/). + +> **Note** +> +> `Icinga Web 2` is still in development and not meant for production deployment. +> Watch the [development roadmap](https://dev.icinga.org/projects/icingaweb2/roadmap) +> and [Icinga website](https://www.icinga.org/) for release schedule updates! + +## Installation + +Please navigate to [doc/installation.md](doc/installation.md) for updated details. + +## Support + +Please head over to the [community support channels](https://www.icinga.org/icinga/faq/get-help/) +in case of questions, bugs, etc. + +Please make sure to provide the following details: + +* OS, distribution, version +* PHP and/or MySQL/PostgreSQL version +* Which browser and its version +* Screenshot and problem description + ## Vagrant -> **Note** that the deployment of the virtual machine is tested against Vagrant starting with version 1.1. +### Requirements + +* Vagrant 1.2+ +* Virtualbox 4.2.16+ +* a fairly powerful hardware (quad core, 4gb ram, fast hdd) + +> **Note** +> +> The deployment of the virtual machine is tested against Vagrant starting with version 1.2. > Unfortunately older versions will not work. +### General + The Icinga Web 2 project ships with a Vagrant virtual machine that integrates the source code with various services and example data in a controlled environment. This enables developers and users to test Livestatus, status.dat, @@ -17,7 +63,9 @@ have to do is install Vagrant and run: vagrant up -> **Note** that the first boot of the vm takes a fairly long time because +> **Note** +> +> The first boot of the vm takes a fairly long time because > you'll download a plain CentOS base box and Vagrant will automatically > provision the environment on the first go. @@ -68,7 +116,7 @@ After you should be able to browse [localhost:8080/icingaweb](http://localhost:8 **Installed files**: * `/usr/share/icinga/htpasswd.users` account information for logging into the Icinga classic web interface for both icinga instances -* `/usr/lib64/nagios/plugins` Nagios Plugins for both icinga instances +* `/usr/lib64/nagios/plugins` Monitoring Plugins for all Icinga instances #### Icinga with IDOUtils using a MySQL database @@ -196,12 +244,13 @@ code style issues. #### Icinga 2 -**Installation path**: `/usr/local/icinga2` +Installed from the Icinga [snapshot package repository](http://packages.icinga.org/epel/). +The configuration is located in `/etc/icinga2`. **Example usage**: - cd /usr/local/icinga2 - ./sbin/icinga2 -c etc/icinga2/icinga2.conf.dist + /etc/init.d/icinga2 (start|stop|restart|reload) + ## Log into Icinga Web 2 @@ -211,3 +260,9 @@ If you've configure LDAP as authentication backend (which is the default) use th > **Password**: password Have a look at [LDAP example data](#ldap example data) for more accounts. + +Using MySQL as backend: + +> **Username**: icingaadmin +> **Password**: icinga + From 143db976ef7cb36625b2676afe8a18e997d4e668 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Tue, 12 Aug 2014 09:56:43 +0200 Subject: [PATCH 13/49] Properly support Apache 2.2 and 2.4 Can be done by using directive. Tested on fc20, el7 and Wheezy. refs #6771 --- etc/apache/icingaweb.conf.in | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/etc/apache/icingaweb.conf.in b/etc/apache/icingaweb.conf.in index 0451abf5b..3884aea5a 100644 --- a/etc/apache/icingaweb.conf.in +++ b/etc/apache/icingaweb.conf.in @@ -3,10 +3,19 @@ Alias @web_path@ "@prefix@/public" Options SymLinksIfOwnerMatch AllowOverride None - Order allow,deny - Allow from all - # new directive needed in Apache 2.4.3+ - #Require all granted + + + # Apache 2.4 + + Require all granted + + + + + # Apache 2.2 + Order allow,deny + Allow from all + SetEnv ICINGAWEB_CONFIGDIR @icingaweb_config_path@ From 7958a81975130bf21f58fd572c1ae2dfb07c53c4 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Tue, 12 Aug 2014 12:49:03 +0200 Subject: [PATCH 14/49] Fix that a form's submit button is not being sent when the method is GET fixes #6890 --- public/js/icinga/events.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index 8dcd0f516..6c6978577 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -355,12 +355,20 @@ $target = self.getLinkTargetFor($form); if (method === 'GET') { - url = icinga.utils.addUrlParams(url, $form.serializeObject()); + var dataObj = $form.serializeObject(); + + if (typeof autosubmit === 'undefined' || ! autosubmit) { + if ($button.length && $button.attr('name') !== 'undefined') { + dataObj[$button.attr('name')] = $button.attr('value'); + } + } + + url = icinga.utils.addUrlParams(url, dataObj); } else { data = $form.serializeArray(); if (typeof autosubmit === 'undefined' || ! autosubmit) { - if ($button.length) { + if ($button.length && $button.attr('name') !== 'undefined') { data.push({ name: $button.attr('name'), value: $button.attr('value') From 9dabc6dc9c93a5393c8cd77bc14b1fdb1af45e42 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Tue, 12 Aug 2014 13:10:45 +0200 Subject: [PATCH 15/49] Update rpm builds refs #6401 refs #6403 --- .gitignore | 3 + icingaweb2.spec | 77 +++++++--------- packages/rhel/README | 57 ------------ packages/rhel/etc/httpd/conf.d/icingaweb.conf | 12 --- .../rhel/usr/share/icingaweb/public/.htaccess | 7 -- .../rhel/usr/share/icingaweb/public/index.php | 6 -- packages/rpm/README.md | 88 +++++++++++++++++++ packages/rpm/etc/httpd/conf.d/icingaweb.conf | 32 +++++++ packages/rpm/etc/icingaweb/authentication.ini | 6 ++ .../icingaweb/modules/monitoring/backends.ini | 8 ++ .../modules/monitoring/instances.ini | 2 + packages/rpm/etc/icingaweb/resources.ini | 28 ++++++ packages/rpm/usr/bin/icingacli | 6 ++ 13 files changed, 206 insertions(+), 126 deletions(-) delete mode 100644 packages/rhel/README delete mode 100644 packages/rhel/etc/httpd/conf.d/icingaweb.conf delete mode 100644 packages/rhel/usr/share/icingaweb/public/.htaccess delete mode 100644 packages/rhel/usr/share/icingaweb/public/index.php create mode 100644 packages/rpm/README.md create mode 100644 packages/rpm/etc/httpd/conf.d/icingaweb.conf create mode 100644 packages/rpm/etc/icingaweb/authentication.ini create mode 100644 packages/rpm/etc/icingaweb/modules/monitoring/backends.ini create mode 100644 packages/rpm/etc/icingaweb/modules/monitoring/instances.ini create mode 100644 packages/rpm/etc/icingaweb/resources.ini create mode 100755 packages/rpm/usr/bin/icingacli diff --git a/.gitignore b/.gitignore index ef44d81c9..1444ecfb2 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,9 @@ config/preferences/*.ini # Application logfiles var/log/*.log +# Packaging /debian +*.tar.gz +*.komodoproject diff --git a/icingaweb2.spec b/icingaweb2.spec index b1cb3d2e5..6d9109f02 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -3,14 +3,14 @@ # Upstream: The icinga devel team # ExcludeDist: el4 el3 -%define revision 0 +%define revision 1 %define configdir %{_sysconfdir}/icingaweb %define sharedir %{_datadir}/icingaweb %define prefixdir %{_datadir}/icingaweb %define logdir %{sharedir}/log %define usermodparam -a -G -#%define logdir %{_localstatedir}/log/icingaweb +%define logdir %{_localstatedir}/log/icingaweb %if "%{_vendor}" == "suse" %define phpname php5 @@ -37,15 +37,15 @@ %define apacheconfdir %{_sysconfdir}/apache2/conf.d %define apacheuser wwwrun %define apachegroup www -%define extcmdfile1x %{_localstatedir}/icinga/rw/icinga.cmd -%define livestatussocket1x %{_localstatedir}/icinga/rw/live +%define extcmdfile %{_localstatedir}/run/icinga2/cmd/icinga.cmd +%define livestatussocket %{_localstatedir}/run/icinga2/cmd/livestatus %endif %if "%{_vendor}" == "redhat" %define apacheconfdir %{_sysconfdir}/httpd/conf.d %define apacheuser apache %define apachegroup apache -%define extcmdfile-1x %{_localstatedir}/spool/icinga/cmd/icinga.cmd -%define livestatussocket1x %{_localstatedir}/spool/icinga/cmd/live +%define extcmdfile %{_localstatedir}/run/icinga2/cmd/icinga.cmd +%define livestatussocket %{_localstatedir}/run/icinga2/cmd/livestatus %endif Summary: Open Source host, service and network monitoring Web UI @@ -109,8 +109,8 @@ Requires: php-Icinga %description -IcingaWeb for Icinga 2 or Icinga 1.x using status data, -IDOUtils or Livestatus as backend provider. +Icinga Web 2 for Icinga 2 or Icinga 1.x using multiple backends +for example DB IDO. %package -n icingacli Summary: Icinga CLI @@ -130,58 +130,54 @@ Requires: %{phpzendname} %description -n php-Icinga -Icinga Web 2 PHP Libraries shared with icingacli. - - +Icinga Web 2 PHP Libraries required by the web frontend and cli tool. %prep -#%setup -q -n %{name}-%{version} -%setup -q -n %{name} +#VERSION=0.0.1; git archive --format=tar --prefix=icingaweb2-$VERSION/ HEAD | gzip >icingaweb2-$VERSION.tar.gz +%setup -q -n %{name}-%{version} %build -cat > README.RHEL.SUSE <<"EOF" -IcingaWeb for RHEL and SUSE -=========================== - -Please check ./doc/installation.md -for requirements and database setup. -EOF - %install [ "%{buildroot}" != "/" ] && [ -d "%{buildroot}" ] && rm -rf %{buildroot} # prepare configuration for sub packages # install rhel apache config -install -D -m0644 packages/rhel/etc/httpd/conf.d/icingaweb.conf %{buildroot}/%{apacheconfdir}/icingaweb.conf +install -D -m0644 packages/rpm/etc/httpd/conf.d/icingaweb.conf %{buildroot}/%{apacheconfdir}/icingaweb.conf # install public, library, modules %{__mkdir} -p %{buildroot}/%{sharedir} %{__mkdir} -p %{buildroot}/%{logdir} +%{__mkdir} -p %{buildroot}/%{_sysconfdir}/icingaweb +%{__mkdir} -p %{buildroot}/%{_sysconfdir}/dashboard +%{__mkdir} -p %{buildroot}/%{_sysconfdir}/icingaweb/modules +%{__mkdir} -p %{buildroot}/%{_sysconfdir}/icingaweb/modules/monitoring %{__mkdir} -p %{buildroot}/%{_sysconfdir}/icingaweb/enabledModules %{__cp} -r application library modules public %{buildroot}/%{sharedir}/ -# install index.php -install -m0644 packages/rhel/usr/share/icingaweb/public/index.php %{buildroot}/%{sharedir}/public/index.php - -# use the vagrant config for configuration for now - TODO -%{__cp} -r .vagrant-puppet/files/etc/icingaweb %{buildroot}/%{_sysconfdir}/ - -# we use the default 'icinga' database -sed -i 's/icinga2/icinga/g' %{buildroot}/%{_sysconfdir}/icingaweb/resources.ini +## config +# use the default menu.ini for application and monitoring mobule +install -D -m0644 config/menu.ini %{buildroot}/%{_sysconfdir}/icingaweb/menu.ini +install -D -m0644 config/modules/monitoring/menu.ini %{buildroot}/%{_sysconfdir}/icingaweb/modules/monitoring/menu.ini +# authentication is db only +install -D -m0644 packages/rpm/etc/icingaweb/authentication.ini %{buildroot}/%{_sysconfdir}/icingaweb/authentication.ini +# custom resource paths +install -D -m0644 packages/rpm/etc/icingaweb/resources.ini %{buildroot}/%{_sysconfdir}/icingaweb/resources.ini +# dashboard +install -D -m0644 config/dashboard/dashboard.ini %{buildroot}/%{_sysconfdir}/icingaweb/dashboard/dashboard.ini +# monitoring module (icinga2) +install -D -m0644 packages/rpm/etc/icingaweb/modules/monitoring/backends.ini %{buildroot}/%{_sysconfdir}/icingaweb/modules/monitoring/backends.ini +install -D -m0644 packages/rpm/etc/icingaweb/modules/monitoring/instances.ini %{buildroot}/%{_sysconfdir}/icingaweb/modules/monitoring/instances.ini # enable the monitoring module by default ln -s %{sharedir}/modules/monitoring %{buildroot}/%{_sysconfdir}/icingaweb/enabledModules/monitoring +## config # install icingacli -install -D -m0755 bin/icingacli %{buildroot}/usr/bin/icingacli - -# install sql schema files as example - -# delete all *.in files +install -D -m0755 packages/rpm/usr/bin/icingacli %{buildroot}/usr/bin/icingacli %pre # Add apacheuser in the icingacmd group @@ -196,9 +192,6 @@ if [ $? -eq 0 ]; then %{_sbindir}/usermod %{usermodparam} icingacmd %{apacheuser} fi -# uncomment if building from git -# %{__rm} -rf %{buildroot}%{_datadir}/icinga2-web/.git - %preun %post @@ -209,14 +202,13 @@ fi %files # main dirs %defattr(-,root,root) -%doc etc/schema doc packages/rhel/README +%doc etc/schema doc packages/rpm/README.md %attr(755,%{apacheuser},%{apachegroup}) %{sharedir}/public %attr(755,%{apacheuser},%{apachegroup}) %{sharedir}/modules # configs %defattr(-,root,root) %config(noreplace) %attr(-,root,root) %{apacheconfdir}/icingaweb.conf -%dir %{configdir} -%config(noreplace) %attr(775,%{apacheuser},%{apachegroup}) %{configdir} +%config(noreplace) %attr(-,%{apacheuser},%{apachegroup}) %{configdir} # logs %attr(2775,%{apacheuser},%{apachegroup}) %dir %{logdir} @@ -228,6 +220,3 @@ fi %attr(0755,root,root) /usr/bin/icingacli %changelog -* Tue May 11 2014 Michael Friedrich - 0.0.1-1 -- initial creation - diff --git a/packages/rhel/README b/packages/rhel/README deleted file mode 100644 index 4e04875bb..000000000 --- a/packages/rhel/README +++ /dev/null @@ -1,57 +0,0 @@ -Requirements -============ - -Disabled SELinux for sending commands via external command pipe -provided by Icinga (2) Core. - -# setenforce 0 - - -Webinterface Login -================== - -The default credentials using the internal MySQL database are - -icingaadmin:icinga - - -Internal MySQL DB Setup -======================= - -# mysql -u root -p - CREATE USER `icingaweb`@`localhost` IDENTIFIED BY 'icingaweb'; - CREATE DATABASE `icingaweb`; - GRANT ALL PRIVILEGES ON `icingaweb`.* TO `icingaweb`@`localhost`; - FLUSH PRIVILEGES; - quit - -# mysql icingaweb < /usr/share/doc/icingaweb2-*/schema/accounts.mysql.sql -# mysql icingaweb < /usr/share/doc/icingaweb2-*/schema/preferences.mysql.sql - - -Modules -======= - -The monitoring module is enabled by default. - - -Backend configuration -===================== - -/etc/icingaweb/resources.ini - -contains the database backend information. By default -the Icinga IDO DB is used by the monitoring module in - -/etc/icingaweb/modules/monitoring/backends.ini - -The external command pipe is required for sending commands -and configured for Icinga 2 in - -/etc/icingaweb/modules/monitoring/instances.ini - - -Support -======= - -Please use one of the listed support channels at https://support.icinga.org diff --git a/packages/rhel/etc/httpd/conf.d/icingaweb.conf b/packages/rhel/etc/httpd/conf.d/icingaweb.conf deleted file mode 100644 index 47d408a67..000000000 --- a/packages/rhel/etc/httpd/conf.d/icingaweb.conf +++ /dev/null @@ -1,12 +0,0 @@ -Alias /icingaweb /usr/share/icingaweb/public - - Options -Indexes - - AllowOverride All - - Order allow,deny - Allow from all - - EnableSendfile Off - - diff --git a/packages/rhel/usr/share/icingaweb/public/.htaccess b/packages/rhel/usr/share/icingaweb/public/.htaccess deleted file mode 100644 index 8588fbbe1..000000000 --- a/packages/rhel/usr/share/icingaweb/public/.htaccess +++ /dev/null @@ -1,7 +0,0 @@ -RewriteEngine on -RewriteBase /icingaweb -RewriteCond %{REQUEST_FILENAME} -s [OR] -RewriteCond %{REQUEST_FILENAME} -l [OR] -RewriteCond %{REQUEST_FILENAME} -d -RewriteRule ^.*$ - [NC,L] -RewriteRule ^.*$ index.php [NC,L] diff --git a/packages/rhel/usr/share/icingaweb/public/index.php b/packages/rhel/usr/share/icingaweb/public/index.php deleted file mode 100644 index be6847bc8..000000000 --- a/packages/rhel/usr/share/icingaweb/public/index.php +++ /dev/null @@ -1,6 +0,0 @@ - + Options SymLinksIfOwnerMatch + AllowOverride None + + + # Apache 2.4 + + Require all granted + + + + + # Apache 2.2 + Order allow,deny + Allow from all + + + SetEnv ICINGAWEB_CONFIGDIR /etc/icingaweb + + EnableSendfile Off + + RewriteEngine on + RewriteBase /icingaweb/ + RewriteCond %{REQUEST_FILENAME} -s [OR] + RewriteCond %{REQUEST_FILENAME} -l [OR] + RewriteCond %{REQUEST_FILENAME} -d + RewriteRule ^.*$ - [NC,L] + RewriteRule ^.*$ index.php [NC,L] + + diff --git a/packages/rpm/etc/icingaweb/authentication.ini b/packages/rpm/etc/icingaweb/authentication.ini new file mode 100644 index 000000000..3ec9c033a --- /dev/null +++ b/packages/rpm/etc/icingaweb/authentication.ini @@ -0,0 +1,6 @@ +[autologin] +backend = autologin + +[internal_db_authentication] +backend = db +resource = internal_db diff --git a/packages/rpm/etc/icingaweb/modules/monitoring/backends.ini b/packages/rpm/etc/icingaweb/modules/monitoring/backends.ini new file mode 100644 index 000000000..6dd67d4b5 --- /dev/null +++ b/packages/rpm/etc/icingaweb/modules/monitoring/backends.ini @@ -0,0 +1,8 @@ +[localdb] +type = ido +resource = "ido" + +[locallive] +disabled = "1" +type = livestatus +resource = livestatus diff --git a/packages/rpm/etc/icingaweb/modules/monitoring/instances.ini b/packages/rpm/etc/icingaweb/modules/monitoring/instances.ini new file mode 100644 index 000000000..037baa8b9 --- /dev/null +++ b/packages/rpm/etc/icingaweb/modules/monitoring/instances.ini @@ -0,0 +1,2 @@ +[icinga] +path = "/var/run/icinga2/cmd/icinga2.cmd" diff --git a/packages/rpm/etc/icingaweb/resources.ini b/packages/rpm/etc/icingaweb/resources.ini new file mode 100644 index 000000000..1c1e62eb1 --- /dev/null +++ b/packages/rpm/etc/icingaweb/resources.ini @@ -0,0 +1,28 @@ +[internal_db] +type = db +db = mysql +host = localhost +port = 3306 +password = icingaweb +username = icingaweb +dbname = icingaweb + +[ido] +type = db +db = mysql +host = localhost +port = 3306 +password = icinga +username = icinga +dbname = icinga + +[livestatus] +type = livestatus +socket = /var/run/icinga2/cmd/livestatus + +[logfile] +type = file +filename = "/var/log/icingaweb/icingaweb.log" +fields = "/^(?[0-9]{4}(-[0-9]{2}){2}T[0-9]{2}(:[0-9]{2}){2}(\\+[0-9]{2}:[0-9]{2})?) - (?[A-Za-z]+) - (?.*)$/" +; format: PCRE +; diff --git a/packages/rpm/usr/bin/icingacli b/packages/rpm/usr/bin/icingacli new file mode 100755 index 000000000..03ed43116 --- /dev/null +++ b/packages/rpm/usr/bin/icingacli @@ -0,0 +1,6 @@ +#!/usr/bin/php +dispatch(); From 57db6e429b645d8fbdab95119f01426b06eb8534 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Tue, 12 Aug 2014 15:24:55 +0200 Subject: [PATCH 16/49] Fix README, update spec header refs #6401 refs #6404 --- icingaweb2.spec | 29 +++++++++++++++++++++++++---- packages/rpm/README.md | 1 + 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/icingaweb2.spec b/icingaweb2.spec index 6d9109f02..0da22b8ea 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -1,7 +1,28 @@ -# $Id$ -# Authority: The icinga devel team -# Upstream: The icinga devel team -# ExcludeDist: el4 el3 +#/** +# * This file is part of Icinga Web 2. +# * +# * Icinga Web 2 - Head for multiple monitoring backends. +# * Copyright (C) 2014 Icinga Development Team +# * +# * This program is free software; you can redistribute it and/or +# * modify it under the terms of the GNU General Public License +# * as published by the Free Software Foundation; either version 2 +# * of the License, or (at your option) any later version. +# * +# * This program is distributed in the hope that it will be useful, +# * but WITHOUT ANY WARRANTY; without even the implied warranty of +# * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# * GNU General Public License for more details. +# * +# * You should have received a copy of the GNU General Public License +# * along with this program; if not, write to the Free Software +# * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# * +# * @copyright 2014 Icinga Development Team +# * @license http://www.gnu.org/licenses/gpl-2.0.txt GPL, version 2 +# * @author Icinga Development Team +# * +# */ %define revision 1 diff --git a/packages/rpm/README.md b/packages/rpm/README.md index b136a6b19..d218a51eb 100644 --- a/packages/rpm/README.md +++ b/packages/rpm/README.md @@ -5,6 +5,7 @@ package (RHEL/CentOS/Fedora, SLES/OpenSUSE). ## Requirements +* EPEL/OBS Repository for Zend Framework * Apache 2.2+ * PHP 5.3+, Zend Framework, PHP PDO MySQL/PostgreSQL, PHP LDAP (optional) * MySQL or PostgreSQL for internal DB From b5d6481c1288ee55e1f45735ad03c6d32ea2c4a7 Mon Sep 17 00:00:00 2001 From: Johannes Meyer Date: Wed, 13 Aug 2014 15:52:33 +0200 Subject: [PATCH 17/49] Make it possible to translate the process info view refs #6610 --- .../views/scripts/process/info.phtml | 56 +++++++++++-------- 1 file changed, 32 insertions(+), 24 deletions(-) diff --git a/modules/monitoring/application/views/scripts/process/info.phtml b/modules/monitoring/application/views/scripts/process/info.phtml index 350966c49..8fb9bd0e3 100644 --- a/modules/monitoring/application/views/scripts/process/info.phtml +++ b/modules/monitoring/application/views/scripts/process/info.phtml @@ -10,28 +10,33 @@ $cf = $this->getHelper('CommandForm');

Backend backendName; ?> -is_currently_running === '1' ? sprintf('has been running with PID %d ', $ps->process_id) . $this->prefixedTimeSince($ps->program_start_time) : 'is not running'; ?>. +is_currently_running === '1' + ? sprintf( + $this->translate('has been running with PID %d '), + $ps->process_id + ) . $this->prefixedTimeSince($ps->program_start_time) + : $this->translate('is not running'); ?>. - + - + - - + + - - + + - + - + - + - + - + - + - + - + - + - + - +
Last status updatetranslate('Last status update'); ?> timeSince($ps->status_update_time) ?> ago
Last check commandtranslate('Last check command'); ?> timeSince($ps->last_command_check) ?> ago
Global host event handlerglobal_host_event_handler ? $ps->global_host_event_handler : 'Not set' ?>translate('Global host event handler'); ?>global_host_event_handler ? $ps->global_host_event_handler : $this->translate('Not set'); ?>
Global service event handlerglobal_service_event_handler ? $ps->global_service_event_handler : 'Not set' ?>translate('Global service event handler'); ?>global_service_event_handler ? $ps->global_service_event_handler : $this->translate('Not set'); ?>
Notifications enabledtranslate('Notifications enabled'); ?> toggleSubmitForm( '', $ps->notifications_enabled, @@ -41,15 +46,18 @@ $cf = $this->getHelper('CommandForm'); array('global' => '1') ) ?> notifications_enabled === '1'): ?> - Temporarily disable + + translate('Temporarily disable'); ?> + disable_notif_expire_time): ?> -Will be re-enabled in timeUntil($ps->disable_notif_expire_time) ?> +translate('Will be re-enabled in %s'), '' . $this->timeUntil($ps->disable_notif_expire_time) . ''); ?>
Execute active service checkstranslate('Execute active service checks'); ?> toggleSubmitForm( '', $ps->active_service_checks_enabled, @@ -60,7 +68,7 @@ Will be re-enabled in timeUntil($ps->disable_notif_expire_tim ) ?>
Accept passive service checkstranslate('Accept passive service checks'); ?> toggleSubmitForm( '', $ps->passive_service_checks_enabled, @@ -71,7 +79,7 @@ Will be re-enabled in timeUntil($ps->disable_notif_expire_tim ) ?>
Execute active host checkstranslate('Execute active host checks'); ?> toggleSubmitForm( '', $ps->active_host_checks_enabled, @@ -82,7 +90,7 @@ Will be re-enabled in timeUntil($ps->disable_notif_expire_tim ) ?>
Accept passive host checkstranslate('Accept passive host checks'); ?> toggleSubmitForm( '', $ps->passive_host_checks_enabled, @@ -93,7 +101,7 @@ Will be re-enabled in timeUntil($ps->disable_notif_expire_tim ) ?>
Eventhandlers enabledtranslate('Eventhandlers enabled'); ?> toggleSubmitForm( '', $ps->event_handlers_enabled, @@ -104,7 +112,7 @@ Will be re-enabled in timeUntil($ps->disable_notif_expire_tim ) ?>
Obsessing over host checkstranslate('Obsessing over host checks'); ?> toggleSubmitForm( '', $ps->obsess_over_hosts, @@ -115,7 +123,7 @@ Will be re-enabled in timeUntil($ps->disable_notif_expire_tim ) ?>
Obsessing over service checkstranslate('Obsessing over service checks'); ?> toggleSubmitForm( '', $ps->obsess_over_services, @@ -126,7 +134,7 @@ Will be re-enabled in timeUntil($ps->disable_notif_expire_tim ) ?>
Flap detection enabledtranslate('Flap detection enabled'); ?> toggleSubmitForm( '', $ps->flap_detection_enabled, @@ -137,7 +145,7 @@ Will be re-enabled in timeUntil($ps->disable_notif_expire_tim ) ?>
Process performance datatranslate('Process performance data'); ?> toggleSubmitForm( '', $ps->process_performance_data, @@ -148,17 +156,17 @@ Will be re-enabled in timeUntil($ps->disable_notif_expire_tim ) ?>
Monitoring Processtranslate('Monitoring Process'); ?> labelSubmitForm( - 'Restart', - 'Restart the monitoring process', + $this->translate('Restart'), + $this->translate('Restart the monitoring process'), '', 'restartprocess' ) ?> + diff --git a/public/img/favicon.png b/public/img/favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..6d6f713986903f1ab05631fdeba40bd5aa433d27 GIT binary patch literal 451 zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE3?yBabR7dyk|nMYCBgY=CFO}lsSJ)O`AMk? zp1FzXsX?iUDV2pMQ*D5XECYN(Tvg;1{{R1Pq^mcne}b>4*T;_^qr)SvUA<~=Z8NdI zzooJ1#PQ=#9zV`VP20V5XIXK{+SRM)&z%d@a^;b83(yeZk|4ieAQufVY^uG(!N9=C z=;`7ZQgN$iGAG|*1s;}-XL)!2`hWb|l*JtmQQjVmY@2g(KK>GHYIio|Es>mXc-OVJ z!DBE1_kBYs!znukC5cxl;Rk|kQyjlnFh)dbXs3$^ zD`*~`^x%h7lC*-dM)QmBwl%^V6ryVx#|1*4HKL{#+L2&`L>w3hB3ij zIa_Tn>mj)XTuaW*4CJ*?Kkri*azLM9V(UYK&9 zwcsv;%}&1TsVdFx3Mz%mbaGqF6;4mzeD4M0UIvSY$CXTT*WIx&3jJi#sJ*s5%Kvxp gzw3L>e-uk#C{W~+XO_F201PVzPgg&ebxsLQ0Ka>@YXATM literal 0 HcmV?d00001 From f67d273bbdca6a77fc2ee66e936a6b90869b3a66 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 10:14:46 +0200 Subject: [PATCH 39/49] AuthenticationController: handle redirect parameter This is a form field instead of a get parameter right now. fixes #6584 --- .../controllers/AuthenticationController.php | 29 ++++++++++++++----- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/application/controllers/AuthenticationController.php b/application/controllers/AuthenticationController.php index 7d4864d5a..a6a5345ed 100644 --- a/application/controllers/AuthenticationController.php +++ b/application/controllers/AuthenticationController.php @@ -35,12 +35,17 @@ class AuthenticationController extends ActionController public function loginAction() { $auth = $this->Auth(); - $this->view->form = new LoginForm(); - $this->view->form->setRequest($this->_request); + $this->view->form = $form = new LoginForm(); + $form->setRequest($this->_request); $this->view->title = $this->translate('Icingaweb Login'); try { - $redirectUrl = Url::fromPath($this->params->get('redirect', 'dashboard')); + $redirectUrl = $this->view->form->getValue('redirect'); + if ($redirectUrl) { + $redirectUrl = Url::fromPath($redirectUrl); + } else { + $redirectUrl = Url::fromPath('dashboard'); + } if ($auth->isAuthenticated()) { $this->rerenderLayout()->redirectNow($redirectUrl); @@ -72,12 +77,20 @@ class AuthenticationController extends ActionController } } } - } elseif ($this->view->form->isSubmittedAndValid()) { - $user = new User($this->view->form->getValue('username')); - $password = $this->view->form->getValue('password'); + } elseif ($form->isSubmittedAndValid()) { + $user = new User($form->getValue('username')); + $password = $form->getValue('password'); $backendsTried = 0; $backendsWithError = 0; + $redirectUrl = $form->getValue('redirect'); + + if ($redirectUrl) { + $redirectUrl = Url::fromPath($redirectUrl); + } else { + $redirectUrl = Url::fromPath('dashboard'); + } + foreach ($chain as $backend) { if ($backend instanceof AutoLoginBackend) { continue; @@ -112,14 +125,14 @@ class AuthenticationController extends ActionController ); } if ($backendsWithError) { - $this->view->form->addNote( + $form->addNote( $this->translate( 'Note that not all authentication backends are available for authentication because they' . ' have errors. Please check the system log or Icinga Web 2 log for more information' ) ); } - $this->view->form->getElement('password')->addError($this->translate('Incorrect username or password')); + $form->getElement('password')->addError($this->translate('Incorrect username or password')); } } catch (Exception $e) { $this->view->errorInfo = $e->getMessage(); From a38d71f17c652720f5887fc8cfe843edd7e305c3 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 10:27:26 +0200 Subject: [PATCH 40/49] Cli\Command: provide Config() This makes it feel more like action controllers fixes #6954 --- library/Icinga/Cli/Command.php | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/library/Icinga/Cli/Command.php b/library/Icinga/Cli/Command.php index 081be318c..acb2462e4 100644 --- a/library/Icinga/Cli/Command.php +++ b/library/Icinga/Cli/Command.php @@ -7,6 +7,7 @@ namespace Icinga\Cli; use Icinga\Cli\Screen; use Icinga\Util\Translator; use Icinga\Cli\Params; +use Icinga\Application\Config; use Icinga\Application\ApplicationBootstrap as App; use Exception; @@ -23,6 +24,10 @@ abstract class Command protected $commandName; protected $actionName; + private $config; + + private $configs; + protected $defaultActionName = 'default'; public function __construct(App $app, $moduleName, $commandName, $actionName, $initialize = true) @@ -41,6 +46,51 @@ abstract class Command } } + public function Config($file = null) + { + if ($this->isModule()) { + return $this->getModuleConfig($file); + } else { + return $this->getMainConfig($file); + } + } + + private function getModuleConfig($file = null) + { + if ($file === null) { + if ($this->config === null) { + $this->config = Config::module($this->moduleName); + } + return $this->config; + } else { + if (! array_key_exists($file, $this->configs)) { + $this->configs[$file] = Config::module($this->moduleName, $file); + } + return $this->configs[$file]; + } + } + + private function getMainConfig($file = null) + { + if ($file === null) { + if ($this->config === null) { + $this->config = Config::app(); + } + return $this->config; + } else { + if (! array_key_exists($file, $this->configs)) { + $this->configs[$file] = Config::module($module, $file); + } + return $this->configs[$file]; + } + return $this->config; + } + + public function isModule() + { + return substr(get_class($this), 0, 14) === 'Icinga\\Module\\'; + } + public function setParams(Params $params) { $this->params = $params; From c69af6c5d2f72e6c3d93bc94703935ce7426dbf1 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Tue, 19 Aug 2014 11:10:01 +0200 Subject: [PATCH 41/49] Move "modules" to "System" menu resolves #6934 --- .vagrant-puppet/files/etc/icingaweb/menu.ini | 7 ++++++- application/controllers/ConfigController.php | 3 --- config/menu.ini | 7 ++++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/.vagrant-puppet/files/etc/icingaweb/menu.ini b/.vagrant-puppet/files/etc/icingaweb/menu.ini index f01ebaecc..d6f342655 100644 --- a/.vagrant-puppet/files/etc/icingaweb/menu.ini +++ b/.vagrant-puppet/files/etc/icingaweb/menu.ini @@ -18,10 +18,15 @@ title = "Configuration" url = "config" priority = 300 +[System.Modules] +title = "Modules" +url = "config/modules" +priority = 400 + [System.ApplicationLog] title = "Application log" url = "list/applicationlog" -priority = 400 +priority = 500 [Logout] url = "authentication/logout" diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index 31739c30e..df189f47f 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -48,9 +48,6 @@ class ConfigController extends BaseConfigController ))->add('logging', array( 'title' => 'Logging', 'url' => 'config/logging' - ))->add('modules', array( - 'title' => 'Modules', - 'url' => 'config/modules' )); } diff --git a/config/menu.ini b/config/menu.ini index 65959c93a..075f4230e 100644 --- a/config/menu.ini +++ b/config/menu.ini @@ -18,10 +18,15 @@ title = "Configuration" url = "config" priority = 300 +[System.Modules] +title = "Modules" +url = "config/modules" +priority = 400 + [System.ApplicationLog] title = "Application log" url = "list/applicationlog" -priority = 400 +priority = 500 [Logout] url = "authentication/logout" From 0d3fb9e7a55e66a4cd381acae0004592237f60e4 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 11:35:51 +0200 Subject: [PATCH 42/49] LoginForm: explicitely remove renderLayout Should prevent against rare race conditions. refs #6584 --- application/forms/Authentication/LoginForm.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/forms/Authentication/LoginForm.php b/application/forms/Authentication/LoginForm.php index f7fc9f22e..0eff8006c 100644 --- a/application/forms/Authentication/LoginForm.php +++ b/application/forms/Authentication/LoginForm.php @@ -17,7 +17,7 @@ class LoginForm extends Form */ protected function create() { - $url = Url::fromRequest(); + $url = Url::fromRequest()->without('renderLayout'); $this->setName('form_login'); $this->addElement('text', 'username', array( From 9ce99bf2800fc54c3cef55678e91bf0c73689829 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 12:22:36 +0200 Subject: [PATCH 43/49] js/helpers: add $.hasAttr Need this for another fix and there is no such jQuery function. As this seems to also be inconsistant across browsers I thought this would definitively be worth a custom jQuery plugin. --- public/js/helpers.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/public/js/helpers.js b/public/js/helpers.js index 082689e40..416bf1185 100644 --- a/public/js/helpers.js +++ b/public/js/helpers.js @@ -95,6 +95,13 @@ if (!Function.prototype.bind) { 'use strict'; + /* Whether a HTML tag has a specific attribute */ + $.fn.hasAttr = function(name) { + // We have inconsistent behaviour across browsers (false VS undef) + var val = this.attr(name); + return typeof val !== 'undefined' && val !== false; + }; + /* Get class list */ $.fn.classes = function (callback) { From f40ada6c81ef25e1179e899eea1281fe6b132eba Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 12:23:51 +0200 Subject: [PATCH 44/49] js/ui: check whether a link tag has a type The new favicon didn't have such, resulting in JS error when reloading CSS at runtime. --- public/js/icinga/ui.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/js/icinga/ui.js b/public/js/icinga/ui.js index e9f3d741c..8ff3733f0 100644 --- a/public/js/icinga/ui.js +++ b/public/js/icinga/ui.js @@ -100,7 +100,7 @@ icinga.logger.info('Reloading CSS'); $('link').each(function() { var $oldLink = $(this); - if ($oldLink.attr('type').indexOf('css') > -1) { + if ($oldLink.hasAttr('type') && $oldLink.attr('type').indexOf('css') > -1) { var $newLink = $oldLink.clone().attr( 'href', icinga.utils.addUrlParams( From 7334716d156b21047e824a806a1cf84a657c06fb Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 12:25:14 +0200 Subject: [PATCH 45/49] favicon: add link type The favicon link tag was missing a type attribute. --- application/layouts/scripts/layout.phtml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/application/layouts/scripts/layout.phtml b/application/layouts/scripts/layout.phtml index 765873c02..32c4879b4 100644 --- a/application/layouts/scripts/layout.phtml +++ b/application/layouts/scripts/layout.phtml @@ -44,7 +44,7 @@ $iframeClass = $isIframe ? ' iframe' : ''; - + From db3ef8fbd0c598032e3422ff302007c36e60c42a Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 12:28:24 +0200 Subject: [PATCH 46/49] ActionController: remove redirectToLogin default The redirectOnLogin function now doesn't have any predefined default. This also leads to the behaviour that "Logout" will not redirect you anywhere on a new login while "forcibly being logged out" (e.g. by logging out in another browser tab) will bring you back to where you came from. --- .../Web/Controller/ActionController.php | 23 +++++++++++-------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/library/Icinga/Web/Controller/ActionController.php b/library/Icinga/Web/Controller/ActionController.php index d8e340907..13809e83d 100644 --- a/library/Icinga/Web/Controller/ActionController.php +++ b/library/Icinga/Web/Controller/ActionController.php @@ -254,18 +254,23 @@ class ActionController extends Zend_Controller_Action * * @throws \Exception */ - protected function redirectToLogin($afterLogin = '/dashboard') + protected function redirectToLogin($afterLogin = null) { - if (! $afterLogin instanceof Url) { - $afterLogin = Url::fromPath($afterLogin); - } - if ($this->isXhr()) { - $redir = '__SELF__'; - } else { - // TODO: Ignore /? - $redir = $afterLogin->getRelativeUrl(); + $redir = null; + if ($afterLogin !== null) { + if (! $afterLogin instanceof Url) { + $afterLogin = Url::fromPath($afterLogin); + } + if ($this->isXhr()) { + $redir = '__SELF__'; + } else { + // TODO: Ignore /? + $redir = $afterLogin->getRelativeUrl(); + } } + $url = Url::fromPath('authentication/login'); + if ($redir) { $url->setParam('redirect', $redir); } From 3f65f3447d1255284ffb34f7e91dc961389b42e8 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 12:39:53 +0200 Subject: [PATCH 47/49] Web\UrlTest: test should use %20 instead of + We MUST use rawurlencode everywhere to avoid potential conflicts with URLs created on JS side. refs #6604 --- test/php/library/Icinga/Web/UrlTest.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/php/library/Icinga/Web/UrlTest.php b/test/php/library/Icinga/Web/UrlTest.php index 0eff54e5c..183f33369 100644 --- a/test/php/library/Icinga/Web/UrlTest.php +++ b/test/php/library/Icinga/Web/UrlTest.php @@ -21,7 +21,7 @@ class UrlTest extends BaseTestCase $url = Url::fromRequest(); $this->assertEquals( '/path/to/my/test/url.html?param1=value1&param2=value2', - $url->getAbsoluteUrl(), + $url->getAbsoluteUrl('&'), 'Url::fromRequest does not reassemble the correct url from the global request' ); } @@ -119,7 +119,7 @@ class UrlTest extends BaseTestCase */ public function testWhetherFromPathProperlyRecognizesAndDecodesQueryParameters() { - $url = Url::fromPath('/my/test/url.html?param1=%25arg1¶m2=arg+2' + $url = Url::fromPath('/my/test/url.html?param1=%25arg1¶m2=arg%202' . '¶m3[]=1¶m3[]=2¶m3[]=3¶m4[key1]=val1¶m4[key2]=val2'); $this->assertEquals( From cd825a4e6b5e2c13cc76f038f22ade6c12f30be7 Mon Sep 17 00:00:00 2001 From: Thomas Gelf Date: Tue, 19 Aug 2014 12:45:42 +0200 Subject: [PATCH 48/49] tests/ScrollingStyle: adjust, pagination shortened Pagination has been "shortened" some time ago to waste less space, tests now fit the current implementation. fixes #6594 fixes #6595 --- .../Paginator/ScrollingStyle/SlidingWithBorderTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php b/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php index d9eb0b25b..a77dcb553 100644 --- a/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php +++ b/test/php/library/Icinga/Web/Paginator/ScrollingStyle/SlidingWithBorderTest.php @@ -19,8 +19,8 @@ class SlidingwithborderTest extends BaseTestCase $pages = $scrollingStyle->getPages($paginator); $this->assertInternalType('array', $pages); - $this->assertCount(13, $pages); - $this->assertEquals('...', $pages[11]); + $this->assertCount(10, $pages); + $this->assertEquals('...', $pages[8]); } public function testGetPages3() @@ -31,9 +31,9 @@ class SlidingwithborderTest extends BaseTestCase $pages = $scrollingStyle->getPages($paginator); $this->assertInternalType('array', $pages); - $this->assertCount(16, $pages); + $this->assertCount(10, $pages); $this->assertEquals('...', $pages[3]); - $this->assertEquals('...', $pages[14]); + $this->assertEquals('...', $pages[12]); } protected function getPaginatorAdapter() From 2f54ff4797cc321261288e28658c3ef993f44710 Mon Sep 17 00:00:00 2001 From: Alexander Fuhr Date: Tue, 19 Aug 2014 13:17:31 +0200 Subject: [PATCH 49/49] Fix the unrelated tabs resolves #6934 --- application/controllers/ConfigController.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/application/controllers/ConfigController.php b/application/controllers/ConfigController.php index df189f47f..45be1d3fd 100644 --- a/application/controllers/ConfigController.php +++ b/application/controllers/ConfigController.php @@ -67,7 +67,7 @@ class ConfigController extends BaseConfigController $form->setConfiguration(IcingaConfig::app()); $form->setRequest($this->_request); if ($form->isSubmittedAndValid()) { - if (!$this->writeConfigFile($form->getConfig(), 'config')) { + if (!$this->writeConfigFile($form->getConfig(), 'config')) { return; } Notification::success('New configuration has successfully been stored'); @@ -104,6 +104,11 @@ class ConfigController extends BaseConfigController */ public function modulesAction() { + $this->view->tabs = Widget::create('tabs')->add('modules', array( + 'title' => 'Modules', + 'url' => 'config/modules' + )); + $this->view->tabs->activate('modules'); $this->view->modules = Icinga::app()->getModuleManager()->select() ->from('modules')