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/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 + diff --git a/application/forms/Config/GeneralForm.php b/application/forms/Config/GeneralForm.php index ced24401c..debb27d44 100644 --- a/application/forms/Config/GeneralForm.php +++ b/application/forms/Config/GeneralForm.php @@ -93,7 +93,6 @@ class GeneralForm extends Form foreach (Translator::getAvailableLocaleCodes() as $language) { $languages[$language] = $language; } - $languages[Translator::DEFAULT_LOCALE] = Translator::DEFAULT_LOCALE; $this->addElement( 'select', diff --git a/application/forms/Preference/GeneralForm.php b/application/forms/Preference/GeneralForm.php index fbc8f8d74..204ddc51d 100644 --- a/application/forms/Preference/GeneralForm.php +++ b/application/forms/Preference/GeneralForm.php @@ -33,7 +33,6 @@ class GeneralForm extends Form foreach (Translator::getAvailableLocaleCodes() as $language) { $languages[$language] = $language; } - $languages[Translator::DEFAULT_LOCALE] = Translator::DEFAULT_LOCALE; $prefs = $this->getUserPreferences(); $useDefaultLanguage = $this->getRequest()->getParam('default_language', !$prefs->has('app.language')); 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@ diff --git a/icingaweb2.spec b/icingaweb2.spec index b1cb3d2e5..0da22b8ea 100644 --- a/icingaweb2.spec +++ b/icingaweb2.spec @@ -1,16 +1,37 @@ -# $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 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 +58,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 +130,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 +151,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 +213,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 +223,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 +241,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/library/Icinga/Protocol/Commandpipe/CommandPipe.php b/library/Icinga/Protocol/Commandpipe/CommandPipe.php index 91be222cd..8d149dd20 100644 --- a/library/Icinga/Protocol/Commandpipe/CommandPipe.php +++ b/library/Icinga/Protocol/Commandpipe/CommandPipe.php @@ -109,7 +109,19 @@ class CommandPipe */ public function send($command) { - $this->transport->send($command); + $this->transport->send($this->escape($command)); + } + + /** + * Return the given command string with escaped newlines + * + * @param string $command The command string to escape + * + * @return string The escaped command string + */ + public function escape($command) + { + return str_replace(array("\r", "\n"), array('\r', '\n'), $command); } /** @@ -121,16 +133,14 @@ class CommandPipe public function sendCommand(Command $command, array $objects = array()) { if ($command->provideGlobalCommand() === true) { - $this->transport->send($command->getGlobalCommand()); + $this->send($command->getGlobalCommand()); } else { foreach ($objects as $object) { $objectType = $this->getObjectType($object); if ($objectType === self::TYPE_SERVICE) { - $this->transport->send( - $command->getServiceCommand($object->host_name, $object->service_description) - ); + $this->send($command->getServiceCommand($object->host_name, $object->service_description)); } else { - $this->transport->send($command->getHostCommand($object->host_name)); + $this->send($command->getHostCommand($object->host_name)); } } } diff --git a/library/Icinga/Util/Translator.php b/library/Icinga/Util/Translator.php index 111e414ad..fd01812b3 100644 --- a/library/Icinga/Util/Translator.php +++ b/library/Icinga/Util/Translator.php @@ -115,7 +115,7 @@ class Translator */ public static function getAvailableLocaleCodes() { - $codes = array(); + $codes = array(static::DEFAULT_LOCALE); foreach (array_values(self::$knownDomains) as $directory) { $dh = opendir($directory); while (false !== ($name = readdir($dh))) { diff --git a/library/Icinga/Web/Url.php b/library/Icinga/Web/Url.php index c705b68d7..ef5a15aa9 100644 --- a/library/Icinga/Web/Url.php +++ b/library/Icinga/Web/Url.php @@ -130,7 +130,7 @@ class Url // Fetch fragment manually and remove it from the url, to 'help' the parse_url() function // parsing the url properly. Otherwise calling the function with a fragment, but without a // query will cause unpredictable behaviour. - $url = self::stripUrlFragment($url); + $fragment = self::stripUrlFragment($url); $urlParts = parse_url($url); if (isset($urlParts['path'])) { if ($baseUrl !== '' && strpos($urlParts['path'], $baseUrl) === 0) { @@ -144,8 +144,7 @@ class Url $params = UrlParams::fromQueryString($urlParts['query'])->mergeValues($params); } - $fragment = self::getUrlFragment($url); - if ($fragment !== '') { + if ($fragment) { $urlObject->setAnchor($fragment); } @@ -154,34 +153,20 @@ class Url } /** - * Get the fragment of a given url + * Remove the fragment-part of a given url and return it * - * @param string $url The url containing the fragment. + * @param string $url The url to strip its fragment from * - * @return string The fragment without the '#' + * @return null|string The stripped fragment, without the '#' */ - protected static function getUrlFragment($url) + protected static function stripUrlFragment(&$url) { - $url = parse_url($url); - if (isset($url['fragment'])) { - return $url['fragment']; - } else { - return ''; + if (preg_match('@#(.*)$@', $url, $matches)) { + $url = str_replace('#' . $matches[1], '', $url); + return $matches[1]; } } - /** - * Remove the fragment-part of a given url - * - * @param string $url The url to strip from its fragment - * - * @return string The url without the fragment - */ - protected static function stripUrlFragment($url) - { - return preg_replace('/#.*$/', '', $url); - } - /** * Overwrite the baseUrl * diff --git a/library/Icinga/Web/Widget/Tabextension/DashboardAction.php b/library/Icinga/Web/Widget/Tabextension/DashboardAction.php index 3d1c97ed0..241b83556 100644 --- a/library/Icinga/Web/Widget/Tabextension/DashboardAction.php +++ b/library/Icinga/Web/Widget/Tabextension/DashboardAction.php @@ -28,7 +28,7 @@ class DashboardAction implements Tabextension 'title' => 'Add To Dashboard', 'url' => Url::fromPath('dashboard/addurl'), 'urlParams' => array( - 'url' => Url::fromRequest()->getRelativeUrl() + 'url' => rawurlencode(Url::fromRequest()->getRelativeUrl()) ) ) ); 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' ) ?>