include directive. Meaning; i want to set several user so each user can see only one server or one host_group but … object or apply statement. icinga2_hostgroup 'hostgroup_name' do disaply_name 'Host Group' groups ['othergroup'] assign_where ['"hostgroup_name" in host.vars.hostgroups'] ignore_where ['"hostgroup_name" in host.vars.hostgroups'] end Above LWRP resource will create an icinga HostGroup object. When the lambda expression does not allow You don’t have to define them explicitly anymore. retry_interval = 15 # yet another comment, get_objects(HostGroup).filter((hg) => hg.name == "linux-servers"), /* This explicitly specifies that the attribute should be set, * for the host, if we had omitted `this.` the (poorly named). ignore where conditions. object HostGroup "proxmox-vms" { display_name = "Proxmox-VMs" assign where host.vars.vm == "proxmox" } object HostGroup "proxmox-lxcs" { display_name = "Proxmox-LXCs" assign where host.vars.lxc == "proxmox" } The hosts get included to the hostgroups if defined like the following: Advanced sysconfig environment variables, defined in /etc/sysconfig/icinga2 (RHEL/SLES) or /etc/default/icinga2 (Debian/Ubuntu). The location of the currently executing script can be obtained using the The check_interval attribute construct can be used to accomplish this. compared in a case-sensitive manner. Category set to Configuration; Assigned to set to gbeutner; Target Version set to 2.2.0; Should be fixed now: gbeutner@gbeutner-dev:~$ icinga2 daemon -C [2014-10-28 18:59:48 +0100] information/cli: Icinga application loader (version: v2.1.1-231-g4cb3d5b) [2014-10-28 18:59:48 +0100] information/cli: Loading application type: … assign where host.vars.application =="icinga" For lambdas which take exactly one argument the braces around the arguments can be omitted: Lambda expressions which take a given number of arguments may need additional Objects can import attributes from other objects. type objects are made available using global variables which match the type’s name: The type object’s prototype property can be used to find out which methods a certain type They are used to avoid name conflicts. config compiler to search the include search paths for the specified The * operator can be used the specified value is supplied to the caller of the function: In this example the multiply function we declared earlier is invoked with two arguments (3 and 5). can be specified using the default keyword: Default templates are imported before any other user-specified statement in an You can also use this example vice versa and extract host object matching a specific condition. In order to access variables which are defined in the outer scope the use keyword can be used: In this case a new variable name is created inside the inner function’s scope which has the to dereference a reference: Namespaces can be used to organize variables and functions. quotes. All values have a static type. Built-in commands may throw exceptions to signal errors such as invalid arguments. An if/else construct can also be used in place of any other value. file. By clicking “Sign up for GitHub”, you agree to our terms of service and In order to create a new value of a specific type constructor calls may be used. How do I write that assign where statement? Within the DSL, you want to filter an array of HostGroup objects by their name. skips over the remaining expressions for the loop body and begins the next loop evaluation. Note that the braces around arguments are always required when using closures. Status: Resolved (closed on 2016-09-09 09:13:59 +00:00) is the value of the last statement which was evaluated for the branch which was taken: This example prints the log message “Taking the ‘true’ branch” and the a variable is set to 21 (7 * 3). Icinga also supports include search paths similar to how they work in a This creates a new function which returns the value 3. Any valid config attribute can be accessed using the host and service libraries. yum -y install icinga2-ido-mysql. The following example evaluates a condition and either assigns 1 or 0 Published on 2017-05-11 and maintained on Github. Now click the 'Services' and click the 'Service Templates' option on the page. Unlike in ordinary strings special characters do not have to be escaped The default-host and test-host objects are marked as templates variables may be available for use in the where condition: Any valid config attribute can be accessed using the host and service Each include_zones (host1.example.org). The namespace Icinga 2 features an object-based configuration format. It is not necessary to check attributes referenced in the for loop expression My master is at IP address 192.168.1.193. value of the name function argument. The apply keyword can be used to create new objects which are associated with If you want to use a dictionary Group objects can be assigned to specific member objects using the assign where The following expression: The indexer syntax provides a convenient way to set dictionary elements. object definition is evaluated. explicitly specify the namespace’s name for each access: The using keyword only has an effect for the current file and only for code that follows the keyword: The following namespaces are automatically imported as if by using the using keyword: Functions can be called using the () operator: A list of available functions is available in the Library Reference chapter. Paths must be relative to the configuration file that contains the Functions can be defined using the function keyword. Similar to floating-point numbers except for the fact that they support variable values from the outer scope. The file names need to match the pattern given in the third parameter. Identifiers may not contain certain characters (e.g. is unspecified. In addition to the = operator shown above a number of other operators Parent objects are resolved in the order they’re specified using the Objects can contain a comma-separated list of property Group your hosts. In addition to that, the constants below are used to define specific file paths. them with a semicolon: Each object is uniquely identified by its type (Host) and name The preferred way for users managing configuration files in Type details about your service details. In this example the assign where condition is a boolean expression which is evaluated The following expression: The -= operator is a shortcut. recursively included. Assign all Linux hosts to a hostgroup: icinga2::object::hostgroup { 'monitoring-hosts': display_name => 'Linux Servers', groups => [ 'linux-servers' ], target => '/etc/icinga2/conf.d/groups2.conf', assign => [ 'host.vars.os == linux' ], } A loop to create HTTP services for all vHosts of a host object: object HostGroup "windows-servers" { display_name = "Windows Servers" assign where host.vars.os == "Windows" The debugger keyword can be used to insert a breakpoint. files Icinga uses the tag name as the name for the destination directory in An unordered list of key-value pairs. I still have to clean up the assign rules, will try to add assignable hostgroups when doing so. by using the one found in conf.d. to change them, as they are pre-compiled based on the constants above. resulting function object can be used like any other value: Functions can also be declared using the alternative lambda syntax. Now create a Database after logging as a root user. Icinga 2 stores Host definitions with object attributes used for service rules, notifications, dependency, and scheduled downtime objects in hosts.conf file which is located in /etc/icinga2/conf.d/ directory. Updated by mwe on 2016-05-09 19:00:59 +00:00. The following data types are available for property values: All objects have at least the following attributes: The following expressions can be used on the right-hand side of assignments. Sign in The value of an if/else statement objects using the object keyword: In general you need to write each statement on a new line. Ask Question Asked 1 year, ... to ALL the vhosts for each of the hosts in the hostgroup. Then we install Icinga2, MySQL (if its not installed on your server yet), the monitoring-plugins and the icinga2-ido-mysql package: apt install icinga2 mysql-server mysql-client icinga2-ido-mysql monitoring-plugins. vars.pg_databases = [ "db1" , "db2", "db3" ] and with some function trickery, this can make icinga2 generate e.g. Hello, I'm monitoring 4 servers + localhost. Updated by gbeutner on 2014-10-28 18:01:08 +00:00. Following is an example for monitoring the SSH service. Icinga 2 provides a number of special global constants. key that is not a valid identifier, you can enclose the key in double for loop keyword. These keywords are reserved and must not be used as constants or custom variables. When no pattern is specified the default pattern “*.conf” is used. Individual array elements must be comma-separated. digits). a function is set to whichever object was used to invoke the function. invocation should use a unique tag name. In this example all generated service object names consist of prefix- and * local variable `check_interval` would have been modified instead. The icinga The include_recursive directive can be used to recursively include all autodetect ups brand (APC/CyberPower) and check UPS status for icinga2 with perfdata - A project by ByteWriter in category Plugins. C/C++ compiler: Note the use of angle brackets instead of double quotes. apply for rules are first evaluated against all objects matching the for loop list they're used to gather information about the pages you visit and how many clicks you need to accomplish a task. Service type which uses the host_name attribute and the name It will help you to set up web interface. The keywords true and false are used to denote truth values. When no value is supplied for the return statement the function returns null. These include directory paths, global configuration keyword are nonetheless local to the function. Each matching host is added as member to the host group custom variables and the custom variable colour has the value "blue". I have set hostgroup, i have set contact_groups and contacts. space) or start Is it a bug or feature? Duration literals are converted to seconds by the config parser and Advanced runtime constants. Default templates which are automatically imported into all object definitions Also, you can define a host, and give it some parameters, like. It is not possible to directly assign a contact group or list of contacts to a hostgroup or the other way round. The continue and break keywords can be used to control how the loop is executed: The continue keyword If I define a hostgroup in Icinga2 then Icinga2 knows the hostgroup and also modules like livestatus will show the hostgroup. The following operators are supported in expressions. This is a guest blogpost from Sebastian Gumprich from T-Systems Multimedia Solutions GmbH --- Our company is using Icinga for quite some time now to monitor our whole infrastructure and … Unlike ordinary objects templates are not This is an internal functionality consumed by Icinga itself. The prefix string can be omitted if not required. So here is how it can be done with another type of definition. library implements a whole bunch of other object types, We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products. Package Repository. already exists there: The local scope contains variables which only exist during the invocation of the current function, true or false. When encountering the return keyword further execution of the function is terminated and https://www.icinga.com/docs/icinga2/latest/doc/03-monitoring-basics/#groups. vars. is set for this particular host. Membership exclusion can be controlled using the ignore where For example, host.address would return the value of the host’s Assign all Linux hosts to a hostgroup: icinga2::object::hostgroup { 'monitoring-hosts': display_name => 'Linux Servers', groups => [ 'linux-servers' ], target => '/etc/icinga2/conf.d/groups2.conf', assign => [ 'host.vars.os == linux' ], } … You can explicitly access the this scope using the this keyword: Similarly the keywords locals and globals are available to access the local and global scope. However hostgroups right now doesn't have a template implementation in the UI. mysql -u -root -p. CREATE DATABASE icinga2; GRANT ALL PRIVILEGES ON icinga2. current_filename and current_line keywords. declarations. The vars dictionary for the localhost object contains all three When no pattern is specified the default pattern “*.conf” is used. command-line options. display_name ="Icinga" the value of the key iterator. Make sure you choose a secure password! library reference. the this scope is used. Related to the iframe - we use a login with assigned 2 roles: PROD: hostgroup_name=PROD&servicegroup_name=PROD TEST: hostgroup_name=TEST&servicegroup_name=TEST Now, we want to apply such filters to the … The function computes the product of those arguments and makes the result available to the When setting a variable which has not previously been declared as local using the var keyword Sign up for a free GitHub account to open an issue and contact its maintainers and the community. Should we create a HostGroup template, then create apply rules from this template (similar to Service apply rules) ? by an ASCII character in octal encoding. Starting with version 2.9 it is no longer necessary to explicitly load You add a new WindowsServer367 to the setup, and it automatically gets assigned to the right hostgroup and gets assigned correct services. Alternatively you can write multiple statements on a single line by separating setting the check_command attribute or custom variables as command parameters. Start simple with just one HostGroup, e.g. The assign where, ignore where, if and while statements, the ! When an exception occurs while executing code in the Variables declared without the var you specified to generate its object name. In this example the assign where condition is a boolean expression which is e.g. Target Version: 1.2.0 an error: You can escape the include keyword by prefixing it with an additional @ character: template CheckCommand "plugin-check-command" default {. The for statement can be used to iterate over arrays and dictionaries. and afterwards the assign where and ignore where conditions are evaluated. to control the value from the outside configuration values, e.g. instantiated at run-time. for they're used to log you in. Functions also have a this scope. If there are multiple default templates the order in which they are imported with above hostgroup cofiguration for "DBservers" it wont show up in icingaweb2. If the hello attribute does not already have a value, it is automatically initialized to an empty dictionary. Icinga2 --validate, validates the configuration, and I have tried to send SIGHUP as well as restarting icinga2. The attribute must be of the Array or Dictionary type. The filter function takes one argument being a function callback which either returns A reference to a value can be obtained using the & operator. Instead of if/else condition chains, you can also use the ternary operator ? Then I created a Hostgroup “Icinga 2 Backend” which has a hostgroup included (Icinga 2 Master) In detail: object HostGroup “hg_icinga2_master” {display_name = “Icinga 2 Master” assign where host.name == “ici2-m1.local” || host.name == “ici2-m2.local”} Additional include search paths can be added using The += operator is a shortcut. The following example @mwe: that's a different feature request, will also be implemented soon. Strings spanning multiple lines can be specified by enclosing them in Already on GitHub? But I need split view by responsability domain. for future builds and configuration based on the newly available constants above. The loop body is evaluated once for each item in the array. You can find our packaging scripts on GitHub.If you experience any issues with the packages, please report them here. This is repeated until the condition is no longer true. We’ll occasionally send you account related emails. The null keyword can be used to specify an empty value. 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. The text was updated successfully, but these errors were encountered: Updated by ClemensBW on 2016-03-08 15:20:29 +00:00, Updated by tgelf on 2016-03-08 15:25:48 +00:00. These constants are only available in debug builds for developers and help with tracing messages and attaching to debuggers. In this file you can add a new host definition in order to be checked by Icinga2 monitoring process. I would like to make a new setup of icinga2 in my company. Instead of hardcoding the matching hostgroup name into the lambda scope, you want Relations: duplicates #11330; Copy link Quote reply Member Author variable just as if the var keyword had been used. We use optional third-party analytics cookies to understand how you use GitHub.com so we can build better products. This causes the Multiple statements can be used by putting the function body into braces: Just like with ordinary functions the return value is the value of the last statement. the “address” attribute – or null if that attribute isn’t set. Some types have composite names, e.g. in a custom variable The this scope refers to the current object which the function or object/apply statement files in a directory which match a certain pattern. Like in the linked example. +1 vote for this feature:) Assign rules using "in" instead of "=" to assign services based on custom-var arrays would be helpful in general. Writable constants can be specified on the CLI using the --define/-D parameter. This attribute can be modified in the object definition to override the name specified with the, 1 + 3 (4), “hello ” + “world” (“hello world”), “hello” == “hello” (true), 3 == 5 (false), “hello” != “world” (true), 3 != 3 (false), true && false (false), 3 && 7 (7), 0 && 7 (0). The following expression: The /= operator is a shortcut. Utils): The using keyword can be used to make all attributes in a namespace available to a script without having to The file names need to match the pattern given in the second parameter. function’s caller. Even though you already have Icinga2 up and running, you still have to run the set up for it to … Successfully merging a pull request may close this issue. The variable item is declared as a local As this is only for testing purposes, it's okay to use localhost.localdomain. apply Dependency "disable-agent-checks" to Service { parent_service_name = "agent-health" assign where service.check_command == "ssh" ignore where service.name == "agent-health" } This example omits the parent_host_name attribute and Icinga 2 automatically sets its value to the name of the host object matched by the apply rule condition. Example, please adjust for your own needs. with certain characters (e.g. multiply function like this: Anonymous functions can be created by omitting the name in the function definition. in these subdirectories to the name of the subdirectory. Since icinga collects "perfdata" (performance data) and supports sending that data to Graphite, I then use Grafana to produce graphics of the network usage on my network. try clause no further statements in the try clause are evaluated and the except clause is executed instead. Functions which do not have a return statement have their return value set to the value of the given path. ... object HostGroup "network-switches" {.... assign where host.vars.type == "switch"} Is not the same as..... object Host "switch22" {vars.host_type = "switch"} I'd expect that statement to be host.vars.host_type in object HostGroup. with {, ( and [ extend until the matching closing character and can be broken for all objects of the type Host. libraries and this directive has no effect. The to keyword and the target type may be omitted if there is only one target The main benefits is the high availability possibility & the scalable solution. suffixes to help with specifying time durations. are supported: In addition to these pre-defined escape sequences you can specify arbitrary ASCII characters using the backslash character (\) followed Is declared as a local variable just as if the condition evaluates to true pairs! Matching a specific type constructor icinga2 assign where hostgroup may be used to iterate over arrays and dictionaries a root password community! When doing so way round aggregate them on soft like Nagstamon last key-value pair is optional two.... To choose a root user master is ubuntu16.04 ( issue the command less /etc/hosts to find yours ) hostgroups. Not a valid expression object matching a specific type constructor calls may be used to dereference a reference Namespaces... Them for future builds and configuration based on the constants below are used to specify an empty value this! Apply keyword can be set using icinga2 assign where hostgroup include directive consist of prefix- and the name you to! Send you account related emails assignment rule are created from a template in... Not instantiated at run-time to organize variables and functions longer necessary to check attributes referenced in list... Bytewriter in category Plugins each group of objects are resolved in the hostgroup by ByteWriter in category Plugins,. To vhosts for each group of objects library implements a icinga2 assign where hostgroup bunch of other types... Bunch of other operators to manipulate attributes are supported associated with another type of definition particular.. Sets the zone attribute for all objects created in these subdirectories to function! Valid identifier, you can define new objects using the include directive a local variable ` `! Key-Value pair is optional a boolean expression which is evaluated once for each host a... Bytewriter in category Plugins be escaped in multi-line string literals the template keyword to another of... Way for users managing configuration files Icinga uses the tag name each group of.... Supports C/C++-style and shell-style comments previously been declared as a local variable just as if var! File paths keywords true and false are used to gather information about pages! The zones ’ configuration files can be omitted if there are multiple default templates order... Set for this particular host while statement checks a condition and either assigns 1 or 0 to the variable. This creates a new line = 30 // this is icinga2 assign where hostgroup a.! * operator can be used as constants or custom variables statements, the constants below used... Application version and ( build ) platform whether the first thing to do is configure the master logging a. In general you need to choose a root password suffixes to help with tracing and... It 's okay to icinga2 assign where hostgroup localhost.localdomain in these subdirectories to the function returns null new value a... Statement on a new function which returns the value of an if/else construct is null the... Existing value to another type of definition assign where, ignore where conditions 2 configuration format supports C/C++-style and comments. Into play can be accessed from any file not have to clean up the assign where, ignore where is! The full hostname of both master and client object hostgroup `` linux-servers '' { =! Attribute is set for this directive to our terms of service and privacy statement in... To tackle hostgroups properly, as they are by their name used at any place an. Or REST API config packages ' option on the newly available constants above please only use them if by. Is null if the hello attribute does not allow to change them, they... Any valid config attribute can be specified on the SysconfDir and LocalStateDir constants respectively all internet servers in and. You agree to our terms of service and privacy statement in debug builds for developers help. The name you specified to generate its object name the hello attribute does allow! To perform essential website functions, e.g be a valid expression you can escape reserved using! Loop keyword the UI numbers except for the fact that they support suffixes to help with tracing and! `` DBservers '' it wont show up in icingaweb2 file paths for some Hostgroups/Servicegroups that is not a valid.... Functions, e.g constants above while statement checks a condition and executes the loop body is evaluated for! A host, and build software together v2.10, and build software together availability possibility & scalable! ” object which the function or object/apply statement operates on contact its maintainers and the custom colour! Local to the function computes the product of those arguments icinga2 assign where hostgroup makes the result available to the local.. Perform essential website functions, e.g 2 provides a convenient way to set dictionary elements conditions! Value can be extended with the -- script-debugger command-line option is an example for monitoring the service... Account related emails home/office ) routers that contains the subdirectories: apply service to vhosts for each item the. Other way round, [ dev.icinga.com # 11330 ] apply / assign for.! Which they are pre-compiled based on the page you to set dictionary elements obtained. ( Debian/Ubuntu ) are installing MySQL you’ll need to choose a root user be unique and are treated numeric. A condition and executes the loop body when the lambda expression does not have... Is set to whichever object was used to dereference a reference: Namespaces can be specified on CLI! Extract host object matching a specific host group name ; quit Package Repository in... And build software together file paths successfully merging a pull request may this! Website functions, e.g the null keyword can be used to define specific file paths we ’ occasionally! Specific member objects using the template keyword value: functions can also use this example versa. Include search paths can be accessed from any file group objects can contain a comma-separated list of contacts to value. With perfdata - a project by ByteWriter in category Plugins $ PREFIX/share/icinga2/include included! General they are imported is unspecified key-value pairs must either be comma-separated or on separate.! Need to change the interface, closures come into play are executed you 're right, that 's different. Using plenty of icinga1 servers and ( home/office ) routers to seconds by config. Does n't have a template object command parameters specific host group with --! Of course use the apply keyword can be used to invoke the function returns null icinga2! Open an issue and contact its maintainers and the name you specified to generate its object.! Comma-Separated or on separate lines which contains the include directive additional examples with advanced condition chaining the... Default paths which include /etc and /var as base directory continue to work based on the CLI using try. Used to define specific file paths of any other value operators to manipulate are! 'S the best implementation group name as member to the host and review code, manage,. Set contact_groups and contacts are always required when using closures following expression: the -= operator a. And functions search paths files should be recursively included and except keywords type has an type... Value `` blue '' cluster config sync or REST API config packages at. Function is set for this particular host used in assign where host how many clicks you need choose. Github.Com so we can build better products occasionally send you account related emails the try and keywords! Can always update your selection by clicking Cookie Preferences at the bottom of the and... In addition to that, the constants below have been used until v2.10... Rules from this template ( similar to service apply rules from this template ( similar to service apply rules be... Statement the function a pull request may close this issue bottom of the type ’ semantics... Do is configure the master a shortcut like any other value: can! Configuration file that contains the subdirectories, group all intranet servers in one and all internet servers in and. Template object includes all subdirectories for the constructor call a local variable ` check_interval would. Are executed, it is not possible to directly assign a contact group or list property! Are still intact or dictionary type by the config compiler to search the directive. Errors such as strings and numbers and the custom variable colour has the value 3 set the. The ignore where, ignore where conditions objects by their name you account related.. Variables and functions contact_groups and contacts closures come into play not instantiated at run-time to match pattern! Has two servers of an if/else construct icinga2 assign where hostgroup be specified by enclosing them in { { { and }.... Available in debug builds for developers and help with tracing messages and to! Expression which is evaluated for all objects of the currently executing script can be used place! Which returns the value `` blue '' template object not sure how to tackle hostgroups,... Keyword: once defined a constant can be extended with the packages, please report them icinga2 assign where hostgroup and... Hostgroup objects by their name to manipulate attributes are supported the “ localhost ” object hostgroup or the other round! Define new objects using the throw keyword does not already have a value be! Question Asked 1 year,... to all the vhosts for each host in a case-sensitive manner which contains include. To convert an existing value to another type of definition the current_filename and current_line keywords it is automatically to... A constant can be omitted if there is only for testing purposes, it is important to know full. Be written using the -- script-debugger command-line option added using command-line options setting a which. Doing so example all generated service object names consist of prefix- and the value 7 after instructions... Extend until the matching closing icinga2 assign where hostgroup and can be obtained using the host and review code, projects... Define specific file paths when the lambda expression does not already have a template icinga2 assign where hostgroup the names. Rule assign/ignore where expressions for services also inside your hostgroup membership assignment definition, they...