diff --git a/config/modules/monitoring/backends.ini.in b/config/modules/monitoring/backends.ini.in index c763f076a..910f17f81 100644 --- a/config/modules/monitoring/backends.ini.in +++ b/config/modules/monitoring/backends.ini.in @@ -1,15 +1,17 @@ [localdb] -type = ido -resource = "ido" +@ido_enabled@ +type = ido +resource = "ido" [locallive] -type = livestatus -socket = @livestatus_socket@ +@livestatus_enabled@ +type = livestatus +resource = livestatus [localfile] -type = statusdat -status_file = @statusdat_file@ -objects_file = @objects_cache_file@ +@statusdat_enabled@ +type = statusdat +resource = statusdat ;[localfailsafe] ;enabled=false diff --git a/config/resources.ini.in b/config/resources.ini.in index aca3a227a..e1daeb27a 100755 --- a/config/resources.ini.in +++ b/config/resources.ini.in @@ -30,3 +30,12 @@ port = @ido_port@ password = @ido_user@ username = @ido_user@ dbname = @ido_database@ + +[statusdat] +type = statusdat +status_file = /usr/local/icinga-mysql/var/status.dat +object_file = /usr/local/icinga-mysql/var/objects.cache + +[livestatus] +type = livestatus +socket = @livestatus_socket@ diff --git a/configure b/configure index 5f4497146..7b92f7802 100755 --- a/configure +++ b/configure @@ -593,15 +593,18 @@ INSTALL_OPTS use_internal_auth use_ldap_auth icinga_commandpipe +livestatus_enabled livestatus_socket objects_cache_file statusdat_file +statusdat_enabled ido_password ido_user ido_database ido_port ido_host ido_db_type +ido_enabled icinga_backend ldap_attribute_username ldap_attribute_basedn @@ -1394,7 +1397,7 @@ Optional Packages: location of the status.dat file when retrieving data from status.dat (default: /usr/local/icinga/var/status.dat) - --with-objects-file=FILE + --with-objects-cache-file=FILE location of the objects.cache file when retrieving data from status.dat (default: /usr/local/icinga/var/objects.cache) @@ -1405,6 +1408,10 @@ Optional Packages: location of the command pipe used for sending commands (default: /usr/local/icinga/var/rw/icinga.cmd) + --with-objects-file=FILE + location of the objects.cache file when retrieving + data from status.dat (default: + /usr/local/icinga/var/objects.cache) Some influential environment variables: PHP php cli binary @@ -2810,9 +2817,9 @@ fi # Comment out the disabled backends per default # -ido_enabled="disable=1" -statusdat_enabled="disable=1" -livestatus_enabled="disable=1" +ido_enabled="disabled = \"1\"" +statusdat_enabled="disabled = \"1\"" +livestatus_enabled="disabled = \"1\"" case $icinga_backend in #( "ido") : @@ -2905,13 +2912,16 @@ fi + # status.dat backend + # livestatus backend + # command pipe diff --git a/configure.ac b/configure.ac index 00936eda2..277703bc6 100755 --- a/configure.ac +++ b/configure.ac @@ -255,7 +255,7 @@ AC_ARG_WITH([statusdat_file], ) AC_ARG_WITH([objects_cache_file], - AS_HELP_STRING([--with-objects-file=FILE], [location of the objects.cache file when retrieving data from status.dat (default: /usr/local/icinga/var/objects.cache)]), + AS_HELP_STRING([--with-objects-cache-file=FILE], [location of the objects.cache file when retrieving data from status.dat (default: /usr/local/icinga/var/objects.cache)]), objects_cache_file=$withval, objects_cache_file="/usr/local/icinga/var/objects.cache" ) @@ -338,9 +338,9 @@ AS_IF([test "x$ido_db_type" = xpgsql], [ # Comment out the disabled backends per default # -ido_enabled="disable=1" -statusdat_enabled="disable=1" -livestatus_enabled="disable=1" +ido_enabled="disabled = \"1\"" +statusdat_enabled="disabled = \"1\"" +livestatus_enabled="disabled = \"1\"" AS_CASE([$icinga_backend], ["ido"], [ido_enabled=""], @@ -397,6 +397,7 @@ AC_SUBST(ldap_attribute_username) AC_SUBST(icinga_backend) # ido backend variables +AC_SUBST(ido_enabled) AC_SUBST(ido_db_type) AC_SUBST(ido_host) AC_SUBST(ido_port) @@ -405,11 +406,13 @@ AC_SUBST(ido_user) AC_SUBST(ido_password) # status.dat backend +AC_SUBST(statusdat_enabled) AC_SUBST(statusdat_file) AC_SUBST(objects_cache_file) # livestatus backend AC_SUBST(livestatus_socket) +AC_SUBST(livestatus_enabled) # command pipe AC_SUBST(icinga_commandpipe) diff --git a/library/Icinga/Data/ResourceFactory.php b/library/Icinga/Data/ResourceFactory.php index bfd5afcab..3d4343b1c 100644 --- a/library/Icinga/Data/ResourceFactory.php +++ b/library/Icinga/Data/ResourceFactory.php @@ -40,7 +40,7 @@ class ResourceFactory implements ConfigAwareFactory $resource = new StatusdatReader($config); break; default: - throw new ConfigurationError('Unsupported Backend "' + $config->type + '"'); + throw new ConfigurationError('Unsupported resource type "' . $config->type . '"'); } return $resource; diff --git a/modules/monitoring/library/Monitoring/Backend.php b/modules/monitoring/library/Monitoring/Backend.php index 500666f54..75a5e949e 100644 --- a/modules/monitoring/library/Monitoring/Backend.php +++ b/modules/monitoring/library/Monitoring/Backend.php @@ -128,8 +128,17 @@ class Backend implements ConfigAwareFactory, DatasourceInterface 'Cannot get default backend as no backend has been configured' ); } - reset($configs); - return key($configs); + + // We won't have disabled backends + foreach ($configs as $name => $config) { + if (!$config->get('disabled') == '1') { + return $name; + } + } + + throw new ConfigurationError( + 'All backends are disabled' + ); } /** @@ -149,11 +158,19 @@ class Backend implements ConfigAwareFactory, DatasourceInterface $name = self::getDefaultBackendName(); } + $config = null; + if (isset(self::$backendConfigs[$name])) { + /** @var Zend_Config $config */ $config = self::$backendConfigs[$name]; - } else { + if ($config->get('disabled') == '1') { + $config = null; + } + } + + if ($config === null) { throw new ConfigurationError( - 'No configuration for backend' . $name + 'No configuration for backend:' . $name ); }