Improve path handling in cmake and daemon

This commit is contained in:
Markus Frosch 2018-07-31 11:59:09 +02:00 committed by Gunnar Beutner
parent a7a012272f
commit 9fbc40615a
64 changed files with 498 additions and 708 deletions

View File

@ -47,19 +47,43 @@ string(REPLACE "Version: " "" ICINGA2_VERSION ${VERSION_LINE})
include(GNUInstallDirs)
include(InstallConfig)
include(SetFullDir)
set(ICINGA2_USER "icinga" CACHE STRING "Icinga 2 user")
set(ICINGA2_GROUP "icinga" CACHE STRING "Icinga 2 group")
set(ICINGA2_COMMAND_GROUP "icingacmd" CACHE STRING "Icinga 2 command group")
set(ICINGA2_RUNDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/run" CACHE STRING "/run directory")
set(ICINGA2_PLUGINDIR "/usr/lib/nagios/plugins" CACHE STRING "Path for the check plugins")
set(ICINGA2_GIT_VERSION_INFO ON CACHE BOOL "Whether to use git describe")
set(ICINGA2_UNITY_BUILD ON CACHE BOOL "Whether to perform a unity build")
set(ICINGA2_LTO_BUILD OFF CACHE BOOL "Whether to use LTO")
if(NOT WIN32)
set(ICINGA2_SYSCONFIGFILE "${CMAKE_INSTALL_FULL_SYSCONFDIR}/sysconfig/icinga2" CACHE PATH "where to store configuation for the init system, defaults to /etc/sysconfig/icinga2")
set(ICINGA2_CONFIGDIR "${CMAKE_INSTALL_SYSCONFDIR}/icinga2" CACHE FILEPATH "Main config directory, e.g. /etc/icinga2")
set(ICINGA2_CACHEDIR "${CMAKE_INSTALL_LOCALSTATEDIR}/cache/icinga2" CACHE FILEPATH "Directory for cache files, e.g. /var/cache/icinga2")
set(ICINGA2_DATADIR "${CMAKE_INSTALL_LOCALSTATEDIR}/lib/icinga2" CACHE FILEPATH "Data directory for the daemon, e.g. /var/lib/icinga2")
set(ICINGA2_LOGDIR "${CMAKE_INSTALL_LOCALSTATEDIR}/log/icinga2" CACHE FILEPATH "Logging directory, e.g. /var/log/icinga2")
set(ICINGA2_SPOOLDIR "${CMAKE_INSTALL_LOCALSTATEDIR}/spool/icinga2" CACHE FILEPATH "Spooling directory, e.g. /var/spool/icinga2")
set(ICINGA2_RUNDIR "${CMAKE_INSTALL_LOCALSTATEDIR}/run" CACHE STRING "/run directory (deprecated, please use ICINGA2_INITRUNDIR)")
set(ICINGA2_INITRUNDIR "${ICINGA2_RUNDIR}/icinga2" CACHE FILEPATH "Runtime data for the init system, e.g. /run/icinga2")
set(ICINGA2_PKGDATADIR "${CMAKE_INSTALL_DATADIR}/icinga2" CACHE FILEPATH "Installed data, e.g. /usr/share/icinga2")
set(ICINGA2_INCLUDEDIR "${ICINGA2_PKGDATADIR}/include" CACHE FILEPATH "Include directory for the ITL, e.g. /usr/share/icinga2/include")
# ensure absolute paths
set_full_dir(ICINGA2_FULL_CONFIGDIR "${ICINGA2_CONFIGDIR}")
set_full_dir(ICINGA2_FULL_CACHEDIR "${ICINGA2_CACHEDIR}")
set_full_dir(ICINGA2_FULL_DATADIR "${ICINGA2_DATADIR}")
set_full_dir(ICINGA2_FULL_LOGDIR "${ICINGA2_LOGDIR}")
set_full_dir(ICINGA2_FULL_SPOOLDIR "${ICINGA2_SPOOLDIR}")
set_full_dir(ICINGA2_FULL_RUNDIR "${ICINGA2_RUNDIR}")
set_full_dir(ICINGA2_FULL_INITRUNDIR "${ICINGA2_INITRUNDIR}")
set_full_dir(ICINGA2_FULL_PKGDATADIR "${ICINGA2_PKGDATADIR}")
set_full_dir(ICINGA2_FULL_INCLUDEDIR "${ICINGA2_INCLUDEDIR}")
set(LOGROTATE_DIR "${CMAKE_INSTALL_SYSCONFDIR}/logrotate.d" CACHE STRING "Location of logrotate configs, e.g. /etc/logrotate.d")
set(BASHCOMPLETION_DIR "${CMAKE_INSTALL_SYSCONFDIR}/bash_completion.d" CACHE STRING "Location of bash_completion files, e.g. /etc/bash_completion.d")
if(NOT WIN32)
set(ICINGA2_SYSCONFIGFILE "${CMAKE_INSTALL_SYSCONFDIR}/sysconfig/icinga2" CACHE PATH "where to store configuation for the init system, defaults to /etc/sysconfig/icinga2")
endif()
site_name(ICINGA2_BUILD_HOST_NAME)

View File

@ -130,16 +130,26 @@ $ cmake .. -DCMAKE_INSTALL_PREFIX=/tmp/icinga2
In addition to `CMAKE_INSTALL_PREFIX` here are most of the supported Icinga-specific cmake variables.
For all variables regarding defaults paths on in CMake, see
[GNUInstallDirs](https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html).
Also see `CMakeLists.txt` for details.
**System Environment**
- `CMAKE_INSTALL_SYSCONFDIR`: The configuration directory; defaults to `CMAKE_INSTALL_PREFIX/etc`
- `CMAKE_INSTALL_LOCALSTATEDIR`: The state directory; defaults to `CMAKE_INSTALL_PREFIX/var`
- `ICINGA2_CONFIGDIR`: Main config directory; defaults to `CMAKE_INSTALL_SYSCONFDIR/icinga2` usually `/etc/icinga2`
- `ICINGA2_CACHEDIR`: Directory for cache files; defaults to `CMAKE_INSTALL_LOCALSTATEDIR/cache/icinga2` usually `/var/cache/icinga2`
- `ICINGA2_DATADIR`: Data directory for the daemon; defaults to `CMAKE_INSTALL_LOCALSTATEDIR/lib/icinga2` usually `/var/lib/icinga2`
- `ICINGA2_LOGDIR`: Logfiles of the daemon; defaults to `CMAKE_INSTALL_LOCALSTATEDIR/log/icinga2 usually `/var/log/icinga2`
- `ICINGA2_SPOOLDIR`: Spooling directory ; defaults to `CMAKE_INSTALL_LOCALSTATEDIR/spool/icinga2` usually `/var/spool/icinga2`
- `ICINGA2_INITRUNDIR`: Runtime data for the init system; defaults to `CMAKE_INSTALL_LOCALSTATEDIR/run/icinga2` usually `/run/icinga2`
- `ICINGA2_GIT_VERSION_INFO`: Whether to use Git to determine the version number; defaults to `ON`
- `ICINGA2_USER`: The user Icinga 2 should run as; defaults to `icinga`
- `ICINGA2_GROUP`: The group Icinga 2 should run as; defaults to `icinga`
- `ICINGA2_COMMAND_GROUP`: The command group Icinga 2 should use; defaults to `icingacmd`
- `ICINGA2_RUNDIR`: The location of the "run" directory; defaults to `CMAKE_INSTALL_LOCALSTATEDIR/run`
- `CMAKE_INSTALL_SYSCONFDIR`: The configuration directory; defaults to `CMAKE_INSTALL_PREFIX/etc`
- `ICINGA2_SYSCONFIGFILE`: Where to put the config file the initscript/systemd pulls it's dirs from;
defaults to `CMAKE_INSTALL_PREFIX/etc/sysconfig/icinga2`
- `CMAKE_INSTALL_LOCALSTATEDIR`: The state directory; defaults to `CMAKE_INSTALL_PREFIX/var`
- `ICINGA2_PLUGINDIR`: The path for the Monitoring Plugins project binaries; defaults to `/usr/lib/nagios/plugins`
**Build Optimization**

26
cmake/SetFullDir.cmake Normal file
View File

@ -0,0 +1,26 @@
# Icinga 2
# Copyright (C) 2018 Icinga Development Team (https://www.icinga.com)
#
# 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 St, Fifth Floor, Boston, MA 02110-1301, USA.
# Ensures a directory is absolute by prefixing CMAKE_INSTALL_PREFIX if it is not
# similar to CMAKE_INSTALL_FULL_... https://cmake.org/cmake/help/latest/module/GNUInstallDirs.html
function(set_full_dir var path)
if(NOT IS_ABSOLUTE "${path}")
message(STATUS "Prefixing in ${var} \"${path}\" with ${CMAKE_INSTALL_PREFIX}")
set(path "${CMAKE_INSTALL_PREFIX}/${path}")
endif()
set(${var} "${path}" PARENT_SCOPE)
endfunction(set_full_dir)

View File

@ -13,17 +13,24 @@
#cmakedefine ICINGA2_UNITY_BUILD
#define ICINGA_PREFIX "${CMAKE_INSTALL_PREFIX}"
#define ICINGA_SYSCONFDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}"
#define ICINGA_RUNDIR "${ICINGA2_RUNDIR}"
#define ICINGA_LOCALSTATEDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}"
#define ICINGA_PKGDATADIR "${CMAKE_INSTALL_FULL_DATADIR}/icinga2"
#define ICINGA_INCLUDECONFDIR "${CMAKE_INSTALL_FULL_DATADIR}/icinga2/include"
#define ICINGA_CONFIGDIR "${ICINGA2_FULL_CONFIGDIR}"
#define ICINGA_DATADIR "${ICINGA2_FULL_DATADIR}"
#define ICINGA_LOGDIR "${ICINGA2_FULL_LOGDIR}"
#define ICINGA_CACHEDIR "${ICINGA2_FULL_CACHEDIR}"
#define ICINGA_SPOOLDIR "${ICINGA2_FULL_SPOOLDIR}"
#define ICINGA_INITRUNDIR "${ICINGA2_FULL_INITRUNDIR}"
#define ICINGA_INCLUDECONFDIR "${ICINGA2_FULL_INCLUDEDIR}"
#define ICINGA_USER "${ICINGA2_USER}"
#define ICINGA_GROUP "${ICINGA2_GROUP}"
#define ICINGA_SYSCONFIGFILE "${ICINGA2_SYSCONFIGFILE}"
#define ICINGA_BUILD_HOST_NAME "${ICINGA2_BUILD_HOST_NAME}"
#define ICINGA_BUILD_COMPILER_NAME "${ICINGA2_BUILD_COMPILER_NAME}"
#define ICINGA_BUILD_COMPILER_VERSION "${ICINGA2_BUILD_COMPILER_VERSION}"
// Deprecated options?
#define ICINGA_PKGDATADIR "${ICINGA2_FULL_PKGDATADIR}"
#define ICINGA_PREFIX "${CMAKE_INSTALL_PREFIX}"
#define ICINGA_SYSCONFDIR "${CMAKE_INSTALL_FULL_SYSCONFDIR}"
#define ICINGA_RUNDIR "${ICINGA2_FULL_RUNDIR}"
#define ICINGA_LOCALSTATEDIR "${CMAKE_INSTALL_FULL_LOCALSTATEDIR}"
#endif /* CONFIG_H */

View File

@ -211,7 +211,7 @@ match your Icinga convention.
Add an `EventCommand` configuration object for the passive service auto reset event.
object EventCommand "coldstart-reset-event" {
command = [ SysconfDir + "/icinga2/conf.d/custom/scripts/coldstart_reset_event.sh" ]
command = [ ConfigDir + "/conf.d/custom/scripts/coldstart_reset_event.sh" ]
arguments = {
"-i" = "$service.state_id$"
@ -356,4 +356,3 @@ passive update with the state and text from the second and third varbind:
vars.dummy_state = 2
vars.dummy_text = "No passive check result received."
}

View File

@ -990,7 +990,7 @@ You can omit the `log()` calls, they only help debugging.
log("Running command")
log(mailscript)
var cmd = [ SysconfDir + "/icinga2/scripts/" + mailscript ]
var cmd = [ ConfigDir + "/scripts/" + mailscript ]
log(LogCritical, "me", cmd)
return cmd
}}

View File

@ -76,12 +76,12 @@ The ApiListener type expects its certificate files to be in the following locati
Type | Location
---------------------|-------------------------------------
Private key | `LocalStateDir + "/lib/icinga2/certs/" + NodeName + ".key"`
Certificate file | `LocalStateDir + "/lib/icinga2/certs/" + NodeName + ".crt"`
CA certificate file | `LocalStateDir + "/lib/icinga2/certs/ca.crt"`
Private key | `DataDir + "/certs/" + NodeName + ".key"`
Certificate file | `DataDir + "/certs/" + NodeName + ".crt"`
CA certificate file | `DataDir + "/certs/ca.crt"`
If the deprecated attributes `cert_path`, `key_path` and/or `ca_path` are specified Icinga 2
copies those files to the new location in `LocalStateDir + "/lib/icinga2/certs"` unless the
copies those files to the new location in `DataDir + "/certs"` unless the
file(s) there are newer.
Please check the [upgrading chapter](16-upgrading-icinga-2.md#upgrading-to-2-8-certificate-paths) for more details.
@ -273,7 +273,7 @@ Configuration Attributes:
Name | Type | Description
--------------------------|-----------------------|----------------------------------
spool\_dir | String | **Optional.** The directory which contains the check result files. Defaults to LocalStateDir + "/lib/icinga2/spool/checkresults/".
spool\_dir | String | **Optional.** The directory which contains the check result files. Defaults to DataDir + "/spool/checkresults/".
## Comment <a id="objecttype-comment"></a>
@ -322,7 +322,7 @@ Configuration Attributes:
Name | Type | Description
--------------------------|-----------------------|----------------------------------
log\_dir | String | **Optional.** Path to the compat log directory. Defaults to LocalStateDir + "/log/icinga2/compat".
log\_dir | String | **Optional.** Path to the compat log directory. Defaults to LogDir + "/compat".
rotation\_method | String | **Optional.** Specifies when to rotate log files. Can be one of "HOURLY", "DAILY", "WEEKLY" or "MONTHLY". Defaults to "HOURLY".
@ -1084,7 +1084,7 @@ Configuration Attributes:
bind\_host | String | **Optional.** Only valid when `socket_type` is set to `tcp`. Host address to listen on for connections. Defaults to `127.0.0.1`.
bind\_port | Number | **Optional.** Only valid when `socket_type` is set to `tcp`. Port to listen on for connections. Defaults to `6558`.
socket\_path | String | **Optional.** Only valid when `socket_type` is set to `unix`. Specifies the path to the UNIX socket file. Defaults to RunDir + "/icinga2/cmd/livestatus".
compat\_log\_path | String | **Optional.** Path to Icinga 1.x log files. Required for historical table queries. Requires `CompatLogger` feature enabled. Defaults to LocalStateDir + "/log/icinga2/compat"
compat\_log\_path | String | **Optional.** Path to Icinga 1.x log files. Required for historical table queries. Requires `CompatLogger` feature enabled. Defaults to LogDir + "/compat"
> **Note**
>
@ -1179,7 +1179,7 @@ Example:
```
object NotificationCommand "mail-service-notification" {
command = [ SysconfDir + "/icinga2/scripts/mail-service-notification.sh" ]
command = [ ConfigDir + "/scripts/mail-service-notification.sh" ]
arguments += {
"-4" = {
@ -1329,10 +1329,10 @@ Configuration Attributes:
Name | Type | Description
--------------------------|-----------------------|----------------------------------
host\_perfdata\_path | String | **Optional.** Path to the host performance data file. Defaults to LocalStateDir + "/spool/icinga2/perfdata/host-perfdata".
service\_perfdata\_path | String | **Optional.** Path to the service performance data file. Defaults to LocalStateDir + "/spool/icinga2/perfdata/service-perfdata".
host\_temp\_path | String | **Optional.** Path to the temporary host file. Defaults to LocalStateDir + "/spool/icinga2/tmp/host-perfdata".
service\_temp\_path | String | **Optional.** Path to the temporary service file. Defaults to LocalStateDir + "/spool/icinga2/tmp/service-perfdata".
host\_perfdata\_path | String | **Optional.** Path to the host performance data file. Defaults to SpoolDir + "/perfdata/host-perfdata".
service\_perfdata\_path | String | **Optional.** Path to the service performance data file. Defaults to SpoolDir + "/perfdata/service-perfdata".
host\_temp\_path | String | **Optional.** Path to the temporary host file. Defaults to SpoolDir + "/tmp/host-perfdata".
service\_temp\_path | String | **Optional.** Path to the temporary service file. Defaults to SpoolDir + "/tmp/service-perfdata".
host\_format\_template | String | **Optional.** Host Format template for the performance data file. Defaults to a template that's suitable for use with PNP4Nagios.
service\_format\_template | String | **Optional.** Service Format template for the performance data file. Defaults to a template that's suitable for use with PNP4Nagios.
rotation\_interval | Duration | **Optional.** Rotation interval for the files specified in `{host,service}_perfdata_path`. Defaults to `30s`.
@ -1534,8 +1534,8 @@ Configuration Attributes:
Name | Type | Description
--------------------------|-----------------------|----------------------------------
status\_path | String | **Optional.** Path to the `status.dat` file. Defaults to LocalStateDir + "/cache/icinga2/status.dat".
objects\_path | String | **Optional.** Path to the `objects.cache` file. Defaults to LocalStateDir + "/cache/icinga2/objects.cache".
status\_path | String | **Optional.** Path to the `status.dat` file. Defaults to CacheDir + "/status.dat".
objects\_path | String | **Optional.** Path to the `objects.cache` file. Defaults to CacheDir + "/objects.cache".
update\_interval | Duration | **Optional.** The interval in which the status files are updated. Defaults to `15s`.

View File

@ -402,7 +402,7 @@ Configuration files are processed in the order they're specified on the command-
When no configuration file is specified and the `--no-config` is not used
Icinga 2 automatically falls back to using the configuration file
`SysconfDir + "/icinga2/icinga2.conf"` (where SysconfDir is usually `/etc`).
`ConfigDir + "/icinga2.conf"` (where ConfigDir is usually `/etc/icinga2`).
### Validation <a id="cli-command-daemon-validation"></a>
@ -730,4 +730,3 @@ safely reload the Icinga 2 daemon.
The `reload` action will send the `SIGHUP` signal to the Icinga 2 daemon
which will validate the configuration in a separate process and not stop
the other events like check execution, notifications, etc.

View File

@ -237,9 +237,9 @@ include <itl>
include <plugins>
```
in the [icinga2.conf](04-configuring-icinga-2.md#icinga2-conf) configuration file. These files are not considered configuration files and will be overridden
on upgrade, so please send modifications as proposed patches upstream. The default include path is set to
`LocalStateDir + "/share/icinga2/includes"`.
in the [icinga2.conf](04-configuring-icinga-2.md#icinga2-conf) configuration file. These files are not considered
configuration files and will be overridden on upgrade, so please send modifications as proposed patches upstream.
The default include path is set to `/usr/share/icinga2/includes` with the constant `IncludeConfDir`.
You should add your own command definitions to a new file in `conf.d/` called `commands.conf`
or similar.

View File

@ -388,31 +388,51 @@ once they are set.
Icinga 2 provides a number of special global constants. Some of them can be overridden using the `--define` command line parameter:
Defaults for paths in `/etc` and `/var` are based on `SysconfDir` and `LocalStateDir` respectively.
Variable |Description
--------------------|-------------------
PrefixDir |**Read-only.** Contains the installation prefix that was specified with cmake -DCMAKE_INSTALL_PREFIX. Defaults to "/usr/local".
SysconfDir |**Read-only.** Contains the path of the sysconf directory. Defaults to PrefixDir + "/etc".
ZonesDir |**Read-only.** Contains the path of the zones.d directory. Defaults to SysconfDir + "/zones.d".
LocalStateDir |**Read-only.** Contains the path of the local state directory. Defaults to PrefixDir + "/var".
RunDir |**Read-only.** Contains the path of the run directory. Defaults to LocalStateDir + "/run".
PkgDataDir |**Read-only.** Contains the path of the package data directory. Defaults to PrefixDir + "/share/icinga2".
StatePath |**Read-write.** Contains the path of the Icinga 2 state file. Defaults to LocalStateDir + "/lib/icinga2/icinga2.state".
ObjectsPath |**Read-write.** Contains the path of the Icinga 2 objects file. Defaults to LocalStateDir + "/cache/icinga2/icinga2.debug".
PidPath |**Read-write.** Contains the path of the Icinga 2 PID file. Defaults to RunDir + "/icinga2/icinga2.pid".
ConfigDir |**Read-only.** Main configuration directory. Usually set to `/etc/icinga2`.
DataDir |**Read-only.** Runtime data for the Icinga daemon. Usually set to `/var/lib/icinga2`.
LogDir |**Read-only.** Logfiles from the daemon. Usually set to `/var/log/icinga2`.
CacheDir |**Read-only.** Cached status information of the daemon. Usually set to `/var/cache/icinga2`.
SpoolDir |**Read-only.** Spool directory for certain data outputs. Usually set to `/var/spool/icinga2`.
InitRunDir |**Read-only.** Directory for PID files and sockets in daemon mode. Usually set to `/run/icinga2`.
ZonesDir |**Read-only.** Contains the path of the zones.d directory. Defaults to `ConfigDir + "/zones.d"`.
Vars |**Read-write.** Contains a dictionary with global custom attributes. Not set by default.
NodeName |**Read-write.** Contains the cluster node name. Set to the local hostname by default.
RunAsUser |**Read-write.** Defines the user the Icinga 2 daemon is running as. Set in the Icinga 2 sysconfig.
RunAsGroup |**Read-write.** Defines the group the Icinga 2 daemon is running as. Set in the Icinga 2 sysconfig.
PlatformName |**Read-only.** The name of the operating system, e.g. "Ubuntu".
PlatformVersion |**Read-only.** The version of the operating system, e.g. "14.04.3 LTS".
PlatformKernel |**Read-only.** The name of the operating system kernel, e.g. "Linux".
PlatformKernelVersion|**Read-only.** The version of the operating system kernel, e.g. "3.13.0-63-generic".
BuildCompilerName |**Read-only.** The name of the compiler Icinga was built with, e.g. "Clang".
BuildCompilerVersion|**Read-only.** The version of the compiler Icinga was built with, e.g. "7.3.0.7030031".
BuildHostName |**Read-only.** The name of the host Icinga was built on, e.g. "acheron".
ApplicationVersion |**Read-only.** The application version, e.g. "2.9.0".
MaxConcurrentChecks |**Read-write**. The number of max checks run simultaneously. Defaults to 512.
Environment |**Read-write**. The name of the Icinga environment. Included in the SNI host name when making outbound connections. Defaults to "production".
PlatformName |**Read-only.** The name of the operating system, e.g. `Ubuntu`.
PlatformVersion |**Read-only.** The version of the operating system, e.g. `14.04.3 LTS`.
PlatformKernel |**Read-only.** The name of the operating system kernel, e.g. `Linux`.
PlatformKernelVersion|**Read-only.** The version of the operating system kernel, e.g. `3.13.0-63-generic`.
BuildCompilerName |**Read-only.** The name of the compiler Icinga was built with, e.g. `Clang`.
BuildCompilerVersion|**Read-only.** The version of the compiler Icinga was built with, e.g. `7.3.0.7030031`.
BuildHostName |**Read-only.** The name of the host Icinga was built on, e.g. `acheron`.
ApplicationVersion |**Read-only.** The application version, e.g. `2.9.0`.
MaxConcurrentChecks |**Read-write**. The number of max checks run simultaneously. Defaults to `512`.
Environment |**Read-write**. The name of the Icinga environment. Included in the SNI host name when making outbound connections. Defaults to `production`.
Certain variables are used to define file paths, you should never need to change them, as they are built based on
constants above.
Variable |Description
--------------------|-------------------
StatePath |**Read-write.** Contains the path of the Icinga 2 state file. Defaults to `DataDir + "/icinga2.state"`.
ObjectsPath |**Read-write.** Contains the path of the Icinga 2 objects file. Defaults to `CacheDir + "/icinga2.debug"`.
PidPath |**Read-write.** Contains the path of the Icinga 2 PID file. Defaults to `InitRunDir + "/icinga2.pid"`.
PkgDataDir |**Read-only.** Contains the path of the package data directory. Defaults to `PrefixDir + "/share/icinga2"`.
Some constants have been used in the past, but are deprecated now. They are stil involved in building Icinga,
see `INSTALL.md`, but please avoid using them for runtime config!
Variable |Description
--------------------|-------------------
PrefixDir |**Read-only.** Contains the installation prefix that was specified with cmake -DCMAKE_INSTALL_PREFIX. `Defaults to "/usr/local"`.
SysconfDir |**Read-only.** Contains the path of the sysconf directory. Defaults to `PrefixDir + "/etc"`.
LocalStateDir |**Read-only.** Contains the path of the local state directory. Defaults to `PrefixDir + "/var"`.
RunDir |**Read-only.** Contains the path of the run directory. Defaults to `LocalStateDir + "/run"`.
Advanced runtime constants. Please only use them if advised by support or developers.
@ -733,12 +753,12 @@ You can explicitly access the `this` scope using the `this` keyword:
object Host "localhost" {
var check_interval = 5m
/* This explicitly specifies that the attribute should be set
* for the host, if we had omitted `this.` the (poorly named)
* local variable `check_interval` would have been modified instead.
*/
this.check_interval = 1m
this.check_interval = 1m
}
Similarly the keywords `locals` and `globals` are available to access the local and global scope.
@ -748,7 +768,7 @@ a function is set to whichever object was used to invoke the function. Here's an
hm = {
h_word = null
function init(word) {
h_word = word
}
@ -1024,4 +1044,3 @@ You can escape the `include` keyword by prefixing it with an additional `@` char
vars.@include = "some cmdb export field"
}

View File

@ -69,9 +69,9 @@ Config files are processed in the order they are specified on the command-line.
When no configuration file is specified and the
.B --no-config
is not used, Icinga 2 automatically falls back to using the configuration file
.B SysconfDir + "/icinga2/icinga2.conf"
(where SysconfDir is usually
.BI "/etc" ")."
.B ConfigDir + "/icinga2.conf"
(where ConfigDir is usually
.BI "/etc/icinga2" ")."
.TP
.B "-z, --noconfig"

View File

@ -24,55 +24,52 @@ if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
endif()
if(NOT WIN32)
install_if_not_exists(${CMAKE_CURRENT_BINARY_DIR}/icinga2/constants.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
install_if_not_exists(icinga2/icinga2.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
install_if_not_exists(${CMAKE_CURRENT_BINARY_DIR}/icinga2/constants.conf ${ICINGA2_CONFIGDIR})
install_if_not_exists(icinga2/icinga2.conf ${ICINGA2_CONFIGDIR})
else()
install_if_not_exists(${CMAKE_CURRENT_SOURCE_DIR}/icinga2/win32/constants.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
install_if_not_exists(icinga2/win32/icinga2.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
install_if_not_exists(${CMAKE_CURRENT_SOURCE_DIR}/icinga2/win32/constants.conf ${ICINGA2_CONFIGDIR})
install_if_not_exists(icinga2/win32/icinga2.conf ${ICINGA2_CONFIGDIR})
endif()
install_if_not_exists(icinga2/zones.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
install_if_not_exists(icinga2/conf.d/app.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/commands.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/downtimes.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/groups.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/zones.conf ${ICINGA2_CONFIGDIR})
install_if_not_exists(icinga2/conf.d/app.conf ${ICINGA2_CONFIGDIR}/conf.d)
install_if_not_exists(icinga2/conf.d/commands.conf ${ICINGA2_CONFIGDIR}/conf.d)
install_if_not_exists(icinga2/conf.d/downtimes.conf ${ICINGA2_CONFIGDIR}/conf.d)
install_if_not_exists(icinga2/conf.d/groups.conf ${ICINGA2_CONFIGDIR}/conf.d)
if(NOT WIN32)
install_if_not_exists(icinga2/conf.d/hosts.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/services.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/hosts.conf ${ICINGA2_CONFIGDIR}/conf.d)
install_if_not_exists(icinga2/conf.d/services.conf ${ICINGA2_CONFIGDIR}/conf.d)
else()
install_if_not_exists(icinga2/conf.d/win32/hosts.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/win32/services.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/win32/hosts.conf ${ICINGA2_CONFIGDIR}/conf.d)
install_if_not_exists(icinga2/conf.d/win32/services.conf ${ICINGA2_CONFIGDIR}/conf.d)
endif()
install_if_not_exists(icinga2/conf.d/notifications.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/templates.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/timeperiods.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/users.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/features-available/api.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/debuglog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/mainlog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/conf.d/notifications.conf ${ICINGA2_CONFIGDIR}/conf.d)
install_if_not_exists(icinga2/conf.d/templates.conf ${ICINGA2_CONFIGDIR}/conf.d)
install_if_not_exists(icinga2/conf.d/timeperiods.conf ${ICINGA2_CONFIGDIR}/conf.d)
install_if_not_exists(icinga2/conf.d/users.conf ${ICINGA2_CONFIGDIR}/conf.d)
install_if_not_exists(icinga2/features-available/api.conf ${ICINGA2_CONFIGDIR}/features-available)
install_if_not_exists(icinga2/features-available/debuglog.conf ${ICINGA2_CONFIGDIR}/features-available)
install_if_not_exists(icinga2/features-available/mainlog.conf ${ICINGA2_CONFIGDIR}/features-available)
if(NOT WIN32)
install_if_not_exists(icinga2/features-available/syslog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/syslog.conf ${ICINGA2_CONFIGDIR}/features-available)
endif()
install_if_not_exists(icinga2/scripts/mail-host-notification.sh ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/scripts)
install_if_not_exists(icinga2/scripts/mail-service-notification.sh ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/scripts)
install_if_not_exists(icinga2/zones.d/README ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/zones.d)
install_if_not_exists(icinga2/scripts/mail-host-notification.sh ${ICINGA2_CONFIGDIR}/scripts)
install_if_not_exists(icinga2/scripts/mail-service-notification.sh ${ICINGA2_CONFIGDIR}/scripts)
install_if_not_exists(icinga2/zones.d/README ${ICINGA2_CONFIGDIR}/zones.d)
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
install_if_not_exists(${CMAKE_CURRENT_BINARY_DIR}/logrotate.d/icinga2 ${CMAKE_INSTALL_SYSCONFDIR}/logrotate.d)
install_if_not_exists(${CMAKE_CURRENT_BINARY_DIR}/logrotate.d/icinga2 ${LOGROTATE_DIR})
endif()
if(NOT WIN32)
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled\")")
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/mainlog.conf \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled/mainlog.conf\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_CONFIGDIR}/features-enabled\")")
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/mainlog.conf \"\$ENV{DESTDIR}${ICINGA2_FULL_CONFIGDIR}/features-enabled/mainlog.conf\")")
install(
FILES bash_completion.d/icinga2
DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/bash_completion.d
)
install(FILES bash_completion.d/icinga2 DESTINATION ${BASHCOMPLETION_DIR})
else()
install_if_not_exists(icinga2/features-enabled/mainlog.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-enabled)
install_if_not_exists(icinga2/features-enabled/mainlog.conf ${ICINGA2_CONFIGDIR}/features-enabled)
endif()
if(${CMAKE_SYSTEM_NAME} MATCHES "(Linux|Solaris|SunOS)")

View File

@ -7,7 +7,7 @@
*/
object NotificationCommand "mail-host-notification" {
command = [ SysconfDir + "/icinga2/scripts/mail-host-notification.sh" ]
command = [ ConfigDir + "/scripts/mail-host-notification.sh" ]
arguments += {
"-4" = "$notification_address$"
@ -66,7 +66,7 @@ object NotificationCommand "mail-host-notification" {
}
object NotificationCommand "mail-service-notification" {
command = [ SysconfDir + "/icinga2/scripts/mail-service-notification.sh" ]
command = [ ConfigDir + "/scripts/mail-service-notification.sh" ]
arguments += {
"-4" = "$notification_address$"
@ -146,7 +146,7 @@ object NotificationCommand "mail-service-notification" {
/*
object NotificationCommand "mail-host-notification" {
command = [ SysconfDir + "/icinga2/scripts/mail-host-notification.sh" ]
command = [ ConfigDir + "/scripts/mail-host-notification.sh" ]
env = {
NOTIFICATIONTYPE = "$notification.type$"
@ -164,7 +164,7 @@ object NotificationCommand "mail-host-notification" {
}
object NotificationCommand "mail-service-notification" {
command = [ SysconfDir + "/icinga2/scripts/mail-service-notification.sh" ]
command = [ ConfigDir + "/scripts/mail-service-notification.sh" ]
env = {
NOTIFICATIONTYPE = "$notification.type$"

View File

@ -6,6 +6,5 @@
object FileLogger "debug-file" {
severity = "debug"
path = LocalStateDir + "/log/icinga2/debug.log"
path = LogDir + "/debug.log"
}

View File

@ -4,6 +4,5 @@
object FileLogger "main-log" {
severity = "information"
path = LocalStateDir + "/log/icinga2/icinga2.log"
path = LogDir + "/icinga2.log"
}

View File

@ -36,10 +36,10 @@ fi
: ${ICINGA2_GROUP:="@ICINGA2_GROUP@"}
: ${ICINGA2_COMMAND_GROUP:="@ICINGA2_COMMAND_GROUP@"}
: ${DAEMON:="@CMAKE_INSTALL_FULL_SBINDIR@/icinga2"}
: ${ICINGA2_CONFIG_FILE:="@CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/icinga2.conf"}
: ${ICINGA2_ERROR_LOG:=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/error.log}
: ${ICINGA2_STARTUP_LOG:=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/startup.log}
: ${ICINGA2_PID_FILE:="@ICINGA2_RUNDIR@/icinga2/icinga2.pid"}
: ${ICINGA2_CONFIG_FILE:="@ICINGA2_CONFIGDIR@/icinga2.conf"}
: ${ICINGA2_ERROR_LOG:=@ICINGA2_LOGDIR@/error.log}
: ${ICINGA2_STARTUP_LOG:=@ICINGA2_LOGDIR@/startup.log}
: ${ICINGA2_PID_FILE:="@ICINGA2_INITRUNDIR@/icinga2.pid"}
# Load extra environment variables
if [ -f /etc/default/icinga2 ]; then
@ -90,7 +90,7 @@ stop() {
if ! icinga2 internal signal -s SIGCHLD -p $pid >/dev/null 2>&1; then
break
fi
printf '.'
sleep 3
done

View File

@ -7,7 +7,7 @@ Type=notify
EnvironmentFile=@ICINGA2_SYSCONFIGFILE@
ExecStartPre=@CMAKE_INSTALL_PREFIX@/lib/icinga2/prepare-dirs @ICINGA2_SYSCONFIGFILE@
ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2 daemon -e ${ICINGA2_ERROR_LOG}
PIDFile=@ICINGA2_RUNDIR@/icinga2/icinga2.pid
PIDFile=@ICINGA2_INITRUNDIR@/icinga2.pid
ExecReload=@CMAKE_INSTALL_PREFIX@/lib/icinga2/safe-reload @ICINGA2_SYSCONFIGFILE@
TimeoutStartSec=30m

View File

@ -2,15 +2,14 @@
#Make your changes here.
#DAEMON=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2
#ICINGA2_CONFIG_FILE=@CMAKE_INSTALL_FULL_SYSCONFDIR@/icinga2/icinga2.conf
#ICINGA2_RUN_DIR=@ICINGA2_RUNDIR@
#ICINGA2_STATE_DIR=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@
#ICINGA2_PID_FILE=@ICINGA2_RUNDIR@/icinga2/icinga2.pid
#ICINGA2_LOG_DIR=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2
#ICINGA2_ERROR_LOG=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/error.log
#ICINGA2_STARTUP_LOG=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/startup.log
#ICINGA2_LOG=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/icinga2.log
#ICINGA2_CACHE_DIR=@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/cache/icinga2
#ICINGA2_CONFIG_FILE=@ICINGA2_CONFIGDIR@/icinga2.conf
#ICINGA2_INIT_RUN_DIR=@ICINGA2_INITRUNDIR@
#ICINGA2_PID_FILE=@ICINGA2_INITRUNDIR@/icinga2.pid
#ICINGA2_LOG_DIR=@ICINGA2_LOGDIR@
#ICINGA2_ERROR_LOG=@ICINGA2_LOGDIR@/error.log
#ICINGA2_STARTUP_LOG=@ICINGA2_LOGDIR@/startup.log
#ICINGA2_LOG=@ICINGA2_LOGDIR@/icinga2.log
#ICINGA2_CACHE_DIR=@ICINGA2_CACHEDIR@
#ICINGA2_USER=@ICINGA2_USER@
#ICINGA2_GROUP=@ICINGA2_GROUP@
#ICINGA2_COMMAND_GROUP=@ICINGA2_COMMAND_GROUP@

View File

@ -17,28 +17,27 @@ fi
: ${ICINGA2_USER:="@ICINGA2_USER@"}
: ${ICINGA2_GROUP:="@ICINGA2_GROUP@"}
: ${ICINGA2_COMMAND_GROUP:="@ICINGA2_COMMAND_GROUP@"}
: ${ICINGA2_RUN_DIR:="@ICINGA2_RUNDIR@"}
: ${ICINGA2_LOG_DIR:="@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2"}
: ${ICINGA2_STATE_DIR:="@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/cache/icinga2"}
: ${ICINGA2_CACHE_DIR:="@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/cache/icinga2"}
: ${ICINGA2_INIT_RUN_DIR:="@ICINGA2_INITRUNDIR@"}
: ${ICINGA2_LOG_DIR:="@ICINGA2_LOGDIR@"}
: ${ICINGA2_CACHE_DIR:="@ICINGA2_CACHEDIR@"}
getent passwd $ICINGA2_USER >/dev/null 2>&1 || (echo "Icinga user '$ICINGA2_USER' does not exist. Exiting." && exit 6)
getent group $ICINGA2_GROUP >/dev/null 2>&1 || (echo "Icinga group '$ICINGA2_GROUP' does not exist. Exiting." && exit 6)
getent group $ICINGA2_COMMAND_GROUP >/dev/null 2>&1 || (echo "Icinga command group '$ICINGA2_COMMAND_GROUP' does not exist. Exiting." && exit 6)
if [ ! -e "$ICINGA2_RUN_DIR"/icinga2 ]; then
mkdir "$ICINGA2_RUN_DIR"/icinga2
mkdir "$ICINGA2_RUN_DIR"/icinga2/cmd
if [ ! -e "$ICINGA2_INIT_RUN_DIR" ]; then
mkdir "$ICINGA2_INIT_RUN_DIR"
mkdir "$ICINGA2_INIT_RUN_DIR"/cmd
fi
chmod 755 "$ICINGA2_RUN_DIR"/icinga2
chmod 2750 "$ICINGA2_RUN_DIR"/icinga2/cmd
chown -R $ICINGA2_USER:$ICINGA2_COMMAND_GROUP "$ICINGA2_RUN_DIR"/icinga2
chmod 755 "$ICINGA2_INIT_RUN_DIR"
chmod 2750 "$ICINGA2_INIT_RUN_DIR"/cmd
chown -R $ICINGA2_USER:$ICINGA2_COMMAND_GROUP "$ICINGA2_INIT_RUN_DIR"
test -e "$ICINGA2_LOG_DIR" || install -m 750 -o $ICINGA2_USER -g $ICINGA2_COMMAND_GROUP -d "$ICINGA2_LOG_DIR"
if type restorecon >/dev/null 2>&1; then
restorecon -R "$ICINGA2_RUN_DIR"/icinga2/
restorecon -R "$ICINGA2_INIT_RUN_DIR"/
fi
test -e "$ICINGA2_CACHE_DIR" || install -m 750 -o $ICINGA2_USER -g $ICINGA2_COMMAND_GROUP -d "$ICINGA2_CACHE_DIR"

View File

@ -11,7 +11,7 @@ fi
# Set defaults, to overwrite see "@ICINGA2_SYSCONFIGFILE@"
: ${ICINGA2_PID_FILE:="@ICINGA2_RUNDIR@/icinga2/icinga2.pid"}
: ${ICINGA2_PID_FILE:="@ICINGA2_INITRUNDIR@/icinga2.pid"}
: ${DAEMON:="@CMAKE_INSTALL_FULL_SBINDIR@/icinga2"}
printf "Validating config files: "

View File

@ -1,4 +1,4 @@
@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/icinga2.log @CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/debug.log {
@ICINGA2_LOGDIR@/icinga2.log @ICINGA2_LOGDIR@/debug.log {
daily
rotate 7@LOGROTATE_USE_SU@
compress
@ -7,11 +7,11 @@
notifempty
create 644 @ICINGA2_USER@ @ICINGA2_GROUP@
postrotate
/bin/kill -USR1 $(cat @ICINGA2_RUNDIR@/icinga2/icinga2.pid 2> /dev/null) 2> /dev/null || true
/bin/kill -USR1 $(cat @ICINGA2_INITRUNDIR@/icinga2.pid 2> /dev/null) 2> /dev/null || true
endscript
}
@CMAKE_INSTALL_FULL_LOCALSTATEDIR@/log/icinga2/error.log {
@ICINGA2_LOGDIR@/error.log {
daily
rotate 90@LOGROTATE_USE_SU@
compress
@ -21,4 +21,3 @@
create 644 @ICINGA2_USER@ @ICINGA2_GROUP@
# TODO: figure out how to get Icinga to re-open this log file
}

View File

@ -107,6 +107,6 @@ install(
RUNTIME DESTINATION ${InstallPath}
)
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/icinga2\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/icinga2\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_RUNDIR}/icinga2\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_LOGDIR}\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_DATADIR}\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_INITRUNDIR}\")")

View File

@ -94,6 +94,68 @@ static std::vector<String> GlobalArgumentCompletion(const String& argument, cons
return std::vector<String>();
}
static void HandleLegacyDefines()
{
#ifdef _WIN32
String dataPrefix = Utility::GetIcingaDataPath();
#endif /* _WIN32 */
Value localStateDir = Application::GetConst("LocalStateDir");
if (!localStateDir.IsEmpty()) {
Log(LogWarning, "icinga-app")
<< "Please do not set LocalStateDir anymore, set DataDir, LogDir, CacheDir and SpoolDir!"
<< " Resetting those vars based on LocalStateDir!";
#ifdef _WIN32
ScriptGlobal::Set("DataDir", localStateDir + "\\lib\\icinga2");
ScriptGlobal::Set("LogDir", localStateDir + "\\log\\icinga2");
ScriptGlobal::Set("CacheDir", localStateDir + "\\cache\\icinga2");
ScriptGlobal::Set("SpoolDir", localStateDir + "\\spool\\icinga2");
} else {
ScriptGlobal::Set("LocalStateDir", dataPrefix + "\\var");
#else /* _WIN32 */
ScriptGlobal::Set("DataDir", localStateDir + "/lib/icinga2");
ScriptGlobal::Set("LogDir", localStateDir + "/log/icinga2");
ScriptGlobal::Set("CacheDir", localStateDir + "/cache/icinga2");
ScriptGlobal::Set("SpoolDir", localStateDir + "/spool/icinga2");
} else {
ScriptGlobal::Set("LocalStateDir", ICINGA_LOCALSTATEDIR);
#endif /* _WIN32 */
}
Value sysconfDir = Application::GetConst("SysconfDir");
if (!sysconfDir.IsEmpty()) {
Log(LogWarning, "icinga-app")
<< "Please do not set Sysconfdir anymore, set ConfigDir! Resetting the var based on SysconfDir!";
#ifdef _WIN32
ScriptGlobal::Set("ConfigDir", sysconfDir + "\\icinga2");
} else {
ScriptGlobal::Set("SysconfDir", dataPrefix + "\\etc");
#else /* _WIN32 */
ScriptGlobal::Set("ConfigDir", sysconfDir + "/icinga2");
} else {
ScriptGlobal::Set("SysconfDir", ICINGA_SYSCONFDIR);
#endif /* _WIN32 */
}
Value runDir = Application::GetConst("RunDir");
if (!runDir.IsEmpty()) {
Log(LogWarning, "icinga-app")
<< "Please do not set RunDir anymore, set InitRunDir! Resetting the var based on RunDir!";
#ifdef _WIN32
ScriptGlobal::Set("InitRunDir", runDir + "\\icinga2");
} else {
ScriptGlobal::Set("RunDir", dataPrefix + "\\var\\run");
#else /* _WIN32 */
ScriptGlobal::Set("InitRunDir", runDir + "/icinga2");
} else {
ScriptGlobal::Set("RunDir", ICINGA_RUNDIR);
#endif /* _WIN32 */
}
}
static int Main()
{
int argc = Application::GetArgC();
@ -128,31 +190,53 @@ static int Main()
#ifdef _WIN32
bool builtinPaths = true;
// Programm install location, C:/Program Files/Icinga2
String binaryPrefix = Utility::GetIcingaInstallPath();
// Returns the datapath for daemons, %PROGRAMDATA%/icinga2
String dataPrefix = Utility::GetIcingaDataPath();
if (!binaryPrefix.IsEmpty() && !dataPrefix.IsEmpty()) {
Application::DeclarePrefixDir(binaryPrefix);
Application::DeclareSysconfDir(dataPrefix + "\\etc");
Application::DeclareRunDir(dataPrefix + "\\var\\run");
Application::DeclareLocalStateDir(dataPrefix + "\\var");
Application::DeclarePkgDataDir(binaryPrefix + "\\share\\icinga2");
Application::DeclareIncludeConfDir(binaryPrefix + "\\share\\icinga2\\include");
Application::DeclareConst("PrefixDir", binaryPrefix);
Application::DeclareConst("ProgramData", dataPrefix);
Application::DeclareConst("ConfigDir", dataPrefix + "\\etc\\icinga2");
Application::DeclareConst("DataDir", dataPrefix + "\\var\\lib\\icinga2");
Application::DeclareConst("LogDir", dataPrefix + "\\var\\log\\icinga2");
Application::DeclareConst("CacheDir", dataPrefix + "\\var\\cache\\icinga2");
Application::DeclareConst("SpoolDir", dataPrefix + "\\var\\spool\\icinga2");
// also see call to HandleLegacyDefines() later
// internal constants
Application::DeclareConst("PkgDataDir", binaryPrefix + "\\share\\icinga2");
Application::DeclareConst("IncludeConfDir", binaryPrefix + "\\share\\icinga2\\include");
} else {
Log(LogWarning, "icinga-app", "Registry key could not be read. Falling back to built-in paths.");
#endif /* _WIN32 */
Application::DeclarePrefixDir(ICINGA_PREFIX);
Application::DeclareSysconfDir(ICINGA_SYSCONFDIR);
Application::DeclareRunDir(ICINGA_RUNDIR);
Application::DeclareLocalStateDir(ICINGA_LOCALSTATEDIR);
Application::DeclarePkgDataDir(ICINGA_PKGDATADIR);
Application::DeclareIncludeConfDir(ICINGA_INCLUDECONFDIR);
Application::DeclareConst("ConfigDir", ICINGA_CONFIGDIR);
Application::DeclareConst("DataDir", ICINGA_DATADIR);
Application::DeclareConst("LogDir", ICINGA_LOGDIR);
Application::DeclareConst("CacheDir", ICINGA_CACHEDIR);
Application::DeclareConst("SpoolDir", ICINGA_SPOOLDIR);
Application::DeclareConst("PrefixDir", ICINGA_PREFIX);
// also see call to HandleLegacyDefines() later
// internal constants
Application::DeclareConst("PkgDataDir", ICINGA_PKGDATADIR);
Application::DeclareConst("IncludeConfDir", ICINGA_INCLUDECONFDIR);
Application::DeclareConst("InitRunDir", ICINGA_INITRUNDIR);
#ifdef _WIN32
}
#endif /* _WIN32 */
Application::DeclareZonesDir(Application::GetSysconfDir() + "/icinga2/zones.d");
Application::DeclareConst("ZonesDir", Application::GetConst("ConfigDir") + "/zones.d");
String icingaUser = Utility::GetFromEnvironment("ICINGA2_USER");
if (icingaUser.IsEmpty())
@ -162,17 +246,17 @@ static int Main()
if (icingaGroup.IsEmpty())
icingaGroup = ICINGA_GROUP;
Application::DeclareRunAsUser(icingaUser);
Application::DeclareRunAsGroup(icingaGroup);
Application::DeclareConst("RunAsUser", icingaUser);
Application::DeclareConst("RunAsGroup", icingaGroup);
if (!autocomplete) {
#ifdef RLIMIT_NOFILE
String rLimitFiles = Utility::GetFromEnvironment("ICINGA2_RLIMIT_FILES");
if (rLimitFiles.IsEmpty())
Application::DeclareRLimitFiles(Application::GetDefaultRLimitFiles());
Application::DeclareConst("RLimitFiles", Application::GetDefaultRLimitFiles());
else {
try {
Application::DeclareRLimitFiles(Convert::ToLong(rLimitFiles));
Application::DeclareConst("RLimitFiles", Convert::ToLong(rLimitFiles));
} catch (const std::invalid_argument& ex) {
std::cout
<< "Error setting \"ICINGA2_RLIMIT_FILES\": " << ex.what() << '\n';
@ -184,10 +268,10 @@ static int Main()
#ifdef RLIMIT_NPROC
String rLimitProcesses = Utility::GetFromEnvironment("ICINGA2_RLIMIT_PROCESSES");
if (rLimitProcesses.IsEmpty())
Application::DeclareRLimitProcesses(Application::GetDefaultRLimitProcesses());
Application::DeclareConst("RLimitProcesses", Application::GetDefaultRLimitProcesses());
else {
try {
Application::DeclareRLimitProcesses(Convert::ToLong(rLimitProcesses));
Application::DeclareConst("RLimitProcesses", Convert::ToLong(rLimitProcesses));
} catch (const std::invalid_argument& ex) {
std::cout
<< "Error setting \"ICINGA2_RLIMIT_PROCESSES\": " << ex.what() << '\n';
@ -199,10 +283,10 @@ static int Main()
#ifdef RLIMIT_STACK
String rLimitStack = Utility::GetFromEnvironment("ICINGA2_RLIMIT_STACK");
if (rLimitStack.IsEmpty())
Application::DeclareRLimitStack(Application::GetDefaultRLimitStack());
Application::DeclareConst("RLimitStack", Application::GetDefaultRLimitStack());
else {
try {
Application::DeclareRLimitStack(Convert::ToLong(rLimitStack));
Application::DeclareConst("RLimitStack", Convert::ToLong(rLimitStack));
} catch (const std::invalid_argument& ex) {
std::cout
<< "Error setting \"ICINGA2_RLIMIT_STACK\": " << ex.what() << '\n';
@ -212,8 +296,8 @@ static int Main()
#endif /* RLIMIT_STACK */
}
Application::DeclareConcurrency(std::thread::hardware_concurrency());
Application::DeclareMaxConcurrentChecks(Application::GetDefaultMaxConcurrentChecks());
Application::DeclareConst("Concurrency", std::thread::hardware_concurrency());
Application::DeclareConst("MaxConcurrentChecks", Application::GetDefaultMaxConcurrentChecks());
ScriptGlobal::Set("Environment", "production");
@ -277,7 +361,8 @@ static int Main()
GetUserName(username, &usernameLen);
std::ifstream userFile;
userFile.open(Application::GetSysconfDir() + "/icinga2/user");
String configDir = Application::GetConst("ConfigDir");
userFile.open(configDir + "/user");
if (userFile && command && !Application::IsProcessElevated()) {
std::string userLine;
@ -361,16 +446,18 @@ static int Main()
}
}
HandleLegacyDefines();
if (vm.count("script-debugger"))
Application::SetScriptDebuggerEnabled(true);
Application::DeclareStatePath(Application::GetLocalStateDir() + "/lib/icinga2/icinga2.state");
Application::DeclareModAttrPath(Application::GetLocalStateDir() + "/lib/icinga2/modified-attributes.conf");
Application::DeclareObjectsPath(Application::GetLocalStateDir() + "/cache/icinga2/icinga2.debug");
Application::DeclareVarsPath(Application::GetLocalStateDir() + "/cache/icinga2/icinga2.vars");
Application::DeclarePidPath(Application::GetRunDir() + "/icinga2/icinga2.pid");
Application::DeclareConst("StatePath", Application::GetConst("DataDir") + "/icinga2.state");
Application::DeclareConst("ModAttrPath", Application::GetConst("DataDir") + "/modified-attributes.conf");
Application::DeclareConst("ObjectsPath", Application::GetConst("CacheDir") + "/icinga2.debug");
Application::DeclareConst("VarsPath", Application::GetConst("CacheDir") + "/icinga2.vars");
Application::DeclareConst("PidPath", Application::GetConst("InitRunDir") + "/icinga2.pid");
ConfigCompiler::AddIncludeSearchDir(Application::GetIncludeConfDir());
ConfigCompiler::AddIncludeSearchDir(Application::GetConst("IncludeConfDir"));
if (!autocomplete && vm.count("include")) {
for (const String& includePath : vm["include"].as<std::vector<std::string> >()) {
@ -480,8 +567,8 @@ static int Main()
return 0;
}
} else if (command && command->GetImpersonationLevel() == ImpersonateIcinga) {
String group = Application::GetRunAsGroup();
String user = Application::GetRunAsUser();
String group = Application::GetConst("RunAsGroup");
String user = Application::GetConst("RunAsUser");
errno = 0;
struct group *gr = getgrnam(group.CStr());

View File

@ -19,5 +19,5 @@ add_subdirectory(plugins-contrib.d)
install(
FILES itl command-icinga.conf hangman plugins command-plugins.conf manubulon command-plugins-manubulon.conf windows-plugins command-plugins-windows.conf nscp command-nscp-local.conf plugins-contrib
DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2/include
DESTINATION ${ICINGA2_INCLUDEDIR}
)

View File

@ -17,5 +17,5 @@
install(
FILES databases.conf hardware.conf icingacli.conf ipmi.conf logmanagement.conf metrics.conf network-components.conf network-services.conf operating-system.conf raid-controller.conf smart-attributes.conf storage.conf virtualization.conf vmware.conf web.conf
DESTINATION ${CMAKE_INSTALL_DATADIR}/icinga2/include/plugins-contrib.d
DESTINATION ${ICINGA2_INCLUDEDIR}/plugins-contrib.d
)

View File

@ -519,7 +519,7 @@ object CheckCommand "oracle_health" {
vars.oracle_home = "/usr/lib/oracle/11.2/client64/lib"
vars.oracle_ld_library_path = "/usr/lib/oracle/11.2/client64/lib"
vars.oracle_tns_admin = SysconfDir + "/icinga2/plugin-configs"
vars.oracle_tns_admin = ConfigDir + "/plugin-configs"
}
object CheckCommand "postgres" {

View File

@ -20,5 +20,5 @@ object CheckCommand "smart-attributes" {
}
}
vars.smart_attributes_config_path = SysconfDir + "/icinga2/plugins-config/check_smartdb.json"
vars.smart_attributes_config_path = ConfigDir + "/plugins-config/check_smartdb.json"
}

View File

@ -122,7 +122,7 @@ set_target_properties (
FOLDER Lib
)
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/cache/icinga2\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/icinga2/crash\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_CACHEDIR}\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_LOGDIR}/crash\")")
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}" PARENT_SCOPE)

View File

@ -168,7 +168,7 @@ void Application::SetResourceLimits()
rlimit rl;
# ifdef RLIMIT_NOFILE
rlim_t fileLimit = GetRLimitFiles();
rlim_t fileLimit = GetConst("RLimitFiles");
if (fileLimit != 0) {
if (fileLimit < GetDefaultRLimitFiles()) {
@ -189,7 +189,7 @@ void Application::SetResourceLimits()
}
# ifdef RLIMIT_NPROC
rlim_t processLimit = GetRLimitProcesses();
rlim_t processLimit = GetConst("RLimitProcesses");
if (processLimit != 0) {
if (processLimit < GetDefaultRLimitProcesses()) {
@ -228,7 +228,7 @@ void Application::SetResourceLimits()
rlim_t stackLimit;
stackLimit = GetRLimitStack();
stackLimit = GetConst("RLimitStack");
if (stackLimit != 0) {
if (stackLimit < GetDefaultRLimitStack()) {
@ -543,16 +543,28 @@ void Application::DisplayInfoMessage(std::ostream& os, bool skipVersion)
if (!skipVersion)
os << " Application version: " << GetAppVersion() << "\n";
os << " Installation root: " << GetPrefixDir() << "\n"
<< " Sysconf directory: " << GetSysconfDir() << "\n"
<< " Run directory: " << GetRunDir() << "\n"
<< " Local state directory: " << GetLocalStateDir() << "\n"
<< " Package data directory: " << GetPkgDataDir() << "\n"
<< " State path: " << GetStatePath() << "\n"
<< " Modified attributes path: " << GetModAttrPath() << "\n"
<< " Objects path: " << GetObjectsPath() << "\n"
<< " Vars path: " << GetVarsPath() << "\n"
<< " PID path: " << GetPidPath() << "\n";
os
<< "\n"
<< " Config directory: " << GetConst("ConfigDir") << "\n"
<< " Data directory: " << GetConst("DataDir") << "\n"
<< " Log directory: " << GetConst("LogDir") << "\n"
<< " Cache directory: " << GetConst("CacheDir") << "\n"
<< " Spool directory: " << GetConst("SpoolDir") << "\n"
<< " Run directory: " << GetConst("InitRunDir") << "\n"
<< "\n"
<< "Older paths (deprecated):" << "\n"
<< " Installation root: " << GetConst("PrefixDir") << "\n"
<< " Sysconf directory: " << GetConst("SysconfDir") << "\n"
<< " Run directory (base): " << GetConst("RunDir") << "\n"
<< " Local state directory: " << GetConst("LocalStateDir") << "\n"
<< "\n"
<< "Internally used paths:" << "\n"
<< " Package data directory: " << GetConst("PkgDataDir") << "\n"
<< " State path: " << GetConst("StatePath") << "\n"
<< " Modified attributes path: " << GetConst("ModAttrPath") << "\n"
<< " Objects path: " << GetConst("ObjectsPath") << "\n"
<< " Vars path: " << GetConst("VarsPath") << "\n"
<< " PID path: " << GetConst("PidPath") << "\n";
os << "\n"
<< "System information:" << "\n"
@ -582,7 +594,7 @@ void Application::DisplayBugMessage(std::ostream& os)
String Application::GetCrashReportFilename()
{
return GetLocalStateDir() + "/log/icinga2/crash/report." + Convert::ToString(Utility::GetTime());
return GetConst("LogDir") + "/crash/report." + Convert::ToString(Utility::GetTime());
}
@ -732,7 +744,7 @@ void Application::SigUsr2Handler(int)
*/
Application::Ptr instance = GetInstance();
try {
instance->UpdatePidFile(GetPidPath(), m_ReloadProcess);
instance->UpdatePidFile(GetConst("PidPath"), m_ReloadProcess);
} catch (const std::exception&) {
/* abort restart */
Log(LogCritical, "Application", "Cannot update PID file. Aborting restart operation.");
@ -1004,10 +1016,10 @@ int Application::Run()
#endif /* _WIN32 */
try {
UpdatePidFile(GetPidPath());
UpdatePidFile(GetConst("PidPath"));
} catch (const std::exception&) {
Log(LogCritical, "Application")
<< "Cannot update PID file '" << GetPidPath() << "'. Aborting.";
<< "Cannot update PID file '" << GetConst("PidPath") << "'. Aborting.";
return EXIT_FAILURE;
}
@ -1089,7 +1101,7 @@ void Application::ClosePidFile(bool unlink)
if (m_PidFile) {
if (unlink) {
String pidpath = GetPidPath();
String pidpath = GetConst("PidPath");
::unlink(pidpath.CStr());
}
@ -1157,310 +1169,37 @@ pid_t Application::ReadPidFile(const String& filename)
return runningpid;
}
/**
* Retrieves the path of the installation prefix.
* Declares a const with ScriptGlobal
*
* @returns The path.
* @param name The const name.
* @param value The new value.
*/
String Application::GetPrefixDir()
void Application::DeclareConst(const String& name, const Value& value)
{
return ScriptGlobal::Get("PrefixDir");
if (!ScriptGlobal::Exists(name))
ScriptGlobal::Set(name, value);
}
/**
* Sets the path for the installation prefix.
* Returns the value of a const from ScriptGlobal
*
* @param path The new path.
* @param name The const name.
*/
void Application::DeclarePrefixDir(const String& path)
Value Application::GetConst(const String& name)
{
if (!ScriptGlobal::Exists("PrefixDir"))
ScriptGlobal::Set("PrefixDir", path);
return GetConst(name, Empty);
}
/**
* Retrives the path of the sysconf dir.
* Returns the value of a const from ScriptGlobal with default value
*
* @returns The path.
* @param name The const name.
* @param def The default value.
*/
String Application::GetSysconfDir()
Value Application::GetConst(const String& name, Value defaultValue)
{
return ScriptGlobal::Get("SysconfDir");
}
/**
* Sets the path of the sysconf dir.
*
* @param path The new path.
*/
void Application::DeclareSysconfDir(const String& path)
{
if (!ScriptGlobal::Exists("SysconfDir"))
ScriptGlobal::Set("SysconfDir", path);
}
/**
* Retrieves the path for the run dir.
*
* @returns The path.
*/
String Application::GetRunDir()
{
return ScriptGlobal::Get("RunDir");
}
/**
* Sets the path of the run dir.
*
* @param path The new path.
*/
void Application::DeclareRunDir(const String& path)
{
if (!ScriptGlobal::Exists("RunDir"))
ScriptGlobal::Set("RunDir", path);
}
/**
* Retrieves the path for the local state dir.
*
* @returns The path.
*/
String Application::GetLocalStateDir()
{
return ScriptGlobal::Get("LocalStateDir");
}
/**
* Sets the path for the local state dir.
*
* @param path The new path.
*/
void Application::DeclareLocalStateDir(const String& path)
{
if (!ScriptGlobal::Exists("LocalStateDir"))
ScriptGlobal::Set("LocalStateDir", path);
}
/**
* Retrieves the path for the local state dir.
*
* @returns The path.
*/
String Application::GetZonesDir()
{
return ScriptGlobal::Get("ZonesDir", &Empty);
}
/**
* Sets the path of the zones dir.
*
* @param path The new path.
*/
void Application::DeclareZonesDir(const String& path)
{
if (!ScriptGlobal::Exists("ZonesDir"))
ScriptGlobal::Set("ZonesDir", path);
}
/**
* Retrieves the path for the package data dir.
*
* @returns The path.
*/
String Application::GetPkgDataDir()
{
String defaultValue = "";
return ScriptGlobal::Get("PkgDataDir", &Empty);
}
/**
* Sets the path for the package data dir.
*
* @param path The new path.
*/
void Application::DeclarePkgDataDir(const String& path)
{
if (!ScriptGlobal::Exists("PkgDataDir"))
ScriptGlobal::Set("PkgDataDir", path);
}
/**
* Retrieves the path for the include conf dir.
*
* @returns The path.
*/
String Application::GetIncludeConfDir()
{
return ScriptGlobal::Get("IncludeConfDir", &Empty);
}
/**
* Sets the path for the package data dir.
*
* @param path The new path.
*/
void Application::DeclareIncludeConfDir(const String& path)
{
if (!ScriptGlobal::Exists("IncludeConfDir"))
ScriptGlobal::Set("IncludeConfDir", path);
}
/**
* Retrieves the path for the state file.
*
* @returns The path.
*/
String Application::GetStatePath()
{
return ScriptGlobal::Get("StatePath", &Empty);
}
/**
* Sets the path for the state file.
*
* @param path The new path.
*/
void Application::DeclareStatePath(const String& path)
{
if (!ScriptGlobal::Exists("StatePath"))
ScriptGlobal::Set("StatePath", path);
}
/**
* Retrieves the path for the modified attributes file.
*
* @returns The path.
*/
String Application::GetModAttrPath()
{
return ScriptGlobal::Get("ModAttrPath", &Empty);
}
/**
* Sets the path for the modified attributes file.
*
* @param path The new path.
*/
void Application::DeclareModAttrPath(const String& path)
{
if (!ScriptGlobal::Exists("ModAttrPath"))
ScriptGlobal::Set("ModAttrPath", path);
}
/**
* Retrieves the path for the objects file.
*
* @returns The path.
*/
String Application::GetObjectsPath()
{
return ScriptGlobal::Get("ObjectsPath", &Empty);
}
/**
* Sets the path for the objects file.
*
* @param path The new path.
*/
void Application::DeclareObjectsPath(const String& path)
{
if (!ScriptGlobal::Exists("ObjectsPath"))
ScriptGlobal::Set("ObjectsPath", path);
}
/**
* Retrieves the path for the vars file.
*
* @returns The path.
*/
String Application::GetVarsPath()
{
return ScriptGlobal::Get("VarsPath", &Empty);
}
/**
* Sets the path for the vars file.
*
* @param path The new path.
*/
void Application::DeclareVarsPath(const String& path)
{
if (!ScriptGlobal::Exists("VarsPath"))
ScriptGlobal::Set("VarsPath", path);
}
/**
* Retrieves the path for the PID file.
*
* @returns The path.
*/
String Application::GetPidPath()
{
return ScriptGlobal::Get("PidPath", &Empty);
}
/**
* Sets the path for the PID file.
*
* @param path The new path.
*/
void Application::DeclarePidPath(const String& path)
{
if (!ScriptGlobal::Exists("PidPath"))
ScriptGlobal::Set("PidPath", path);
}
/**
* Retrieves the name of the user.
*
* @returns The name.
*/
String Application::GetRunAsUser()
{
return ScriptGlobal::Get("RunAsUser");
}
/**
* Sets the name of the user.
*
* @param path The new user name.
*/
void Application::DeclareRunAsUser(const String& user)
{
if (!ScriptGlobal::Exists("RunAsUser"))
ScriptGlobal::Set("RunAsUser", user);
}
/**
* Retrieves the name of the group.
*
* @returns The name.
*/
String Application::GetRunAsGroup()
{
return ScriptGlobal::Get("RunAsGroup");
}
/**
* Sets the name of the group.
*
* @param path The new group name.
*/
void Application::DeclareRunAsGroup(const String& group)
{
if (!ScriptGlobal::Exists("RunAsGroup"))
ScriptGlobal::Set("RunAsGroup", group);
}
/**
* Retrieves the file rlimit.
*
* @returns The limit.
*/
int Application::GetRLimitFiles()
{
return ScriptGlobal::Get("RLimitFiles");
return ScriptGlobal::Get(name, &defaultValue);
}
int Application::GetDefaultRLimitFiles()
@ -1468,80 +1207,16 @@ int Application::GetDefaultRLimitFiles()
return 16 * 1024;
}
/**
* Sets the file rlimit.
*
* @param path The new file rlimit.
*/
void Application::DeclareRLimitFiles(int limit)
{
if (!ScriptGlobal::Exists("RLimitFiles"))
ScriptGlobal::Set("RLimitFiles", limit);
}
/**
* Retrieves the process rlimit.
*
* @returns The limit.
*/
int Application::GetRLimitProcesses()
{
return ScriptGlobal::Get("RLimitProcesses");
}
int Application::GetDefaultRLimitProcesses()
{
return 16 * 1024;
}
/**
* Sets the process rlimit.
*
* @param path The new process rlimit.
*/
void Application::DeclareRLimitProcesses(int limit)
{
if (!ScriptGlobal::Exists("RLimitProcesses"))
ScriptGlobal::Set("RLimitProcesses", limit);
}
/**
* Retrieves the stack rlimit.
*
* @returns The limit.
*/
int Application::GetRLimitStack()
{
return ScriptGlobal::Get("RLimitStack");
}
int Application::GetDefaultRLimitStack()
{
return 256 * 1024;
}
/**
* Sets the stack rlimit.
*
* @param path The new stack rlimit.
*/
void Application::DeclareRLimitStack(int limit)
{
if (!ScriptGlobal::Exists("RLimitStack"))
ScriptGlobal::Set("RLimitStack", limit);
}
/**
* Sets the concurrency level.
*
* @param path The new concurrency level.
*/
void Application::DeclareConcurrency(int ncpus)
{
if (!ScriptGlobal::Exists("Concurrency"))
ScriptGlobal::Set("Concurrency", ncpus);
}
/**
* Retrieves the concurrency level.
*
@ -1563,17 +1238,6 @@ void Application::SetMaxConcurrentChecks(int maxChecks)
ScriptGlobal::Set("MaxConcurrentChecks", maxChecks);
}
/**
* Sets the max concurrent checks.
*
* @param maxChecks The new limit.
*/
void Application::DeclareMaxConcurrentChecks(int maxChecks)
{
if (!ScriptGlobal::Exists("MaxConcurrentChecks"))
ScriptGlobal::Set("MaxConcurrentChecks", maxChecks);
}
/**
* Retrieves the max concurrent checks.
*

View File

@ -85,70 +85,21 @@ public:
static String GetExePath(const String& argv0);
static String GetPrefixDir();
static void DeclarePrefixDir(const String& path);
static String GetSysconfDir();
static void DeclareSysconfDir(const String& path);
static String GetZonesDir();
static void DeclareZonesDir(const String& path);
static String GetRunDir();
static void DeclareRunDir(const String& path);
static String GetLocalStateDir();
static void DeclareLocalStateDir(const String& path);
static String GetPkgDataDir();
static void DeclarePkgDataDir(const String& path);
static String GetIncludeConfDir();
static void DeclareIncludeConfDir(const String& path);
static String GetStatePath(void);
static void DeclareStatePath(const String& path);
static String GetModAttrPath();
static void DeclareModAttrPath(const String& path);
static String GetObjectsPath();
static void DeclareObjectsPath(const String& path);
static String GetVarsPath();
static void DeclareVarsPath(const String& path);
static String GetPidPath();
static void DeclarePidPath(const String& path);
static String GetRunAsUser();
static void DeclareRunAsUser(const String& user);
static String GetRunAsGroup();
static void DeclareRunAsGroup(const String& group);
static void DeclareConst(const String& name, const Value& value);
static Value GetConst(const String& name);
static Value GetConst(const String& name, Value defaultValue);
#ifdef _WIN32
static bool IsProcessElevated();
#endif /* _WIN32 */
static int GetRLimitFiles();
static int GetDefaultRLimitFiles();
static void DeclareRLimitFiles(int limit);
static int GetRLimitProcesses();
static int GetDefaultRLimitProcesses();
static void DeclareRLimitProcesses(int limit);
static int GetRLimitStack();
static int GetDefaultRLimitStack();
static void DeclareRLimitStack(int limit);
static int GetConcurrency();
static void DeclareConcurrency(int ncpus);
static int GetMaxConcurrentChecks();
static int GetDefaultMaxConcurrentChecks();
static void DeclareMaxConcurrentChecks(int maxChecks);
static void SetMaxConcurrentChecks(int maxChecks);
static ThreadPool& GetTP();

View File

@ -535,7 +535,7 @@ std::shared_ptr<X509> CreateCert(EVP_PKEY *pubkey, X509_NAME *subject, X509_NAME
String GetIcingaCADir()
{
return Application::GetLocalStateDir() + "/lib/icinga2/ca";
return Application::GetConst("DataDir") + "/ca";
}
std::shared_ptr<X509> CreateCertIcingaCA(EVP_PKEY *pubkey, X509_NAME *subject)

View File

@ -36,14 +36,14 @@ set_target_properties (
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/checker.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
${ICINGA2_CONFIGDIR}/features-available
)
if(NOT WIN32)
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled\")")
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/checker.conf \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled/checker.conf\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_CONFIGDIR}/features-enabled\")")
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/checker.conf \"\$ENV{DESTDIR}${ICINGA2_FULL_CONFIGDIR}/features-enabled/checker.conf\")")
else()
install_if_not_exists(${PROJECT_SOURCE_DIR}/etc/icinga2/features-enabled/checker.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-enabled)
install_if_not_exists(${PROJECT_SOURCE_DIR}/etc/icinga2/features-enabled/checker.conf ${ICINGA2_CONFIGDIR}/features-enabled)
endif()
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}" PARENT_SCOPE)

View File

@ -40,7 +40,7 @@ using namespace icinga;
String ApiSetupUtility::GetConfdPath()
{
return Application::GetSysconfDir() + "/icinga2/conf.d";
return Application::GetConst("ConfigDir") + "/conf.d";
}
String ApiSetupUtility::GetApiUsersConfPath()

View File

@ -72,7 +72,7 @@ static bool Daemonize()
do {
Utility::Sleep(0.1);
readpid = Application::ReadPidFile(Application::GetPidPath());
readpid = Application::ReadPidFile(Application::GetConst("PidPath"));
ret = waitpid(pid, &status, WNOHANG);
} while (readpid != pid && ret == 0);
@ -193,7 +193,7 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
<< ")";
if (!vm.count("validate") && !vm.count("reload-internal")) {
pid_t runningpid = Application::ReadPidFile(Application::GetPidPath());
pid_t runningpid = Application::ReadPidFile(Application::GetConst("PidPath"));
if (runningpid > 0) {
Log(LogCritical, "cli")
<< "Another instance of Icinga already running with PID " << runningpid;
@ -204,14 +204,16 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
std::vector<std::string> configs;
if (vm.count("config") > 0)
configs = vm["config"].as<std::vector<std::string> >();
else if (!vm.count("no-config"))
configs.push_back(Application::GetSysconfDir() + "/icinga2/icinga2.conf");
else if (!vm.count("no-config")) {
String configDir = Application::GetConst("ConfigDir");
configs.push_back(configDir + "/icinga2.conf");
}
Log(LogInformation, "cli", "Loading configuration file(s).");
std::vector<ConfigItem::Ptr> newItems;
if (!DaemonUtility::LoadConfigFiles(configs, newItems, Application::GetObjectsPath(), Application::GetVarsPath()))
if (!DaemonUtility::LoadConfigFiles(configs, newItems, Application::GetConst("ObjectsPath"), Application::GetConst("VarsPath")))
return EXIT_FAILURE;
if (vm.count("validate")) {
@ -253,7 +255,7 @@ int DaemonCommand::Run(const po::variables_map& vm, const std::vector<std::strin
/* restore the previous program state */
try {
ConfigObject::RestoreObjects(Application::GetStatePath());
ConfigObject::RestoreObjects(Application::GetConst("StatePath"));
} catch (const std::exception& ex) {
Log(LogCritical, "cli")
<< "Failed to restore state file: " << DiagnosticInformation(ex);

View File

@ -121,7 +121,7 @@ bool DaemonUtility::ValidateConfigFiles(const std::vector<std::string>& configs,
* unfortunately moving it there is somewhat non-trivial. */
success = true;
String zonesEtcDir = Application::GetZonesDir();
String zonesEtcDir = Application::GetConst("ZonesDir");
if (!zonesEtcDir.IsEmpty() && Utility::PathExists(zonesEtcDir))
Utility::Glob(zonesEtcDir + "/*", std::bind(&IncludeZoneDirRecursive, _1, "_etc", std::ref(success)), GlobDirectory);
@ -130,7 +130,7 @@ bool DaemonUtility::ValidateConfigFiles(const std::vector<std::string>& configs,
/* Load package config files - they may contain additional zones which
* are authoritative on this node and are checked in HasZoneConfigAuthority(). */
String packagesVarDir = Application::GetLocalStateDir() + "/lib/icinga2/api/packages";
String packagesVarDir = Application::GetConst("DataDir") + "/api/packages";
if (Utility::PathExists(packagesVarDir))
Utility::Glob(packagesVarDir + "/*", std::bind(&IncludePackage, _1, std::ref(success)), GlobDirectory);
@ -138,7 +138,7 @@ bool DaemonUtility::ValidateConfigFiles(const std::vector<std::string>& configs,
return false;
/* Load cluster synchronized configuration files */
String zonesVarDir = Application::GetLocalStateDir() + "/lib/icinga2/api/zones";
String zonesVarDir = Application::GetConst("DataDir") + "/api/zones";
if (Utility::PathExists(zonesVarDir))
Utility::Glob(zonesVarDir + "/*", std::bind(&IncludeNonLocalZone, _1, "_cluster", std::ref(success)), GlobDirectory);

View File

@ -31,12 +31,12 @@ using namespace icinga;
String FeatureUtility::GetFeaturesAvailablePath()
{
return Application::GetSysconfDir() + "/icinga2/features-available";
return Application::GetConst("ConfigDir") + "/features-available";
}
String FeatureUtility::GetFeaturesEnabledPath()
{
return Application::GetSysconfDir() + "/icinga2/features-enabled";
return Application::GetConst("ConfigDir") + "/features-enabled";
}
std::vector<String> FeatureUtility::GetFieldCompletionSuggestions(const String& word, bool enable)

View File

@ -410,7 +410,7 @@ int NodeSetupCommand::SetupNode(const boost::program_options::variables_map& vm,
} else {
/* We cannot retrieve the parent certificate.
* Tell the user to manually copy the ca.crt file
* into LocalStateDir + "/lib/icinga2/certs"
* into DataDir + "/certs"
*/
Log(LogWarning, "cli")
<< "\nNo connection to the parent node was specified.\n\n"

View File

@ -43,12 +43,12 @@ using namespace icinga;
String NodeUtility::GetConstantsConfPath()
{
return Application::GetSysconfDir() + "/icinga2/constants.conf";
return Application::GetConst("ConfigDir") + "/constants.conf";
}
String NodeUtility::GetZonesConfPath()
{
return Application::GetSysconfDir() + "/icinga2/zones.conf";
return Application::GetConst("ConfigDir") + "/zones.conf";
}
/*
@ -274,7 +274,7 @@ void NodeUtility::SerializeObject(std::ostream& fp, const Dictionary::Ptr& objec
*/
bool NodeUtility::UpdateConfiguration(const String& value, bool include, bool recursive)
{
String configurationFile = Application::GetSysconfDir() + "/icinga2/icinga2.conf";
String configurationFile = Application::GetConst("ConfigDir") + "/icinga2.conf";
Log(LogInformation, "cli")
<< "Updating '" << value << "' include in '" << configurationFile << "'.";

View File

@ -392,7 +392,7 @@ wizard_ticket:
} else {
/* We cannot retrieve the parent certificate.
* Tell the user to manually copy the ca.crt file
* into LocalStateDir + "/lib/icinga2/certs"
* into DataDir + "/certs"
*/
std::cout << ConsoleColorTag(Console_Bold)
@ -850,7 +850,7 @@ wizard_global_zone_loop_start:
}
/* Include api-users.conf */
String apiUsersFilePath = Application::GetSysconfDir() + "/icinga2/conf.d/api-users.conf";
String apiUsersFilePath = Application::GetConst("ConfigDir") + "/conf.d/api-users.conf";
std::cout << ConsoleColorTag(Console_Bold | Console_ForegroundGreen)
<< "Checking if the api-users.conf file exists...\n"

View File

@ -67,11 +67,11 @@ void ObjectListCommand::InitParameters(boost::program_options::options_descripti
*/
int ObjectListCommand::Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const
{
String objectfile = Application::GetObjectsPath();
String objectfile = Application::GetConst("ObjectsPath");
if (!Utility::PathExists(objectfile)) {
Log(LogCritical, "cli")
<< "Cannot open objects file '" << Application::GetObjectsPath() << "'.";
<< "Cannot open objects file '" << Application::GetConst("ObjectsPath") << "'.";
Log(LogCritical, "cli", "Run 'icinga2 daemon -C' to validate config and generate the cache file.");
return 1;
}

View File

@ -147,16 +147,26 @@ bool TroubleshootCommand::GeneralInfo(InfoLog& log, const boost::program_options
//Application::DisplayInfoMessage() but formatted
InfoLogLine(log)
<< "\tApplication version: " << Application::GetAppVersion() << '\n'
<< "\tInstallation root: " << Application::GetPrefixDir() << '\n'
<< "\tSysconf directory: " << Application::GetSysconfDir() << '\n'
<< "\tRun directory: " << Application::GetRunDir() << '\n'
<< "\tLocal state directory: " << Application::GetLocalStateDir() << '\n'
<< "\tPackage data directory: " << Application::GetPkgDataDir() << '\n'
<< "\tState path: " << Application::GetStatePath() << '\n'
<< "\tObjects path: " << Application::GetObjectsPath() << '\n'
<< "\tVars path: " << Application::GetVarsPath() << '\n'
<< "\tPID path: " << Application::GetPidPath() << '\n';
<< "\tApplication version: " << Application::GetConst("AppVersion") << '\n'
<< "\t\n"
<< "\tConfig directory: " << Application::GetConst("ConfigDir") << "\n"
<< "\tData directory: " << Application::GetConst("DataDir") << "\n"
<< "\tLog directory: " << Application::GetConst("LogDir") << "\n"
<< "\tCache directory: " << Application::GetConst("CacheDir") << "\n"
<< "\tRun directory: " << Application::GetConst("InitRunDir") << "\n"
<< "\t\n"
<< "Older paths (deprecated):" << "\n"
<< "\tInstallation root: " << Application::GetConst("PrefixDir") << '\n'
<< "\tSysconf directory: " << Application::GetConst("SysconfDir") << '\n'
<< "\tRun directory: " << Application::GetConst("RunDir") << '\n'
<< "\tLocal state directory: " << Application::GetConst("LocalStateDir") << '\n'
<< "\t\n"
<< "Internally used paths:" << "\n"
<< "\tPackage data directory: " << Application::GetConst("PkgDataDir") << '\n'
<< "\tState path: " << Application::GetConst("StatePath") << '\n'
<< "\tObjects path: " << Application::GetConst("ObjectsPath") << '\n'
<< "\tVars path: " << Application::GetConst("VarsPath") << '\n'
<< "\tPID path: " << Application::GetConst("PidPath") << '\n';
InfoLogLine(log)
<< '\n';
@ -176,7 +186,7 @@ bool TroubleshootCommand::ObjectInfo(InfoLog& log, const boost::program_options:
InfoLogLine(log, Console_ForegroundBlue)
<< std::string(14, '=') << " OBJECT INFORMATION " << std::string(14, '=') << "\n\n";
String objectfile = Application::GetObjectsPath();
String objectfile = Application::GetConst("ObjectsPath");
std::set<String> configs;
if (!Utility::PathExists(objectfile)) {
@ -252,14 +262,14 @@ bool TroubleshootCommand::ConfigInfo(InfoLog& log, const boost::program_options:
InfoLogLine(log)
<< "A collection of important configuration files follows, please make sure to remove any sensitive data such as credentials, internal company names, etc\n";
if (!PrintFile(log, Application::GetSysconfDir() + "/icinga2/icinga2.conf")) {
if (!PrintFile(log, Application::GetConst("ConfigDir") + "/icinga2.conf")) {
InfoLogLine(log, 0, LogWarning)
<< "icinga2.conf not found, therefore skipping validation.\n"
<< "If you are using an icinga2.conf somewhere but the default path please validate it via 'icinga2 daemon -C -c \"path\to/icinga2.conf\"'\n"
<< "and provide it with your support request.\n";
}
if (!PrintFile(log, Application::GetSysconfDir() + "/icinga2/zones.conf")) {
if (!PrintFile(log, Application::GetConst("ConfigDir") + "/zones.conf")) {
InfoLogLine(log, 0, LogWarning)
<< "zones.conf not found.\n"
<< "If you are using a zones.conf somewhere but the default path please provide it with your support request\n";
@ -370,7 +380,7 @@ void TroubleshootCommand::GetLatestReport(const String& filename, time_t& bestTi
bool TroubleshootCommand::PrintCrashReports(InfoLog& log)
{
String spath = Application::GetLocalStateDir() + "/log/icinga2/crash/report.*";
String spath = Application::GetConst("LogDir") + "/crash/report.*";
time_t bestTimestamp = 0;
String bestFilename;
@ -383,7 +393,7 @@ bool TroubleshootCommand::PrintCrashReports(InfoLog& log)
if (int const * err = boost::get_error_info<errinfo_win32_error>(ex)) {
if (*err != 3) {//Error code for path does not exist
InfoLogLine(log, 0, LogWarning)
<< Application::GetLocalStateDir() << "/log/icinga2/crash/ does not exist\n";
<< Application::GetConst("LogDir") + "/crash/ does not exist\n";
return false;
}
@ -396,7 +406,7 @@ bool TroubleshootCommand::PrintCrashReports(InfoLog& log)
#else
catch (...) {
InfoLogLine(log, 0, LogWarning) << "Error printing crash reports.\n"
<< "Does " << Application::GetLocalStateDir() << "/log/icinga2/crash/ exist?\n";
<< "Does " << Application::GetConst("LogDir") + "/crash/ exist?\n";
return false;
}
@ -404,7 +414,7 @@ bool TroubleshootCommand::PrintCrashReports(InfoLog& log)
if (!bestTimestamp)
InfoLogLine(log, Console_ForegroundYellow)
<< "No crash logs found in " << Application::GetLocalStateDir().CStr() << "/log/icinga2/crash/\n\n";
<< "No crash logs found in " << Application::GetConst("LogDir") << "/crash/\n\n";
else {
InfoLogLine(log)
<< "Latest crash report is from " << Utility::FormatDateTime("%Y-%m-%d %H:%M:%S", Utility::GetTime()) << '\n'
@ -444,7 +454,9 @@ bool TroubleshootCommand::PrintFile(InfoLog& log, const String& path)
bool TroubleshootCommand::CheckConfig()
{
return DaemonUtility::ValidateConfigFiles({ Application::GetSysconfDir() + "/icinga2/icinga2.conf" }, Application::GetObjectsPath());
String configDir = Application::GetConst("ConfigDir");
String objectsPath = Application::GetConst("ObjectsPath");
return DaemonUtility::ValidateConfigFiles({ configDir + "/icinga2.conf" }, objectsPath);
}
//print is supposed allow the user to print the object file
@ -610,10 +622,10 @@ void TroubleshootCommand::InitParameters(boost::program_options::options_descrip
int TroubleshootCommand::Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const
{
#ifdef _WIN32 //Dislikes ':' in filenames
String path = Application::GetLocalStateDir() + "/log/icinga2/troubleshooting-"
String path = Application::GetConst("LogDir") + "/troubleshooting-"
+ Utility::FormatDateTime("%Y-%m-%d_%H-%M-%S", Utility::GetTime()) + ".log";
#else
String path = Application::GetLocalStateDir() + "/log/icinga2/troubleshooting-"
String path = Application::GetConst("LogDir") + "/troubleshooting-"
+ Utility::FormatDateTime("%Y-%m-%d_%H:%M:%S", Utility::GetTime()) + ".log";
#endif /*_WIN32*/

View File

@ -75,7 +75,7 @@ int VariableGetCommand::Run(const boost::program_options::variables_map& vm, con
return 0;
}
String varsfile = Application::GetVarsPath();
String varsfile = Application::GetConst("VarsPath");
if (!Utility::PathExists(varsfile)) {
Log(LogCritical, "cli")

View File

@ -53,7 +53,7 @@ String VariableListCommand::GetShortDescription() const
*/
int VariableListCommand::Run(const boost::program_options::variables_map& vm, const std::vector<std::string>& ap) const
{
String varsfile = Application::GetVarsPath();
String varsfile = Application::GetConst("VarsPath");
if (!Utility::PathExists(varsfile)) {
Log(LogCritical, "cli")

View File

@ -31,7 +31,7 @@ using namespace icinga;
Value VariableUtility::GetVariable(const String& name)
{
String varsfile = Application::GetVarsPath();
String varsfile = Application::GetConst("VarsPath");
std::fstream fp;
fp.open(varsfile.CStr(), std::ios_base::in);
@ -61,7 +61,7 @@ Value VariableUtility::GetVariable(const String& name)
void VariableUtility::PrintVariables(std::ostream& outfp)
{
String varsfile = Application::GetVarsPath();
String varsfile = Application::GetConst("VarsPath");
std::fstream fp;
fp.open(varsfile.CStr(), std::ios_base::in);

View File

@ -42,21 +42,21 @@ set_target_properties (
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/command.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
${ICINGA2_CONFIGDIR}/features-available
)
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/compatlog.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
${ICINGA2_CONFIGDIR}/features-available
)
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/statusdata.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
${ICINGA2_CONFIGDIR}/features-available
)
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/log/icinga2/compat/archives\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/spool/icinga2\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_RUNDIR}/icinga2/cmd\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_LOGDIR}/compat/archives\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_SPOOLDIR}\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_INITRUNDIR}/cmd\")")
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}" PARENT_SCOPE)

View File

@ -30,7 +30,7 @@ class CheckResultReader : ConfigObject
activation_priority 100;
[config] String spool_dir {
default {{{ return Application::GetLocalStateDir() + "/lib/icinga2/spool/checkresults/"; }}}
default {{{ return Application::GetConst("DataDir") + "/spool/checkresults/"; }}}
};
};

View File

@ -30,7 +30,7 @@ class CompatLogger : ConfigObject
activation_priority 100;
[config] String log_dir {
default {{{ return Application::GetLocalStateDir() + "/log/icinga2/compat"; }}}
default {{{ return Application::GetConst("LogDir") + "/compat"; }}}
};
[config] String rotation_method {
default {{{ return "HOURLY"; }}}

View File

@ -30,7 +30,7 @@ class ExternalCommandListener : ConfigObject
activation_priority 100;
[config] String command_path {
default {{{ return Application::GetRunDir() + "/icinga2/cmd/icinga2.cmd"; }}}
default {{{ return Application::GetConst("InitRunDir") + "/cmd/icinga2.cmd"; }}}
};
};

View File

@ -559,7 +559,7 @@ void StatusDataWriter::UpdateObjectsCache()
{
CONTEXT("Writing objects.cache file");
String objectsPath = GetObjectsPath();
String objectsPath = Application::GetConst("ObjectsPath");
std::fstream objectfp;
String tempObjectsPath = Utility::CreateTempFile(objectsPath + ".XXXXXX", 0644, objectfp);

View File

@ -30,10 +30,10 @@ class StatusDataWriter : ConfigObject
activation_priority 100;
[config] String status_path {
default {{{ return Application::GetLocalStateDir() + "/cache/icinga2/status.dat"; }}}
default {{{ return Application::GetConst("CacheDir") + "/status.dat"; }}}
};
[config] String objects_path {
default {{{ return Application::GetLocalStateDir() + "/cache/icinga2/objects.cache"; }}}
default {{{ return Application::GetConst("CacheDir") + "/objects.cache"; }}}
};
[config] double update_interval {
default {{{ return 15; }}}

View File

@ -577,8 +577,8 @@ bool ConfigItem::ActivateItems(WorkQueue& upq, const std::vector<ConfigItem::Ptr
if (withModAttrs) {
/* restore modified attributes */
if (Utility::PathExists(Application::GetModAttrPath())) {
std::unique_ptr<Expression> expression = ConfigCompiler::CompileFile(Application::GetModAttrPath());
if (Utility::PathExists(Application::GetConst("ModAttrPath"))) {
std::unique_ptr<Expression> expression = ConfigCompiler::CompileFile(Application::GetConst("ModAttrPath"));
if (expression) {
try {

View File

@ -38,7 +38,7 @@ set_target_properties (
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/ido-mysql.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
${ICINGA2_CONFIGDIR}/features-available
)
install(

View File

@ -38,7 +38,7 @@ set_target_properties (
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/ido-pgsql.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
${ICINGA2_CONFIGDIR}/features-available
)
install(

View File

@ -156,13 +156,13 @@ static void PersistModAttrHelper(std::fstream& fp, ConfigObject::Ptr& previousOb
void IcingaApplication::DumpProgramState()
{
ConfigObject::DumpObjects(GetStatePath());
ConfigObject::DumpObjects(GetConst("StatePath"));
DumpModifiedAttributes();
}
void IcingaApplication::DumpModifiedAttributes()
{
String path = GetModAttrPath();
String path = GetConst("ModAttrPath");
std::fstream fp;
String tempFilename = Utility::CreateTempFile(path + ".XXXXXX", 0644, fp);

View File

@ -46,8 +46,6 @@ public:
static IcingaApplication::Ptr GetInstance();
String GetPidPath() const;
bool ResolveMacro(const String& macro, const CheckResult::Ptr& cr, Value *result) const override;
String GetNodeName() const;

View File

@ -72,9 +72,9 @@ set_target_properties (
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/livestatus.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
${ICINGA2_CONFIGDIR}/features-available
)
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_RUNDIR}/icinga2/cmd\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_INITRUNDIR}/cmd\")")
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}" PARENT_SCOPE)

View File

@ -32,7 +32,7 @@ class LivestatusListener : ConfigObject {
default {{{ return "unix"; }}}
};
[config] String socket_path {
default {{{ return Application::GetRunDir() + "/icinga2/cmd/livestatus"; }}}
default {{{ return Application::GetConst("InitRunDir") + "/cmd/livestatus"; }}}
};
[config] String bind_host {
default {{{ return "127.0.0.1"; }}}
@ -41,7 +41,7 @@ class LivestatusListener : ConfigObject {
default {{{ return "6558"; }}}
};
[config] String compat_log_path {
default {{{ return Application::GetLocalStateDir() + "/log/icinga2/compat"; }}}
default {{{ return Application::GetConst("LogDir") + "/compat"; }}}
};
};

View File

@ -36,14 +36,14 @@ set_target_properties (
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/notification.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
${ICINGA2_CONFIGDIR}/features-available
)
if(NOT WIN32)
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled\")")
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/notification.conf \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_SYSCONFDIR}/icinga2/features-enabled/notification.conf\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_CONFIGDIR}/features-enabled\")")
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/notification.conf \"\$ENV{DESTDIR}${ICINGA2_FULL_CONFIGDIR}/features-enabled/notification.conf\")")
else()
install_if_not_exists(${PROJECT_SOURCE_DIR}/etc/icinga2/features-enabled/notification.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-enabled)
install_if_not_exists(${PROJECT_SOURCE_DIR}/etc/icinga2/features-enabled/notification.conf ${ICINGA2_CONFIGDIR}/features-enabled)
endif()
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}" PARENT_SCOPE)

View File

@ -46,35 +46,35 @@ set_target_properties (
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/gelf.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
${ICINGA2_CONFIGDIR}/features-available
)
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/graphite.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
${ICINGA2_CONFIGDIR}/features-available
)
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/influxdb.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
${ICINGA2_CONFIGDIR}/features-available
)
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/elasticsearch.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
${ICINGA2_CONFIGDIR}/features-available
)
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/opentsdb.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
${ICINGA2_CONFIGDIR}/features-available
)
install_if_not_exists(
${PROJECT_SOURCE_DIR}/etc/icinga2/features-available/perfdata.conf
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
${ICINGA2_CONFIGDIR}/features-available
)
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/spool/icinga2/perfdata\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/spool/icinga2/tmp\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_SPOOLDIR}/perfdata\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_SPOOLDIR}/tmp\")")
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}" PARENT_SCOPE)

View File

@ -30,16 +30,16 @@ class PerfdataWriter : ConfigObject
activation_priority 100;
[config] String host_perfdata_path {
default {{{ return Application::GetLocalStateDir() + "/spool/icinga2/perfdata/host-perfdata"; }}}
default {{{ return Application::GetConst("SpoolDir") + "/perfdata/host-perfdata"; }}}
};
[config] String service_perfdata_path {
default {{{ return Application::GetLocalStateDir() + "/spool/icinga2/perfdata/service-perfdata"; }}}
default {{{ return Application::GetConst("SpoolDir") + "/perfdata/service-perfdata"; }}}
};
[config] String host_temp_path {
default {{{ return Application::GetLocalStateDir() + "/spool/icinga2/tmp/host-perfdata"; }}}
default {{{ return Application::GetConst("SpoolDir") + "/tmp/host-perfdata"; }}}
};
[config] String service_temp_path {
default {{{ return Application::GetLocalStateDir() + "/spool/icinga2/tmp/service-perfdata"; }}}
default {{{ return Application::GetConst("SpoolDir") + "/tmp/service-perfdata"; }}}
};
[config] String host_format_template {
default {{{

View File

@ -76,10 +76,10 @@ set_target_properties (
FOLDER Lib
)
#install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/icinga2/api\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/icinga2/api/log\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/icinga2/api/zones\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/icinga2/certs\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${CMAKE_INSTALL_FULL_LOCALSTATEDIR}/lib/icinga2/certificate-requests\")")
#install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_DATADIR}/api\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_DATADIR}/api/log\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_DATADIR}/api/zones\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_DATADIR}/certs\")")
install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_DATADIR}/certificate-requests\")")

View File

@ -202,7 +202,7 @@ void ApiListener::SyncZoneDir(const Zone::Ptr& zone) const
if (sumUpdates == 0)
return;
String oldDir = Application::GetLocalStateDir() + "/lib/icinga2/api/zones/" + zone->GetName();
String oldDir = Application::GetConst("DataDir") + "/api/zones/" + zone->GetName();
Log(LogInformation, "ApiListener")
<< "Copying " << sumUpdates << " zone configuration files for zone '" << zone->GetName() << "' to '" << oldDir << "'.";
@ -240,7 +240,7 @@ void ApiListener::SendConfigUpdate(const JsonRpcConnection::Ptr& aclient)
Dictionary::Ptr configUpdateV1 = new Dictionary();
Dictionary::Ptr configUpdateV2 = new Dictionary();
String zonesDir = Application::GetLocalStateDir() + "/lib/icinga2/api/zones";
String zonesDir = Application::GetConst("DataDir") + "/api/zones";
for (const Zone::Ptr& zone : ConfigType::GetObjectsByType<Zone>()) {
String zoneDir = zonesDir + "/" + zone->GetName();
@ -315,7 +315,7 @@ Value ApiListener::ConfigUpdateHandler(const MessageOrigin::Ptr& origin, const D
continue;
}
String oldDir = Application::GetLocalStateDir() + "/lib/icinga2/api/zones/" + zone->GetName();
String oldDir = Application::GetConst("DataDir") + "/api/zones/" + zone->GetName();
Utility::MkDirP(oldDir, 0700);

View File

@ -56,22 +56,22 @@ ApiListener::ApiListener()
String ApiListener::GetApiDir()
{
return Application::GetLocalStateDir() + "/lib/icinga2/api/";
return Application::GetConst("DataDir") + "/api/";
}
String ApiListener::GetCertsDir()
{
return Application::GetLocalStateDir() + "/lib/icinga2/certs/";
return Application::GetConst("DataDir") + "/certs/";
}
String ApiListener::GetCaDir()
{
return Application::GetLocalStateDir() + "/lib/icinga2/ca/";
return Application::GetConst("DataDir") + "/ca/";
}
String ApiListener::GetCertificateRequestsDir()
{
return Application::GetLocalStateDir() + "/lib/icinga2/certificate-requests/";
return Application::GetConst("DataDir") + "/certificate-requests/";
}
String ApiListener::GetDefaultCertPath()

View File

@ -30,7 +30,7 @@ using namespace icinga;
String ConfigPackageUtility::GetPackageDir()
{
return Application::GetLocalStateDir() + "/lib/icinga2/api/packages";
return Application::GetConst("DataDir") + "/api/packages";
}
void ConfigPackageUtility::CreatePackage(const String& name)