-object Service "apt" {
+apply Service "apt" {
import "generic-service"
- host_name = "localhost"
check_command = "apt"
+
+ assign where host.name == NodeName
}
-object Service "kernel" {
+apply Service "kernel" {
import "generic-service"
- host_name = "localhost"
check_command = "running_kernel"
+
+ assign where host.name == NodeName
}
-debian/config/apt.conf etc/icinga2/conf.d/hosts/localhost
+debian/config/apt.conf etc/icinga2/conf.d
debian/tmp/etc/icinga2
debian/tmp/etc/logrotate.d
debian/tmp/etc/bash_completion.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/conf.d/hosts.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/notifications.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
install_if_not_exists(icinga2/conf.d/satellite.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/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/conf.d/hosts/localhost.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts)
-install_if_not_exists(icinga2/conf.d/hosts/localhost/disk.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost)
-install_if_not_exists(icinga2/conf.d/hosts/localhost/http.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost)
-install_if_not_exists(icinga2/conf.d/hosts/localhost/icinga.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost)
-install_if_not_exists(icinga2/conf.d/hosts/localhost/load.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost)
-install_if_not_exists(icinga2/conf.d/hosts/localhost/procs.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost)
-install_if_not_exists(icinga2/conf.d/hosts/localhost/ssh.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost)
-install_if_not_exists(icinga2/conf.d/hosts/localhost/swap.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost)
-install_if_not_exists(icinga2/conf.d/hosts/localhost/users.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost)
install_if_not_exists(icinga2/features-available/api.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/checker.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
install_if_not_exists(icinga2/features-available/command.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
object ServiceGroup "disk" {
display_name = "Disk Checks"
- assign where service.check_command == "disk"
+ assign where match("disk*", service.check_command)
}
--- /dev/null
+/*
+ * Host definitions with object attributes
+ * used for apply rules for Service, Notification,
+ * Dependency and ScheduledDowntime objects.
+ *
+ * Tip: Use `icinga2 object list --type Host` to
+ * list all host objects after running
+ * configuration validation (`icinga2 daemon -C`).
+ */
+
+/*
+ * This is an example host based on your
+ * local host's FQDN. Specify the NodeName
+ * constant in `constants.conf` or use your
+ * own description, e.g. "db-host-1".
+ */
+
+object Host NodeName {
+ /* Import the default host template defined in `templates.conf`. */
+ import "generic-host"
+
+ /* Specify the address attributes for checks e.g. `ssh` or `http`. */
+ address = "127.0.0.1"
+ address6 = "::1"
+
+ /* Set custom attribute `os` for hostgroup assignment in `groups.conf`. */
+ vars.os = "Linux"
+
+ /* Define http vhost attributes for service apply rules in `services.conf`. */
+ vars.http_vhosts["http"] = {
+ http_uri = "/"
+ }
+ /* Uncomment if you've sucessfully installed Icinga Web 2. */
+ //vars.http_vhosts["Icinga Web 2"] = {
+ // http_uri = "/icingaweb"
+ //}
+
+ /* Define disks and attributes for service apply rules in `services.conf`. */
+ vars.disks["disk"] = {
+ /* No parameters. */
+ }
+ vars.disks["disk /"] = {
+ disk_partition = "/"
+ }
+
+ /* Define notification mail attributes for notification apply rules in `notifications.conf`. */
+ vars.notification["mail"] = {
+ /* The UserGroup `icingaadmins` is defined in `users.conf`. */
+ groups = [ "icingaadmins" ]
+ }
+}
+
+++ /dev/null
-/**
- * A host definition. You can create your own configuration files
- * in the conf.d directory (e.g. one per host). By default all *.conf
- * files in this directory are included.
- */
-object Host "localhost" {
- import "generic-host"
-
- address = "127.0.0.1"
- address6 = "::1"
-
- vars.os = "Linux"
- vars.sla = "24x7"
-}
+++ /dev/null
-/*
- * The CheckCommand object `disk` is provided by
- * the plugin check command templates.
- * Check the documentation for details.
- */
-object Service "disk" {
- import "generic-service"
-
- host_name = "localhost"
- check_command = "disk"
- vars.sla = "24x7"
-}
+++ /dev/null
-/*
- * The CheckCommand object `http` is provided by
- * the plugin check command templates.
- * Check the documentation for details.
- */
-object Service "http" {
- import "generic-service"
-
- host_name = "localhost"
- check_command = "http"
- vars.sla = "24x7"
-}
+++ /dev/null
-/*
- * The CheckCommand object `icinga` is provided by
- * the icinga template library.
- * Check the documentation for details.
- */
-object Service "icinga" {
- import "generic-service"
-
- host_name = "localhost"
- check_command = "icinga"
- vars.sla = "24x7"
-}
+++ /dev/null
-/*
- * The CheckCommand object `load` is provided by
- * the plugin check command templates.
- * Check the documentation for details.
- */
-object Service "load" {
- import "generic-service"
-
- host_name = "localhost"
- check_command = "load"
- vars.sla = "24x7"
-
- vars.backup_downtime = "02:00-03:00"
-}
+++ /dev/null
-/*
- * The CheckCommand object `procs` is provided by
- * the plugin check command templates.
- * Check the documentation for details.
- */
-object Service "procs" {
- import "generic-service"
-
- host_name = "localhost"
- check_command = "procs"
- vars.sla = "24x7"
-}
+++ /dev/null
-/*
- * The CheckCommand object `ssh` is provided by
- * the plugin check command templates.
- * Check the documentation for details.
- */
-object Service "ssh" {
- import "generic-service"
-
- host_name = "localhost"
- check_command = "ssh"
- vars.sla = "24x7"
-}
+++ /dev/null
-/*
- * The CheckCommand object `swap` is provided by
- * the plugin check command templates.
- * Check the documentation for details.
- */
-object Service "swap" {
- import "generic-service"
-
- host_name = "localhost"
- check_command = "swap"
- vars.sla = "24x7"
-}
+++ /dev/null
-/*
- * The CheckCommand object `users` is provided by
- * the plugin check command templates.
- * Check the documentation for details.
- */
-object Service "users" {
- import "generic-service"
-
- host_name = "localhost"
- check_command = "users"
- vars.sla = "24x7"
-}
* The example notification apply rules.
*
* Only applied if host/service objects have
- * the custom attribute `sla` set to `24x7`.
+ * the custom attribute `notification` defined
+ * and containing `mail` as key.
+ *
+ * Check `hosts.conf` for an example.
*/
apply Notification "mail-icingaadmin" to Host {
import "mail-host-notification"
- user_groups = [ "icingaadmins" ]
+ user_groups = host.vars.notification.mail.groups
- assign where host.vars.sla == "24x7"
+ assign where host.vars.notification.mail
}
apply Notification "mail-icingaadmin" to Service {
import "mail-service-notification"
- user_groups = [ "icingaadmins" ]
+ user_groups = host.vars.notification.mail.groups
- assign where service.vars.sla == "24x7"
+ assign where host.vars.notification.mail
}
/*
* Service apply rules.
*
- * Only applied if host objects are members of
- * the groups `linux-server` or `windows-server`
- * and having the `address` resp. `address6`
- * attribute set.
- *
- * The CheckCommand objects `ping4` and `ping6`
+ * The CheckCommand objects `ping4`, `ping6`, etc
* are provided by the plugin check command templates.
* Check the documentation for details.
+ *
+ * Tip: Use `icinga2 object list --type Service` to
+ * list all service objects after running
+ * configuration validation (`icinga2 daemon -C`).
*/
+/*
+ * This is an example host based on your
+ * local host's FQDN. Specify the NodeName
+ * constant in `constants.conf` or use your
+ * own description, e.g. "db-host-1".
+ */
+
+/*
+ * These are generic `ping4` and `ping6`
+ * checks applied to all hosts having the
+ * `address` resp. `address6` attribute
+ * defined.
+ */
apply Service "ping4" {
import "generic-service"
check_command = "ping4"
- vars.sla = "24x7"
- assign where "linux-servers" in host.groups
- assign where "windows-servers" in host.groups
- ignore where host.address == ""
+ assign where host.address
}
apply Service "ping6" {
import "generic-service"
check_command = "ping6"
- vars.sla = "24x7"
- assign where "linux-servers" in host.groups
- assign where "windows-servers" in host.groups
- ignore where host.address6 == ""
+ assign where host.address6
+}
+
+/*
+ * Apply the `ssh` service to all hosts
+ * with the `address` attribute defined and
+ * the custom attribute `os` set to `Linux`.
+ */
+apply Service "ssh" {
+ import "generic-service"
+
+ check_command = "ssh"
+
+ assign where host.address && host.vars.os == "Linux"
+}
+
+
+
+apply Service for (http_vhost => config in host.vars.http_vhosts) {
+ import "generic-service"
+
+ check_command = "http"
+
+ vars += config
+
+ assign where host.vars.http_vhosts
+}
+
+apply Service for (disk => config in host.vars.disks) {
+ import "generic-service"
+
+ check_command = "disk"
+
+ vars += config
+
+ assign where host.vars.disks
}
+apply Service "icinga" {
+ import "generic-service"
+
+ check_command = "icinga"
+
+ assign where host.name == NodeName
+}
+
+apply Service "load" {
+ import "generic-service"
+
+ check_command = "load"
+
+ /* Used by the ScheduledDowntime apply rule in `downtimes.conf`. */
+ vars.backup_downtime = "02:00-03:00"
+
+ assign where host.name == NodeName
+}
+
+apply Service "procs" {
+ import "generic-service"
+
+ check_command = "procs"
+
+ assign where host.name == NodeName
+}
+
+apply Service "swap" {
+ import "generic-service"
+
+ check_command = "swap"
+
+ assign where host.name == NodeName
+}
+
+apply Service "users" {
+ import "generic-service"
+
+ check_command = "users"
+
+ assign where host.name == NodeName
+}
+
+
+
%endif
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d
-%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d/hosts
-%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/conf.d/hosts/localhost
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-available
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/features-enabled
%attr(0750,%{icinga_user},%{icinga_group}) %dir %{_sysconfdir}/%{name}/repository.d
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/constants.conf
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.conf
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/*.conf
-%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/hosts/*.conf
-%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/conf.d/hosts/localhost/*.conf
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/features-available/*.conf
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/repository.d/*
%config(noreplace) %attr(0640,%{icinga_user},%{icinga_group}) %{_sysconfdir}/%{name}/zones.d/*