1 # Language Reference <a id="language-reference"></a>
3 ## Object Definition <a id="object-definition"></a>
5 Icinga 2 features an object-based configuration format. You can define new
6 objects using the `object` keyword:
8 object Host "host1.example.org" {
11 address = "192.168.0.1"
15 In general you need to write each statement on a new line. Expressions started
16 with `{`, `(` and `[` extend until the matching closing character and can be broken
17 up into multiple lines.
19 Alternatively you can write multiple statements on a single line by separating
20 them with a semicolon:
22 object Host "host1.example.org" {
23 display_name = "host1"
25 address = "192.168.0.1"; address6 = "::1"
28 Each object is uniquely identified by its type (`Host`) and name
29 (`host1.example.org`). Some types have composite names, e.g. the
30 `Service` type which uses the `host_name` attribute and the name
31 you specified to generate its object name.
33 Exclamation marks (!) are not permitted in object names.
35 Objects can contain a comma-separated list of property
36 declarations. Instead of commas semicolons may also be used.
37 The following data types are available for property values:
39 All objects have at least the following attributes:
41 Attribute | Description
42 ---------------------|-----------------------------
43 name | The name of the object. This attribute can be modified in the object definition to override the name specified with the `object` directive.
44 type | The type of the object.
46 ## Expressions <a id="expressions"></a>
48 The following expressions can be used on the right-hand side of assignments.
50 ### Numeric Literals <a id="numeric-literals"></a>
52 A floating-point number.
58 ### Duration Literals <a id="duration-literals"></a>
60 Similar to floating-point numbers except for the fact that they support
61 suffixes to help with specifying time durations.
67 Supported suffixes include ms (milliseconds), s (seconds), m (minutes),
68 h (hours) and d (days).
70 Duration literals are converted to seconds by the config parser and
71 are treated like numeric literals.
73 ### String Literals <a id="string-literals"></a>
81 #### String Literals Escape Sequences <a id="string-literals-escape-sequences"></a>
83 Certain characters need to be escaped. The following escape sequences
86 Character | Escape sequence
87 --------------------------|------------------------------------
91 <CARRIAGE-RETURN> | \\r
92 <LINE-FEED> | \\n
94 <FORM-FEED> | \\f
96 In addition to these pre-defined escape sequences you can specify
97 arbitrary ASCII characters using the backslash character (\\) followed
98 by an ASCII character in octal encoding.
100 ### Multi-line String Literals <a id="multiline-string-literals"></a>
102 Strings spanning multiple lines can be specified by enclosing them in
112 Unlike in ordinary strings special characters do not have to be escaped
113 in multi-line string literals.
115 ### Boolean Literals <a id="boolean-literals"></a>
117 The keywords `true` and `false` are used to denote truth values.
119 ### Null Value <a id="null-value"></a>
121 The `null` keyword can be used to specify an empty value.
123 ### Dictionary <a id="dictionary"></a>
125 An unordered list of key-value pairs. Keys must be unique and are
126 compared in a case-sensitive manner.
128 Individual key-value pairs must either be comma-separated or on separate lines.
129 The comma after the last key-value pair is optional.
134 address = "192.168.0.1"
138 Identifiers may not contain certain characters (e.g. space) or start
139 with certain characters (e.g. digits). If you want to use a dictionary
140 key that is not a valid identifier, you can enclose the key in double
143 ### Array <a id="array"></a>
145 An ordered list of values.
147 Individual array elements must be comma-separated.
148 The comma after the last element is optional.
154 An array may simultaneously contain values of different types, such as
157 ### Operators <a id="expression-operators"></a>
159 The following operators are supported in expressions. The operators are by descending precedence.
161 Operator | Precedence | Examples (Result) | Description
162 ---------|------------|-----------------------------------------------|--------------------------------
163 () | 1 | (3 + 3) * 5 | Groups sub-expressions
164 () | 1 | Math.random() | Calls a function
165 [] | 1 | a[3] | Array subscript
166 . | 1 | a.b | Element access
167 ! | 2 | !"Hello" (false), !false (true) | Logical negation of the operand
168 ~ | 2 | ~true (false) | Bitwise negation of the operand
169 + | 2 | +3 | Unary plus
170 - | 2 | -3 | Unary minus
171 * | 3 | 5m * 10 (3000) | Multiplies two numbers
172 / | 3 | 5m / 5 (60) | Divides two numbers
173 % | 3 | 17 % 12 (5) | Remainder after division
174 + | 4 | 1 + 3 (4), "hello " + "world" ("hello world") | Adds two numbers; concatenates strings
175 - | 4 | 3 - 1 (2) | Subtracts two numbers
176 << | 5 | 4 << 8 (1024) | Left shift
177 >> | 5 | 1024 >> 4 (64) | Right shift
178 < | 6 | 3 < 5 (true) | Less than
179 > | 6 | 3 > 5 (false) | Greater than
180 <= | 6 | 3 <= 3 (true) | Less than or equal
181 >= | 6 | 3 >= 3 (true) | Greater than or equal
182 in | 7 | "foo" in [ "foo", "bar" ] (true) | Element contained in array
183 !in | 7 | "foo" !in [ "bar", "baz" ] (true) | Element not contained in array
184 == | 8 | "hello" == "hello" (true), 3 == 5 (false) | Equal to
185 != | 8 | "hello" != "world" (true), 3 != 3 (false) | Not equal to
186 & | 9 | 7 & 3 (3) | Binary AND
187 ^ | 10 | 17 ^ 12 (29) | Bitwise XOR
188 | | 11 | 2 | 3 (3) | Binary OR
189 && | 13 | true && false (false), 3 && 7 (7), 0 && 7 (0) | Logical AND
190 || | 14 | true || false (true), 0 || 7 (7)| Logical OR
191 = | 12 | a = 3 | Assignment
192 => | 15 | x => x * x (function with arg x) | Lambda, for loop
194 ### Function Calls <a id="function-calls"></a>
196 Functions can be called using the `()` operator:
198 const MyGroups = [ "test1", "test" ]
201 check_interval = len(MyGroups) * 1m
204 A list of available functions is available in the [Library Reference](18-library-reference.md#library-reference) chapter.
206 ## Assignments <a id="dictionary-operators"></a>
208 In addition to the `=` operator shown above a number of other operators
209 to manipulate attributes are supported. Here's a list of all
212 ### Operator = <a id="operator-assignment"></a>
214 Sets an attribute to the specified value.
223 In this example `a` has the value `7` after both instructions are executed.
225 ### Operator += <a id="operator-additive-assignment"></a>
227 The += operator is a shortcut. The following expression:
241 ### Operator -= <a id="operator-substractive-assignment"></a>
243 The -= operator is a shortcut. The following expression:
257 ### Operator \*= <a id="operator-multiply-assignment"></a>
259 The *= operator is a shortcut. The following expression:
273 ### Operator /= <a id="operator-dividing-assignment"></a>
275 The /= operator is a shortcut. The following expression:
289 ## Indexer <a id="indexer"></a>
291 The indexer syntax provides a convenient way to set dictionary elements.
299 Example (alternative syntax):
302 hello["key"] = "world"
305 This is equivalent to writing:
313 If the `hello` attribute does not already have a value, it is automatically initialized to an empty dictionary.
315 ## Template Imports <a id="template-imports"></a>
317 Objects can import attributes from other objects.
321 template Host "default-host" {
325 template Host "test-host" {
326 import "default-host"
331 object Host "localhost" {
334 address = "127.0.0.1"
338 The `default-host` and `test-host` objects are marked as templates
339 using the `template` keyword. Unlike ordinary objects templates are not
340 instantiated at run-time. Parent objects do not necessarily have to be
341 templates, however in general they are.
343 The `vars` dictionary for the `localhost` object contains all three
344 custom attributes and the custom attribute `colour` has the value `"blue"`.
346 Parent objects are resolved in the order they're specified using the
349 Default templates which are automatically imported into all object definitions
350 can be specified using the `default` keyword:
352 template CheckCommand "plugin-check-command" default {
356 Default templates are imported before any other user-specified statement in an
357 object definition is evaluated.
359 If there are multiple default templates the order in which they are imported
362 ## Constants <a id="constants"></a>
364 Global constants can be set using the `const` keyword:
366 const VarName = "some value"
368 Once defined a constant can be accessed from any file. Constants cannot be changed
373 > Best practice is to manage constants in the [constants.conf](04-configuring-icinga-2.md#constants-conf) file.
375 ### Icinga 2 Specific Constants <a id="icinga-constants"></a>
377 Icinga 2 provides a number of special global constants. Some of them can be overridden using the `--define` command line parameter:
379 Variable |Description
380 --------------------|-------------------
381 PrefixDir |**Read-only.** Contains the installation prefix that was specified with cmake -DCMAKE_INSTALL_PREFIX. Defaults to "/usr/local".
382 SysconfDir |**Read-only.** Contains the path of the sysconf directory. Defaults to PrefixDir + "/etc".
383 ZonesDir |**Read-only.** Contains the path of the zones.d directory. Defaults to SysconfDir + "/zones.d".
384 LocalStateDir |**Read-only.** Contains the path of the local state directory. Defaults to PrefixDir + "/var".
385 RunDir |**Read-only.** Contains the path of the run directory. Defaults to LocalStateDir + "/run".
386 PkgDataDir |**Read-only.** Contains the path of the package data directory. Defaults to PrefixDir + "/share/icinga2".
387 StatePath |**Read-write.** Contains the path of the Icinga 2 state file. Defaults to LocalStateDir + "/lib/icinga2/icinga2.state".
388 ObjectsPath |**Read-write.** Contains the path of the Icinga 2 objects file. Defaults to LocalStateDir + "/cache/icinga2/icinga2.debug".
389 PidPath |**Read-write.** Contains the path of the Icinga 2 PID file. Defaults to RunDir + "/icinga2/icinga2.pid".
390 Vars |**Read-write.** Contains a dictionary with global custom attributes. Not set by default.
391 NodeName |**Read-write.** Contains the cluster node name. Set to the local hostname by default.
392 RunAsUser |**Read-write.** Defines the user the Icinga 2 daemon is running as. Used in the `init.conf` configuration file.
393 RunAsGroup |**Read-write.** Defines the group the Icinga 2 daemon is running as. Used in the `init.conf` configuration file.
394 PlatformName |**Read-only.** The name of the operating system, e.g. "Ubuntu".
395 PlatformVersion |**Read-only.** The version of the operating system, e.g. "14.04.3 LTS".
396 PlatformKernel |**Read-only.** The name of the operating system kernel, e.g. "Linux".
397 PlatformKernelVersion|**Read-only.** The version of the operating system kernel, e.g. "3.13.0-63-generic".
398 BuildCompilerName |**Read-only.** The name of the compiler Icinga was built with, e.g. "Clang".
399 BuildCompilerVersion|**Read-only.** The version of the compiler Icinga was built with, e.g. "7.3.0.7030031".
400 BuildHostName |**Read-only.** The name of the host Icinga was built on, e.g. "acheron".
403 Advanced runtime constants. Please only use them if advised by support or developers.
405 Variable |Description
406 --------------------|-------------------
407 EventEngine |**Read-write.** The name of the socket event engine, can be `poll` or `epoll`. The epoll interface is only supported on Linux.
408 AttachDebugger |**Read-write.** Whether to attach a debugger when Icinga 2 crashes. Defaults to `false`.
409 RLimitFiles |**Read-write.** Defines the resource limit for RLIMIT_NOFILE that should be set at start-up. Value cannot be set lower than the default `16 * 1024`. 0 disables the setting. Used in the `init.conf` configuration file.
410 RLimitProcesses |**Read-write.** Defines the resource limit for RLIMIT_NPROC that should be set at start-up. Value cannot be set lower than the default `16 * 1024`. 0 disables the setting. Used in the `init.conf` configuration file.
411 RLimitStack |**Read-write.** Defines the resource limit for RLIMIT_STACK that should be set at start-up. Value cannot be set lower than the default `256 * 1024`. 0 disables the setting. Used in the `init.conf` configuration file.
413 ## Apply <a id="apply"></a>
415 The `apply` keyword can be used to create new objects which are associated with
416 another group of objects.
418 apply Service "ping" to Host {
419 import "generic-service"
421 check_command = "ping4"
423 assign where host.name == "localhost"
426 In this example the `assign where` condition is a boolean expression which is
427 evaluated for all objects of type `Host` and a new service with name "ping"
428 is created for each matching host. [Expression operators](17-language-reference.md#expression-operators)
429 may be used in `assign where` conditions.
431 The `to` keyword and the target type may be omitted if there is only one target
432 type, e.g. for the `Service` type.
434 Depending on the object type used in the `apply` expression additional local
435 variables may be available for use in the `where` condition:
437 Source Type | Target Type | Variables
438 ------------------|-------------|--------------
439 Service | Host | host
440 Dependency | Host | host
441 Dependency | Service | host, service
442 Notification | Host | host
443 Notification | Service | host, service
444 ScheduledDowntime | Host | host
445 ScheduledDowntime | Service | host, service
447 Any valid config attribute can be accessed using the `host` and `service`
448 variables. For example, `host.address` would return the value of the host's
449 "address" attribute -- or null if that attribute isn't set.
451 More usage examples are documented in the [monitoring basics](03-monitoring-basics.md#using-apply-expressions)
454 ## Apply For <a id="apply-for"></a>
456 [Apply](17-language-reference.md#apply) rules can be extended with the
457 [for loop](17-language-reference.md#for-loops) keyword.
459 apply Service "prefix-" for (key => value in host.vars.dictionary) to Host {
460 import "generic-service"
462 check_command = "ping4"
463 vars.host_value = value
467 Any valid config attribute can be accessed using the `host` and `service`
468 variables. The attribute must be of the Array or Dictionary type. In this example
469 `host.vars.dictionary` is of the Dictionary type which needs a key-value-pair
472 In this example all generated service object names consist of `prefix-` and
473 the value of the `key` iterator. The prefix string can be omitted if not required.
475 The `key` and `value` variables can be used for object attribute assignment, e.g. for
476 setting the `check_command` attribute or custom attributes as command parameters.
478 `apply for` rules are first evaluated against all objects matching the `for loop` list
479 and afterwards the `assign where` and `ignore where` conditions are evaluated.
481 It is not necessary to check attributes referenced in the `for loop` expression
482 for their existance using an additional `assign where` condition.
484 More usage examples are documented in the [monitoring basics](03-monitoring-basics.md#using-apply-for)
487 ## Group Assign <a id="group-assign"></a>
489 Group objects can be assigned to specific member objects using the `assign where`
490 and `ignore where` conditions.
492 object HostGroup "linux-servers" {
493 display_name = "Linux Servers"
495 assign where host.vars.os == "Linux"
498 In this example the `assign where` condition is a boolean expression which is evaluated
499 for all objects of the type `Host`. Each matching host is added as member to the host group
500 with the name "linux-servers". Membership exclusion can be controlled using the `ignore where`
501 condition. [Expression operators](17-language-reference.md#expression-operators) may be used in `assign where` and
502 `ignore where` conditions.
504 Source Type | Variables
505 ------------------|--------------
507 ServiceGroup | host, service
511 ## Boolean Values <a id="boolean-values"></a>
513 The `assign where`, `ignore where`, `if` and `while` statements, the `!` operator as
514 well as the `bool()` function convert their arguments to a boolean value based on the
517 Description | Example Value | Boolean Value
518 ---------------------|-------------------|--------------
519 Empty value | null | false
521 Non-zero integer | -23945 | true
522 Empty string | "" | false
523 Non-empty string | "Hello" | true
524 Empty array | [] | false
525 Non-empty array | [ "Hello" ] | true
526 Empty dictionary | {} | false
527 Non-empty dictionary | { key = "value" } | true
529 For a list of supported expression operators for `assign where` and `ignore where`
530 statements, see [expression operators](17-language-reference.md#expression-operators).
532 ## Comments <a id="comments"></a>
534 The Icinga 2 configuration format supports C/C++-style and shell-style comments.
541 object Host "localhost" {
542 check_interval = 30 // this is also a comment.
543 retry_interval = 15 # yet another comment
546 ## Includes <a id="includes"></a>
548 Other configuration files can be included using the `include` directive.
549 Paths must be relative to the configuration file that contains the
554 include "some/other/file.conf"
555 include "conf.d/*.conf"
557 Wildcard includes are not recursive.
559 Icinga also supports include search paths similar to how they work in a
564 Note the use of angle brackets instead of double quotes. This causes the
565 config compiler to search the include search paths for the specified
566 file. By default $PREFIX/share/icinga2/include is included in the list of search
567 paths. Additional include search paths can be added using
568 [command-line options](11-cli-commands.md#config-include-path).
570 Wildcards are not permitted when using angle brackets.
572 ## Recursive Includes <a id="recursive-includes"></a>
574 The `include_recursive` directive can be used to recursively include all
575 files in a directory which match a certain pattern.
579 include_recursive "conf.d", "*.conf"
580 include_recursive "templates"
582 The first parameter specifies the directory from which files should be
583 recursively included.
585 The file names need to match the pattern given in the second parameter.
586 When no pattern is specified the default pattern "*.conf" is used.
588 ## Zone Includes <a id="zone-includes"></a>
590 The `include_zones` recursively includes all subdirectories for the
593 In addition to that it sets the `zone` attribute for all objects created
594 in these subdirectories to the name of the subdirectory.
598 include_zones "etc", "zones.d", "*.conf"
599 include_zones "puppet", "puppet-zones"
601 The first parameter specifies a tag name for this directive. Each `include_zones`
602 invocation should use a unique tag name. When copying the zones' configuration
603 files Icinga uses the tag name as the name for the destination directory in
604 `/var/lib/icinga2/api/config`.
606 The second parameter specifies the directory which contains the subdirectories.
608 The file names need to match the pattern given in the third parameter.
609 When no pattern is specified the default pattern "*.conf" is used.
611 ## Library directive <a id="library"></a>
613 The `library` directive can be used to manually load additional
614 libraries. Libraries can be used to provide additional object types and
621 ## Functions <a id="functions"></a>
623 Functions can be defined using the `function` keyword.
627 function multiply(a, b) {
631 When encountering the `return` keyword further execution of the function is terminated and
632 the specified value is supplied to the caller of the function:
636 In this example the `multiply` function we declared earlier is invoked with two arguments (3 and 5).
637 The function computes the product of those arguments and makes the result available to the
640 When no value is supplied for the `return` statement the function returns `null`.
642 Functions which do not have a `return` statement have their return value set to the value of the
643 last expression which was performed by the function. For example, we could have also written our
644 `multiply` function like this:
646 function multiply(a, b) {
650 Anonymous functions can be created by omitting the name in the function definition. The
651 resulting function object can be used like any other value:
653 var fn = function() { 3 }
657 ## Lambda Expressions <a id="lambdas"></a>
659 Functions can also be declared using the alternative lambda syntax.
665 Multiple statements can be used by putting the function body into braces:
672 Just like with ordinary functions the return value is the value of the last statement.
674 For lambdas which take exactly one argument the braces around the arguments can be omitted:
678 ## Abbreviated Lambda Syntax <a id="nullary-lambdas"></a>
680 Lambdas which take no arguments can also be written using the abbreviated lambda syntax.
686 This creates a new function which returns the value 3.
688 ## Variable Scopes <a id="variable-scopes"></a>
690 When setting a variable Icinga checks the following scopes in this order whether the variable
691 already exists there:
697 The local scope contains variables which only exist during the invocation of the current function,
698 object or apply statement. Local variables can be declared using the `var` keyword:
700 function multiply(a, b) {
705 Each time the `multiply` function is invoked a new `temp` variable is used which is in no way
706 related to previous invocations of the function.
708 When setting a variable which has not previously been declared as local using the `var` keyword
709 the `this` scope is used.
711 The `this` scope refers to the current object which the function or object/apply statement
714 object Host "localhost" {
718 In this example the `this` scope refers to the "localhost" object. The `check_interval` attribute
719 is set for this particular host.
721 You can explicitly access the `this` scope using the `this` keyword:
723 object Host "localhost" {
724 var check_interval = 5m
726 /* This explicitly specifies that the attribute should be set
727 * for the host, if we had omitted `this.` the (poorly named)
728 * local variable `check_interval` would have been modified instead.
730 this.check_interval = 1m
733 Similarly the keywords `locals` and `globals` are available to access the local and global scope.
735 Functions also have a `this` scope. However unlike for object/apply statements the `this` scope for
736 a function is set to whichever object was used to invoke the function. Here's an example:
741 function init(word) {
746 /* Let's invoke the init() function */
749 We're using `hm.init` to invoke the function which causes the value of `hm` to become the `this`
750 scope for this function call.
752 ## Closures <a id="closures"></a>
754 By default `function`s, `object`s and `apply` rules do not have access to variables declared
755 outside of their scope (except for global variables).
757 In order to access variables which are defined in the outer scope the `use` keyword can be used:
759 function MakeHelloFunction(name) {
760 return function() use(name) {
761 log("Hello, " + name)
765 In this case a new variable `name` is created inside the inner function's scope which has the
766 value of the `name` function argument.
768 Alternatively a different value for the inner variable can be specified:
770 function MakeHelloFunction(name) {
771 return function() use (greeting = "Hello, " + name) {
776 ## Conditional Statements <a id="conditional-statements"></a>
778 Sometimes it can be desirable to only evaluate statements when certain conditions are met. The if/else
779 construct can be used to accomplish this.
793 An if/else construct can also be used in place of any other value. The value of an if/else statement
794 is the value of the last statement which was evaluated for the branch which was taken:
797 log("Taking the 'true' branch")
800 log("Taking the 'false' branch")
804 This example prints the log message "Taking the 'true' branch" and the `a` variable is set to 21 (7 * 3).
806 The value of an if/else construct is null if the condition evaluates to false and no else branch is given.
808 ## While Loops <a id="while-loops"></a>
810 The `while` statement checks a condition and executes the loop body when the condition evaluates to `true`.
811 This is repeated until the condition is no longer true.
822 The `continue` and `break` keywords can be used to control how the loop is executed: The `continue` keyword
823 skips over the remaining expressions for the loop body and begins the next loop evaluation. The `break` keyword
824 breaks out of the loop.
826 ## For Loops <a id="for-loops"></a>
828 The `for` statement can be used to iterate over arrays and dictionaries.
832 var list = [ "a", "b", "c" ]
838 The loop body is evaluated once for each item in the array. The variable `item` is declared as a local
839 variable just as if the `var` keyword had been used.
841 Iterating over dictionaries can be accomplished in a similar manner:
843 var dict = { a = 3, b = 7 }
845 for (key => value in dict) {
846 log("Key: " + key + ", Value: " + value)
849 The `continue` and `break` keywords can be used to control how the loop is executed: The `continue` keyword
850 skips over the remaining expressions for the loop body and begins the next loop evaluation. The `break` keyword
851 breaks out of the loop.
853 ## Constructors <a id="constructor"></a>
855 In order to create a new value of a specific type constructor calls may be used.
859 var pd = PerfdataValue()
863 You can also try to convert an existing value to another type by specifying it as an argument for the constructor call.
867 var s = String(3) /* Sets s to "3". */
869 ## Throwing Exceptions <a id="throw"></a>
871 Built-in commands may throw exceptions to signal errors such as invalid arguments. User scripts can throw exceptions
872 using the `throw` keyword.
876 throw "An error occurred."
878 ## Handling Exceptions <a id="try-except"></a>
880 Exceptions can be handled using the `try` and `except` keywords. When an exception occurs while executing code in the
881 `try` clause no further statements in the `try` clause are evaluated and the `except` clause is executed instead.
888 log("This statement won't get executed.")
890 log("An error occurred in the try clause.")
893 ## Breakpoints <a id="breakpoints"></a>
895 The `debugger` keyword can be used to insert a breakpoint. It may be used at any place where an assignment would also be a valid expression.
897 By default breakpoints have no effect unless Icinga is started with the `--script-debugger` command-line option. When the script debugger is enabled Icinga stops execution of the script when it encounters a breakpoint and spawns a console which lets the user inspect the current state of the execution environment.
899 ## Types <a id="types"></a>
901 All values have a static type. The `typeof` function can be used to determine the type of a value:
903 typeof(3) /* Returns an object which represents the type for numbers */
905 The following built-in types are available:
907 Type | Examples | Description
908 -----------|-------------------|------------------------
909 Number | 3.7 | A numerical value.
910 Boolean | true, false | A boolean value.
911 String | "hello" | A string.
912 Array | [ "a", "b" ] | An array.
913 Dictionary | { a = 3 } | A dictionary.
915 Depending on which libraries are loaded additional types may become available. The `icinga`
916 library implements a whole bunch of other [object types](09-object-types.md#object-types),
917 e.g. Host, Service, CheckCommand, etc.
919 Each type has an associated type object which describes the type's semantics. These
920 type objects are made available using global variables which match the type's name:
922 /* This logs 'true' */
923 log(typeof(3) == Number)
925 The type object's `prototype` property can be used to find out which methods a certain type
928 /* This returns: ["contains","find","len","lower","replace","reverse","split","substr","to_string","trim","upper"] */
929 keys(String.prototype)
931 Additional documentation on type methods is available in the
932 [library reference](18-library-reference.md#library-reference).
934 ## Location Information <a id="location-information"></a>
936 The location of the currently executing script can be obtained using the
937 `current_filename` and `current_line` keywords.
941 log("Hello from '" + current_filename + "' in line " + current_line)
943 ## Reserved Keywords <a id="reserved-keywords"></a>
945 These keywords are reserved and must not be used as constants or custom attributes.
985 You can escape reserved keywords using the `@` character. The following example
986 tries to set `vars.include` which references a reserved keyword and generates
989 [2014-09-15 17:24:00 +0200] critical/config: Location:
990 /etc/icinga2/conf.d/hosts/localhost.conf(13): vars.sla = "24x7"
991 /etc/icinga2/conf.d/hosts/localhost.conf(14):
992 /etc/icinga2/conf.d/hosts/localhost.conf(15): vars.include = "some cmdb export field"
994 /etc/icinga2/conf.d/hosts/localhost.conf(16): }
995 /etc/icinga2/conf.d/hosts/localhost.conf(17):
997 Config error: in /etc/icinga2/conf.d/hosts/localhost.conf: 15:8-15:14: syntax error, unexpected include (T_INCLUDE), expecting T_IDENTIFIER
998 [2014-09-15 17:24:00 +0200] critical/config: 1 errors, 0 warnings.
1000 You can escape the `include` keyword by prefixing it with an additional `@` character:
1002 object Host "localhost" {
1003 import "generic-host"
1005 address = "127.0.0.1"
1011 vars.@include = "some cmdb export field"