PidPath |**Read-write.** Contains the path of the Icinga 2 PID file. Defaults to RunDir + "/icinga2/icinga2.pid".
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.
-ApplicationType |**Read-write.** Contains the name of the Application type. Defaults to "icinga/IcingaApplication".
EnableNotifications |**Read-write.** Whether notifications are globally enabled. Defaults to true.
EnableEventHandlers |**Read-write.** Whether event handlers are globally enabled. Defaults to true.
EnableFlapping |**Read-write.** Whether flap detection is globally enabled. Defaults to true.
EnableServiceChecks |**Read-write.** Whether active service checks are globally enabled. Defaults to true.
EnablePerfdata |**Read-write.** Whether performance data processing is globally enabled. Defaults to true.
UseVfork |**Read-write.** Whether to use vfork(). Only available on *NIX. Defaults to true.
+AttachDebugger |**Read-write.** Whether to attach a debugger when Icinga 2 crashes. Defaults to false.
RunAsUser |**Read-write.** Defines the user the Icinga 2 daemon is running as. Used in the `init.conf` configuration file.
RunAsGroup |**Read-write.** Defines the group the Icinga 2 daemon is running as. Used in the `init.conf` configuration file.
The file names need to match the pattern given in the second parameter.
When no pattern is specified the default pattern "*.conf" is used.
+## <a id="zone-includes"></a> Zone Includes
+
+The `include_zones` recursively includes all subdirectories for the
+given path.
+
+In addition to that it sets the `zone` attribute for all objects created
+in these subdirectories to the name of the subdirectory.
+
+Example:
+
+ include_zones "etc", "zones.d", "*.conf"
+ include_zones "puppet", "puppet-zones"
+
+The first parameter specifies a tag name for this directive. Each `include_zones`
+invocation should use a unique tag name. When copying the zones' configuration
+files Icinga uses the tag name as the name for the destination directory in
+`/var/lib/icinga2/api/config`.
+
+The second parameter specifies the directory which contains the subdirectories.
+
+The file names need to match the pattern given in the third parameter.
+When no pattern is specified the default pattern "*.conf" is used.
+
## <a id="library"></a> Library directive
The `library` directive can be used to manually load additional
Example:
function multiply(a, b) {
- return a * b
- }
+ return a * b
+ }
When encountering the `return` keyword further execution of the function is terminated and
the specified value is supplied to the caller of the function:
`multiply` function like this:
function multiply(a, b) {
- a * b
- }
+ a * b
+ }
Anonymous functions can be created by omitting the name in the function definition. The
resulting function object can be used like any other value:
var fn = function() { 3 }
-
- fn() /* Returns 3 */
+
+ fn() /* Returns 3 */
## <a id="lambdas"></a> Lambda Expressions
Multiple statements can be used by putting the function body into braces:
f = (x) => {
- log("Lambda called")
- x * x
+ log("Lambda called")
+ x * x
}
Just like with ordinary functions the return value is the value of the last statement.
object or apply statement. Local variables can be declared using the `var` keyword:
function multiply(a, b) {
- var temp = a * b
- return temp
- }
+ var temp = a * b
+ return temp
+ }
Each time the `multiply` function is invoked a new `temp` variable is used which is in no way
related to previous invocations of the function.
operates on.
object Host "localhost" {
- check_interval = 5m
+ check_interval = 5m
}
In this example the `this` scope refers to the "localhost" object. The `check_interval` attribute
You can explicitly access the `this` scope using the `this` keyword:
object Host "localhost" {
- var check_interval = 5m
+ var check_interval = 5m
/* This explicitly specifies that the attribute should be set
* for the host, if we had omitted `this.` the (poorly named)
a function is set to whichever object was used to invoke the function. Here's an example:
hm = {
- h_word = null
-
- function init(word) {
- h_word = word
- }
- }
-
- /* Let's invoke the init() function */
- hm.init("hello")
+ h_word = null
+
+ function init(word) {
+ h_word = word
+ }
+ }
+
+ /* Let's invoke the init() function */
+ hm.init("hello")
We're using `hm.init` to invoke the function which causes the value of `hm` to become the `this`
scope for this function call.
+## <a id="closures"></a> Closures
+
+By default `function`s, `object`s and `apply` rules do not have access to variables declared
+outside of their scope (except for global variables).
+
+In order to access variables which are defined in the outer scope the `use` keyword can be used:
+
+ function MakeHelloFunction(name) {
+ return function() use(name) {
+ log("Hello, " + name)
+ }
+ }
+
+In this case a new variable `name` is created inside the inner function's scope which has the
+value of the `name` function argument.
+
+Alternatively a different value for the inner variable can be specified:
+
+ function MakeHelloFunction(name) {
+ return function() use (greeting = "Hello, " + name) {
+ log(greeting)
+ }
+ }
+
## <a id="conditional-statements"></a> Conditional Statements
Sometimes it can be desirable to only evaluate statements when certain conditions are met. The if/else
is the value of the last statement which was evaluated for the branch which was taken:
a = if (true) {
- log("Taking the 'true' branch")
- 7 * 3
- } else {
- log("Taking the 'false' branch")
- 9
- }
+ log("Taking the 'true' branch")
+ 7 * 3
+ } else {
+ log("Taking the 'false' branch")
+ 9
+ }
This example prints the log message "Taking the 'true' branch" and the `a` variable is set to 21 (7 * 3).
Example:
var list = [ "a", "b", "c" ]
-
- for (item in list) {
- log("Item: " + item)
- }
+
+ for (item in list) {
+ log("Item: " + item)
+ }
The loop body is evaluated once for each item in the array. The variable `item` is declared as a local
variable just as if the `var` keyword had been used.
Iterating over dictionaries can be accomplished in a similar manner:
var dict = { a = 3, b = 7 }
-
- for (key => value in dict) {
- log("Key: " + key + ", Value: " + value)
+
+ for (key => value in dict) {
+ log("Key: " + key + ", Value: " + value)
}
The `continue` and `break` keywords can be used to control how the loop is executed: The `continue` keyword
The type object's `prototype` property can be used to find out which methods a certain type
supports:
- /* This returns: ["find","len","lower","replace","split","substr","to_string","upper"] */
+ /* This returns: ["find","len","lower","replace","split","substr","to_string","upper"] */
keys(String.prototype)
## <a id="reserved-keywords"></a> Reserved Keywords