mirror of https://github.com/Icinga/icinga2.git
Enhance Monitoring Basics in the documentation
This commit adds documentation for * custom attributes value types and nested dictionaries * better introduction into apply rules and usage examples * better apply for iterations and explanations * notifications with users on the host/service objects explained in a dedicated chapter * command arguments and set_if - which values are supported * macro() as scoped function * alternative host check command This also changes all code and config snippets to use three backticks instead of four spaces indent. fixes #5663 fixes #5664 fixes #5665 fixes #5666 fixes #5667 fixes #5186 fixes #5060 fixes #5662
This commit is contained in:
parent
fc098ead59
commit
1da5c53fee
File diff suppressed because it is too large
Load Diff
|
@ -403,6 +403,8 @@ apply Service "external-check" {
|
|||
}
|
||||
```
|
||||
|
||||
References: [get_service](18-library-reference.md#objref-get_service), [nacro](18-library-reference.md#scoped-functions-macro), [DateTime](18-library-reference.md#datetime-type).
|
||||
|
||||
Example output in Icinga Web 2:
|
||||
|
||||
![Icinga 2 Freshness Checks](images/advanced-topics/icinga2_external_checks_freshness_icingaweb2.png)
|
||||
|
|
|
@ -368,6 +368,10 @@ Global constants can be set using the `const` keyword:
|
|||
Once defined a constant can be accessed from any file. Constants cannot be changed
|
||||
once they are set.
|
||||
|
||||
> **Tip**
|
||||
>
|
||||
> Best practice is to manage constants in the [constants.conf](04-configuring-icinga-2.md#constants-conf) file.
|
||||
|
||||
### Icinga 2 Specific Constants <a id="icinga-constants"></a>
|
||||
|
||||
Icinga 2 provides a number of special global constants. Some of them can be overridden using the `--define` command line parameter:
|
||||
|
|
|
@ -564,6 +564,48 @@ Signature:
|
|||
|
||||
Sleeps for the specified amount of time (in seconds).
|
||||
|
||||
|
||||
## Scoped Functions <a id="scoped-functions"></a>
|
||||
|
||||
This chapter describes functions which are only available
|
||||
in a specific scope.
|
||||
|
||||
### macro <a id="scoped-functions-macro"></a>
|
||||
|
||||
Signature:
|
||||
|
||||
```
|
||||
function macro("$macro_name$")
|
||||
```
|
||||
|
||||
The `macro` function can be used to resolve [runtime macro](03-monitoring-basics.md#runtime-macros)
|
||||
strings into their values.
|
||||
The returned value depends on the attribute value which is resolved
|
||||
from the specified runtime macro.
|
||||
|
||||
This function is only available in runtime evaluated functions, e.g.
|
||||
for [custom attributes](03-monitoring-basics.md#custom-attributes-functions) which
|
||||
use the [abbreviated lambda syntax](17-language-reference.md#nullary-lambdas).
|
||||
|
||||
This example sets the `snmp_address` custom attribute
|
||||
based on `$address$` and `$address6`.
|
||||
|
||||
```
|
||||
vars.snmp_address = {{
|
||||
var addr_v4 = macro("$address$")
|
||||
var addr_v6 = macro("$address6$")
|
||||
|
||||
if (addr_v4) {
|
||||
return addr_v4
|
||||
} else {
|
||||
return "udp6:[" + addr_v6 + "]"
|
||||
}
|
||||
}}
|
||||
```
|
||||
|
||||
More reference examples are available inside the [Icinga Template Library](10-icinga-template-library.md#icinga-template-library)
|
||||
and the [object accessors chapter](08-advanced-topics.md#access-object-attributes-at-runtime).
|
||||
|
||||
## Object Accessor Functions <a id="object-accessor-functions"></a>
|
||||
|
||||
These functions can be used to retrieve a reference to another object by name.
|
||||
|
|
Loading…
Reference in New Issue