diff --git a/etc/icinga2/conf.d/Makefile.am b/etc/icinga2/conf.d/Makefile.am index dc43107c5..4eee019f0 100644 --- a/etc/icinga2/conf.d/Makefile.am +++ b/etc/icinga2/conf.d/Makefile.am @@ -5,9 +5,12 @@ icinga2confdir = $(DESTDIR)${sysconfdir}/icinga2/conf.d CONFIG_FILES = \ generic-host.conf \ generic-service.conf \ + groups.conf \ localhost.conf \ macros.conf \ - timeperiods.conf + notifications.conf \ + timeperiods.conf \ + users.conf install-data-local: @if [ ! -e $(icinga2confdir) ]; then \ diff --git a/etc/icinga2/conf.d/generic-host.conf b/etc/icinga2/conf.d/generic-host.conf index a779022f6..20499226c 100644 --- a/etc/icinga2/conf.d/generic-host.conf +++ b/etc/icinga2/conf.d/generic-host.conf @@ -5,3 +5,49 @@ template Host "generic-host" { } + +template Host "linux-server" inherits "generic-host" { + + groups = [ "linux-servers" ], + + services["ping4"] = { + templates = [ "generic-service" ], + + check_command = "ping4" + }, + + check = "ping4" +} + +template Host "windows-server" inherits "generic-host" { + + groups = [ "windows-servers" ], + + services["ping4"] = { + templates = [ "generic-service" ], + + check_command = "ping4" + }, + + check = "ping4" +} + +template Host "generic-printer" inherits "generic-host" { + services["ping4"] = { + templates = [ "generic-service" ], + + check_command = "ping4" + }, + + check = "ping4" +} + +template Host "generic-switch" inherits "generic-host" { + services["ping4"] = { + templates = [ "generic-service" ], + + check_command = "ping4" + }, + + check = "ping4" +} diff --git a/etc/icinga2/conf.d/generic-service.conf b/etc/icinga2/conf.d/generic-service.conf index 4f472e930..0039dc51c 100644 --- a/etc/icinga2/conf.d/generic-service.conf +++ b/etc/icinga2/conf.d/generic-service.conf @@ -4,4 +4,12 @@ */ template Service "generic-service" { + max_check_attempts = 3, + check_interval = 5m, + retry_interval = 1m, + + notifications["mail-icingaadmin"] = { + templates = [ "mail-notification" ], + user_groups = [ "icingaadmins" ] + } } diff --git a/etc/icinga2/conf.d/groups.conf b/etc/icinga2/conf.d/groups.conf new file mode 100644 index 000000000..9bdc96256 --- /dev/null +++ b/etc/icinga2/conf.d/groups.conf @@ -0,0 +1,11 @@ +/** + * Host and service group examples. + */ + +object HostGroup "linux-servers" { + display_name = "Linux Servers" +} + +object HostGroup "windows-servers" { + display_name = "Windows Servers" +} diff --git a/etc/icinga2/conf.d/localhost.conf b/etc/icinga2/conf.d/localhost.conf index 0fa783e97..c0dcefe6d 100644 --- a/etc/icinga2/conf.d/localhost.conf +++ b/etc/icinga2/conf.d/localhost.conf @@ -4,6 +4,11 @@ * files in this directory are included. */ object Host "localhost" inherits "generic-host" { + + display_name = "localhost", + + groups = [ "linux-servers", "windows-servers" ], + services["ping4"] = { templates = [ "generic-service" ], diff --git a/etc/icinga2/conf.d/notifications.conf b/etc/icinga2/conf.d/notifications.conf new file mode 100644 index 000000000..518cd95e2 --- /dev/null +++ b/etc/icinga2/conf.d/notifications.conf @@ -0,0 +1,49 @@ +/** + * The example notification templates. + */ + +template Notification "mail-notification" { + notification_command = "mail-service-notification", + + notification_state_filter = (StateFilterWarning | + StateFilterCritical | + StateFilterUnknown), + notification_type_filter = (NotificationFilterProblem | + NotificationFilterAcknowledgement | + NotificationFilterRecovery | + NotificationFilterCustom | + NotificationFilterFlappingStart | + NotificationFilterFlappingEnd | + NotificationFilterDowntimeStart | + NotificationFilterDowntimeEnd | + NotificationFilterDowntimeRemoved), + + notification_period = "24x7", + users = [ "icingaadmin" ], + usergroups = [ "icingaadmins" ] +} + +object NotificationCommand "mail-service-notification" inherits "plugin-notification-command" { + command = [ + "/usr/bin/printf", + "\"%b\"", + {{{\"***** Icinga ***** + + Notification Type: $NOTIFICATIONTYPE$ + + Service: $SERVICEDESC$ + Host: $HOSTALIAS$ + Address: $HOSTADDRESS$ + State: $SERVICESTATE$ + + Date/Time: $LONGDATETIME$ + + Additional Info: $SERVICEOUTPUT$ + + Comment: [$NOTIFICATIONAUTHORNAME$] $NOTIFICATIONCOMMENT$\"}}}, + "-s", + "\"$NOTIFICATIONTYPE$ - $HOSTDISPLAYNAME$ - $SERVICEDISPLAYNAME$ is $SERVICESTATE$\"", + "$USEREMAIL$" + ] +} + diff --git a/etc/icinga2/conf.d/users.conf b/etc/icinga2/conf.d/users.conf new file mode 100644 index 000000000..b80107993 --- /dev/null +++ b/etc/icinga2/conf.d/users.conf @@ -0,0 +1,40 @@ +/** + * The example user 'icingaadmin' and the example + * group 'icingaadmins'. + */ + +object User "icingaadmin" { + display_name = "Icinga 2 Admin", + groups = [ "icingaadmins" ], + + enable_notifications = 1, + notification_period = "24x7", + + notification_state_filter = (StateFilterWarning | + StateFilterCritical | + StateFilterUnknown), + notification_type_filter = (NotificationFilterProblem | + NotificationFilterAcknowledgement | + NotificationFilterRecovery | + NotificationFilterCustom | + NotificationFilterFlappingStart | + NotificationFilterFlappingEnd | + NotificationFilterDowntimeStart | + NotificationFilterDowntimeEnd | + NotificationFilterDowntimeRemoved), + + macros = { + "name" = "Icinga 2 Admin", + "email" = "icinga@localhost", + "pager" = "icingaadmin@localhost.localdomain" + }, + + custom = { + notes = "This is the Icinga 2 Admin account.", + } +} + + +object UserGroup "icingaadmins" { + display_name = "Icinga 2 Admin Group" +}