Fix backend configuration while installation

refs #4941
This commit is contained in:
Marius Hein 2013-10-22 16:04:38 +02:00
parent 8c640cbab7
commit b9f03e27b7
6 changed files with 61 additions and 20 deletions

View File

@ -1,15 +1,17 @@
[localdb] [localdb]
type = ido @ido_enabled@
resource = "ido" type = ido
resource = "ido"
[locallive] [locallive]
type = livestatus @livestatus_enabled@
socket = @livestatus_socket@ type = livestatus
resource = livestatus
[localfile] [localfile]
type = statusdat @statusdat_enabled@
status_file = @statusdat_file@ type = statusdat
objects_file = @objects_cache_file@ resource = statusdat
;[localfailsafe] ;[localfailsafe]
;enabled=false ;enabled=false

View File

@ -30,3 +30,12 @@ port = @ido_port@
password = @ido_user@ password = @ido_user@
username = @ido_user@ username = @ido_user@
dbname = @ido_database@ 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@

18
configure vendored
View File

@ -593,15 +593,18 @@ INSTALL_OPTS
use_internal_auth use_internal_auth
use_ldap_auth use_ldap_auth
icinga_commandpipe icinga_commandpipe
livestatus_enabled
livestatus_socket livestatus_socket
objects_cache_file objects_cache_file
statusdat_file statusdat_file
statusdat_enabled
ido_password ido_password
ido_user ido_user
ido_database ido_database
ido_port ido_port
ido_host ido_host
ido_db_type ido_db_type
ido_enabled
icinga_backend icinga_backend
ldap_attribute_username ldap_attribute_username
ldap_attribute_basedn ldap_attribute_basedn
@ -1394,7 +1397,7 @@ Optional Packages:
location of the status.dat file when retrieving data location of the status.dat file when retrieving data
from status.dat (default: from status.dat (default:
/usr/local/icinga/var/status.dat) /usr/local/icinga/var/status.dat)
--with-objects-file=FILE --with-objects-cache-file=FILE
location of the objects.cache file when retrieving location of the objects.cache file when retrieving
data from status.dat (default: data from status.dat (default:
/usr/local/icinga/var/objects.cache) /usr/local/icinga/var/objects.cache)
@ -1405,6 +1408,10 @@ Optional Packages:
location of the command pipe used for sending location of the command pipe used for sending
commands (default: commands (default:
/usr/local/icinga/var/rw/icinga.cmd) /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: Some influential environment variables:
PHP php cli binary PHP php cli binary
@ -2810,9 +2817,9 @@ fi
# Comment out the disabled backends per default # Comment out the disabled backends per default
# #
ido_enabled="disable=1" ido_enabled="disabled = \"1\""
statusdat_enabled="disable=1" statusdat_enabled="disabled = \"1\""
livestatus_enabled="disable=1" livestatus_enabled="disabled = \"1\""
case $icinga_backend in #( case $icinga_backend in #(
"ido") : "ido") :
@ -2905,13 +2912,16 @@ fi
# status.dat backend # status.dat backend
# livestatus backend # livestatus backend
# command pipe # command pipe

View File

@ -255,7 +255,7 @@ AC_ARG_WITH([statusdat_file],
) )
AC_ARG_WITH([objects_cache_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=$withval,
objects_cache_file="/usr/local/icinga/var/objects.cache" 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 # Comment out the disabled backends per default
# #
ido_enabled="disable=1" ido_enabled="disabled = \"1\""
statusdat_enabled="disable=1" statusdat_enabled="disabled = \"1\""
livestatus_enabled="disable=1" livestatus_enabled="disabled = \"1\""
AS_CASE([$icinga_backend], AS_CASE([$icinga_backend],
["ido"], [ido_enabled=""], ["ido"], [ido_enabled=""],
@ -397,6 +397,7 @@ AC_SUBST(ldap_attribute_username)
AC_SUBST(icinga_backend) AC_SUBST(icinga_backend)
# ido backend variables # ido backend variables
AC_SUBST(ido_enabled)
AC_SUBST(ido_db_type) AC_SUBST(ido_db_type)
AC_SUBST(ido_host) AC_SUBST(ido_host)
AC_SUBST(ido_port) AC_SUBST(ido_port)
@ -405,11 +406,13 @@ AC_SUBST(ido_user)
AC_SUBST(ido_password) AC_SUBST(ido_password)
# status.dat backend # status.dat backend
AC_SUBST(statusdat_enabled)
AC_SUBST(statusdat_file) AC_SUBST(statusdat_file)
AC_SUBST(objects_cache_file) AC_SUBST(objects_cache_file)
# livestatus backend # livestatus backend
AC_SUBST(livestatus_socket) AC_SUBST(livestatus_socket)
AC_SUBST(livestatus_enabled)
# command pipe # command pipe
AC_SUBST(icinga_commandpipe) AC_SUBST(icinga_commandpipe)

View File

@ -40,7 +40,7 @@ class ResourceFactory implements ConfigAwareFactory
$resource = new StatusdatReader($config); $resource = new StatusdatReader($config);
break; break;
default: default:
throw new ConfigurationError('Unsupported Backend "' + $config->type + '"'); throw new ConfigurationError('Unsupported resource type "' . $config->type . '"');
} }
return $resource; return $resource;

View File

@ -128,8 +128,17 @@ class Backend implements ConfigAwareFactory, DatasourceInterface
'Cannot get default backend as no backend has been configured' '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(); $name = self::getDefaultBackendName();
} }
$config = null;
if (isset(self::$backendConfigs[$name])) { if (isset(self::$backendConfigs[$name])) {
/** @var Zend_Config $config */
$config = self::$backendConfigs[$name]; $config = self::$backendConfigs[$name];
} else { if ($config->get('disabled') == '1') {
$config = null;
}
}
if ($config === null) {
throw new ConfigurationError( throw new ConfigurationError(
'No configuration for backend' . $name 'No configuration for backend:' . $name
); );
} }