From 022e34449a11bea61d2fca6203740a064cf6792a Mon Sep 17 00:00:00 2001 From: Jan Dittberner Date: Tue, 15 Aug 2023 17:46:37 +0200 Subject: [PATCH] First objects - add basic service and host templates - add service groups - define a few services - add beholder host --- global-templates/host-templates.conf | 30 ++++++++++++++++++ global-templates/service-templates.conf | 11 +++++++ global-templates/servicegroups.conf | 18 +++++++++++ global-templates/services.conf | 41 +++++++++++++++++++++++++ master/hosts.conf | 14 +++++++++ 5 files changed, 114 insertions(+) create mode 100644 global-templates/host-templates.conf create mode 100644 global-templates/service-templates.conf create mode 100644 global-templates/servicegroups.conf create mode 100644 global-templates/services.conf create mode 100644 master/hosts.conf diff --git a/global-templates/host-templates.conf b/global-templates/host-templates.conf new file mode 100644 index 0000000..fb7f191 --- /dev/null +++ b/global-templates/host-templates.conf @@ -0,0 +1,30 @@ +// vim: set ft=icinga2 et sw=2 ts=2 si ai: + +/** + * Provides default settings for hosts. By convention + * all hosts should import this template. + * + * The CheckCommand object `hostalive` is provided by + * the plugin check command templates. + * Check the documentation for details. + */ +template Host "generic-host" { + max_check_attempts = 3 + check_interval = 1m + retry_interval = 30s + + check_command = "hostalive" +} + +template Host "debian-host" { + import "generic-host" + + vars.osfamily = "Debian" + + vars.procs = { + "ssh" = { + procs_command = "sshd" + procs_critical = "1:50" + } + } +} diff --git a/global-templates/service-templates.conf b/global-templates/service-templates.conf new file mode 100644 index 0000000..767fac4 --- /dev/null +++ b/global-templates/service-templates.conf @@ -0,0 +1,11 @@ +// vim: set ft=icinga2 et sw=2 ts=2 si ai: + +/** + * Provides default settings for services. By convention + * all services should import this template. + */ +template Service "generic-service" { + max_check_attempts = 5 + check_interval = 1m + retry_interval = 30s +} diff --git a/global-templates/servicegroups.conf b/global-templates/servicegroups.conf new file mode 100644 index 0000000..2e16249 --- /dev/null +++ b/global-templates/servicegroups.conf @@ -0,0 +1,18 @@ +// vim: set ft=icinga2 et sw=2 ts=2 si ai: +object ServiceGroup "disk" { + display_name = "Disk Checks" + + assign where service.check_command == "disk" +} + +object ServiceGroup "package-updates" { + display_name = "Package Update Status" + + assign where service.check_command == "apt" +} + +object ServiceGroup "procs" { + display_name = "Process Checks" + + assign where service.check_command == "procs" +} diff --git a/global-templates/services.conf b/global-templates/services.conf new file mode 100644 index 0000000..4bbacf2 --- /dev/null +++ b/global-templates/services.conf @@ -0,0 +1,41 @@ +// vim: set ft=icinga2 et sw=2 ts=2 si ai: +apply Service "apt" { + import "generic-service" + + check_command = "apt" + + check_interval = 1h + retry_interval = 15m + + vars.apt_list = true + + assign where host.vars.osfamily == "Debian" +} + +apply Service "icinga" { + import "generic-service" + + check_command = "icinga" +} + +apply Service "procs" { + import "generic-service" + + check_command = "procs" +} + +apply Service "proc-" for (proc => config in host.vars.procs) { + import "generic-service" + + check_command = "procs" + + vars += config +} + +apply Service "disk-" for (disk => config in host.vars.disks) { + import "generic-service" + + check_command = "disk" + + vars += config +} diff --git a/master/hosts.conf b/master/hosts.conf new file mode 100644 index 0000000..e044119 --- /dev/null +++ b/master/hosts.conf @@ -0,0 +1,14 @@ +// vim: set ft=icinga2 et sw=2 ts=2 si ai: +object Host "beholder" { + import "debian-host" + + address = "127.0.0.1" + address6 = "::1" + + vars.disks["/"] = { + disk_partitions = "/" + } + vars.disks["/boot/efi"] = { + disk_partitions = "/boot/efi" + } +}