mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-06 05:14:29 +02:00
Emphasize on apply rules in example config.
- move all templates into templates.conf - move service apply ping{4,6} to services.conf - apply notifications based on vars.sla == "24x7" - apply scheduled downtime based on host/service name - apply ping{4,6} based on hostgroup membership - keep hosts/localhost for real local configuration Fixes #6266
This commit is contained in:
parent
831743fa0a
commit
0eec68aec4
@ -24,10 +24,12 @@ install_if_not_exists(icinga2/constants.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2
|
|||||||
install_if_not_exists(icinga2/zones.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
|
install_if_not_exists(icinga2/zones.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2)
|
||||||
install_if_not_exists(icinga2/conf.d/commands.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.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/downtimes.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
|
||||||
install_if_not_exists(icinga2/conf.d/generic-host.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
|
|
||||||
install_if_not_exists(icinga2/conf.d/generic-service.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d)
|
|
||||||
install_if_not_exists(icinga2/conf.d/generic-user.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/groups.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/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.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/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/http.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost)
|
||||||
@ -37,9 +39,6 @@ install_if_not_exists(icinga2/conf.d/hosts/localhost/procs.conf ${CMAKE_INSTALL_
|
|||||||
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/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/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/conf.d/hosts/localhost/users.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/conf.d/hosts/localhost)
|
||||||
install_if_not_exists(icinga2/conf.d/notifications.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/features-available/api.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
|
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/checker.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
|
||||||
install_if_not_exists(icinga2/features-available/command.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
|
install_if_not_exists(icinga2/features-available/command.conf ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available)
|
||||||
|
@ -1,18 +1,9 @@
|
|||||||
/**
|
/**
|
||||||
* The example downtime templates.
|
* The example downtime apply rule.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template ScheduledDowntime "backup-downtime" {
|
apply ScheduledDowntime "backup-downtime" to Service {
|
||||||
author = "icingaadmin"
|
import "backup-downtime"
|
||||||
comment = "Scheduled downtime for backup"
|
|
||||||
|
|
||||||
ranges = {
|
assign where host.name == "localhost" && service.name == "load"
|
||||||
monday = "02:00-03:00"
|
|
||||||
tuesday = "02:00-03:00"
|
|
||||||
wednesday = "02:00-03:00"
|
|
||||||
thursday = "02:00-03:00"
|
|
||||||
friday = "02:00-03:00"
|
|
||||||
saturday = "02:00-03:00"
|
|
||||||
sunday = "02:00-03:00"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,37 +0,0 @@
|
|||||||
/**
|
|
||||||
* Provides default settings for hosts. By convention
|
|
||||||
* all hosts should import this template.
|
|
||||||
*/
|
|
||||||
template Host "generic-host" {
|
|
||||||
max_check_attempts = 5
|
|
||||||
check_interval = 1m
|
|
||||||
retry_interval = 30s
|
|
||||||
|
|
||||||
check_command = "hostalive"
|
|
||||||
}
|
|
||||||
|
|
||||||
apply Service "ping4" {
|
|
||||||
import "generic-service"
|
|
||||||
|
|
||||||
check_command = "ping4"
|
|
||||||
|
|
||||||
assign where "generic-host" in host.templates
|
|
||||||
ignore where host.address == ""
|
|
||||||
}
|
|
||||||
|
|
||||||
apply Service "ping6" {
|
|
||||||
import "generic-service"
|
|
||||||
|
|
||||||
check_command = "ping6"
|
|
||||||
|
|
||||||
assign where "generic-host" in host.templates
|
|
||||||
ignore where host.address6 == ""
|
|
||||||
}
|
|
||||||
|
|
||||||
apply Notification "mail-icingaadmin" to Host {
|
|
||||||
import "mail-host-notification"
|
|
||||||
|
|
||||||
user_groups = [ "icingaadmins" ]
|
|
||||||
|
|
||||||
assign where "generic-host" in host.templates
|
|
||||||
}
|
|
@ -1,17 +0,0 @@
|
|||||||
/**
|
|
||||||
* Provides default settings for services. By convention
|
|
||||||
* all services should import this template.
|
|
||||||
*/
|
|
||||||
template Service "generic-service" {
|
|
||||||
max_check_attempts = 3
|
|
||||||
check_interval = 1m
|
|
||||||
retry_interval = 30s
|
|
||||||
}
|
|
||||||
|
|
||||||
apply Notification "mail-icingaadmin" to Service {
|
|
||||||
import "mail-service-notification"
|
|
||||||
|
|
||||||
user_groups = [ "icingaadmins" ]
|
|
||||||
|
|
||||||
assign where "generic-service" in service.templates
|
|
||||||
}
|
|
@ -1,8 +0,0 @@
|
|||||||
/**
|
|
||||||
* Provides default settings for users. By convention
|
|
||||||
* all users should inherit from this template.
|
|
||||||
*/
|
|
||||||
|
|
||||||
template User "generic-user" {
|
|
||||||
|
|
||||||
}
|
|
@ -10,4 +10,5 @@ object Host "localhost" {
|
|||||||
address6 = "::1"
|
address6 = "::1"
|
||||||
|
|
||||||
vars.os = "Linux"
|
vars.os = "Linux"
|
||||||
|
vars.sla = "24x7"
|
||||||
}
|
}
|
||||||
|
@ -3,4 +3,5 @@ object Service "disk" {
|
|||||||
|
|
||||||
host_name = "localhost"
|
host_name = "localhost"
|
||||||
check_command = "disk"
|
check_command = "disk"
|
||||||
|
vars.sla = "24x7"
|
||||||
}
|
}
|
||||||
|
@ -3,4 +3,5 @@ object Service "http" {
|
|||||||
|
|
||||||
host_name = "localhost"
|
host_name = "localhost"
|
||||||
check_command = "http"
|
check_command = "http"
|
||||||
|
vars.sla = "24x7"
|
||||||
}
|
}
|
||||||
|
@ -3,4 +3,5 @@ object Service "icinga" {
|
|||||||
|
|
||||||
host_name = "localhost"
|
host_name = "localhost"
|
||||||
check_command = "icinga"
|
check_command = "icinga"
|
||||||
|
vars.sla = "24x7"
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,5 @@ object Service "load" {
|
|||||||
|
|
||||||
host_name = "localhost"
|
host_name = "localhost"
|
||||||
check_command = "load"
|
check_command = "load"
|
||||||
}
|
vars.sla = "24x7"
|
||||||
|
|
||||||
object ScheduledDowntime "backup-downtime" {
|
|
||||||
import "backup-downtime"
|
|
||||||
|
|
||||||
host_name = "localhost"
|
|
||||||
service_name = "load"
|
|
||||||
}
|
}
|
||||||
|
@ -3,5 +3,6 @@ object Service "procs" {
|
|||||||
|
|
||||||
host_name = "localhost"
|
host_name = "localhost"
|
||||||
check_command = "procs"
|
check_command = "procs"
|
||||||
|
vars.sla = "24x7"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,4 +3,5 @@ object Service "ssh" {
|
|||||||
|
|
||||||
host_name = "localhost"
|
host_name = "localhost"
|
||||||
check_command = "ssh"
|
check_command = "ssh"
|
||||||
|
vars.sla = "24x7"
|
||||||
}
|
}
|
||||||
|
@ -3,4 +3,5 @@ object Service "swap" {
|
|||||||
|
|
||||||
host_name = "localhost"
|
host_name = "localhost"
|
||||||
check_command = "swap"
|
check_command = "swap"
|
||||||
|
vars.sla = "24x7"
|
||||||
}
|
}
|
||||||
|
@ -3,4 +3,5 @@ object Service "users" {
|
|||||||
|
|
||||||
host_name = "localhost"
|
host_name = "localhost"
|
||||||
check_command = "users"
|
check_command = "users"
|
||||||
|
vars.sla = "24x7"
|
||||||
}
|
}
|
||||||
|
@ -1,26 +1,22 @@
|
|||||||
/**
|
/**
|
||||||
* The example notification templates.
|
* The example notification apply rules.
|
||||||
|
*
|
||||||
|
* Only applied if host/service objects have
|
||||||
|
* the custom attribute `sla` set to `24x7`.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
template Notification "mail-host-notification" {
|
apply Notification "mail-icingaadmin" to Host {
|
||||||
command = "mail-host-notification"
|
import "mail-host-notification"
|
||||||
|
|
||||||
states = [ Up, Down ]
|
user_groups = [ "icingaadmins" ]
|
||||||
types = [ Problem, Acknowledgement, Recovery, Custom,
|
|
||||||
FlappingStart, FlappingEnd,
|
|
||||||
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
|
|
||||||
|
|
||||||
period = "24x7"
|
assign where host.vars.sla == "24x7"
|
||||||
}
|
}
|
||||||
|
|
||||||
template Notification "mail-service-notification" {
|
apply Notification "mail-icingaadmin" to Service {
|
||||||
command = "mail-service-notification"
|
import "mail-service-notification"
|
||||||
|
|
||||||
states = [ OK, Warning, Critical, Unknown ]
|
user_groups = [ "icingaadmins" ]
|
||||||
types = [ Problem, Acknowledgement, Recovery, Custom,
|
|
||||||
FlappingStart, FlappingEnd,
|
|
||||||
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
|
|
||||||
|
|
||||||
period = "24x7"
|
assign where service.vars.sla == "24x7"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
31
etc/icinga2/conf.d/services.conf
Normal file
31
etc/icinga2/conf.d/services.conf
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
apply Service "ping4" {
|
||||||
|
import "generic-service"
|
||||||
|
|
||||||
|
check_command = "ping4"
|
||||||
|
vars.sla = "24x7"
|
||||||
|
|
||||||
|
assign where "linux-server" in host.groups
|
||||||
|
assign where "windows-server" in host.groups
|
||||||
|
ignore where host.address == ""
|
||||||
|
}
|
||||||
|
|
||||||
|
apply Service "ping6" {
|
||||||
|
import "generic-service"
|
||||||
|
|
||||||
|
check_command = "ping6"
|
||||||
|
vars.sla = "24x7"
|
||||||
|
|
||||||
|
assign where "linux-server" in host.groups
|
||||||
|
assign where "windows-server" in host.groups
|
||||||
|
ignore where host.address6 == ""
|
||||||
|
}
|
||||||
|
|
86
etc/icinga2/conf.d/templates.conf
Normal file
86
etc/icinga2/conf.d/templates.conf
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
/*
|
||||||
|
* Generic template examples.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides default settings for hosts. By convention
|
||||||
|
* all hosts should import this template.
|
||||||
|
*/
|
||||||
|
template Host "generic-host" {
|
||||||
|
max_check_attempts = 5
|
||||||
|
check_interval = 1m
|
||||||
|
retry_interval = 30s
|
||||||
|
|
||||||
|
check_command = "hostalive"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides default settings for services. By convention
|
||||||
|
* all services should import this template.
|
||||||
|
*/
|
||||||
|
template Service "generic-service" {
|
||||||
|
max_check_attempts = 3
|
||||||
|
check_interval = 1m
|
||||||
|
retry_interval = 30s
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides default settings for users. By convention
|
||||||
|
* all users should inherit from this template.
|
||||||
|
*/
|
||||||
|
|
||||||
|
template User "generic-user" {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides default settings for host notifications.
|
||||||
|
* By convention all host notifications should import
|
||||||
|
* this template.
|
||||||
|
*/
|
||||||
|
template Notification "mail-host-notification" {
|
||||||
|
command = "mail-host-notification"
|
||||||
|
|
||||||
|
states = [ Up, Down ]
|
||||||
|
types = [ Problem, Acknowledgement, Recovery, Custom,
|
||||||
|
FlappingStart, FlappingEnd,
|
||||||
|
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
|
||||||
|
|
||||||
|
period = "24x7"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides default settings for service notifications.
|
||||||
|
* By convention all service notifications should import
|
||||||
|
* this template.
|
||||||
|
*/
|
||||||
|
template Notification "mail-service-notification" {
|
||||||
|
command = "mail-service-notification"
|
||||||
|
|
||||||
|
states = [ OK, Warning, Critical, Unknown ]
|
||||||
|
types = [ Problem, Acknowledgement, Recovery, Custom,
|
||||||
|
FlappingStart, FlappingEnd,
|
||||||
|
DowntimeStart, DowntimeEnd, DowntimeRemoved ]
|
||||||
|
|
||||||
|
period = "24x7"
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides default settings for recurring backup downtime
|
||||||
|
*/
|
||||||
|
|
||||||
|
template ScheduledDowntime "backup-downtime" {
|
||||||
|
author = "icingaadmin"
|
||||||
|
comment = "Scheduled downtime for backup"
|
||||||
|
|
||||||
|
ranges = {
|
||||||
|
monday = "02:00-03:00"
|
||||||
|
tuesday = "02:00-03:00"
|
||||||
|
wednesday = "02:00-03:00"
|
||||||
|
thursday = "02:00-03:00"
|
||||||
|
friday = "02:00-03:00"
|
||||||
|
saturday = "02:00-03:00"
|
||||||
|
sunday = "02:00-03:00"
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user