summaryrefslogtreecommitdiffstats
path: root/etc
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:34:54 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 12:34:54 +0000
commit0915b3ef56dfac3113cce55a59a5765dc94976be (patch)
treea8fea11d50b4f083e1bf0f90025ece7f0824784a /etc
parentInitial commit. (diff)
downloadicinga2-0915b3ef56dfac3113cce55a59a5765dc94976be.tar.xz
icinga2-0915b3ef56dfac3113cce55a59a5765dc94976be.zip
Adding upstream version 2.13.6.upstream/2.13.6upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'etc')
-rw-r--r--etc/CMakeLists.txt66
-rw-r--r--etc/bash_completion.d/icinga217
-rw-r--r--etc/icinga2/conf.d/app.conf1
-rw-r--r--etc/icinga2/conf.d/commands.conf187
-rw-r--r--etc/icinga2/conf.d/downtimes.conf20
-rw-r--r--etc/icinga2/conf.d/groups.conf37
-rw-r--r--etc/icinga2/conf.d/hosts.conf52
-rw-r--r--etc/icinga2/conf.d/notifications.conf33
-rw-r--r--etc/icinga2/conf.d/services.conf117
-rw-r--r--etc/icinga2/conf.d/templates.conf83
-rw-r--r--etc/icinga2/conf.d/timeperiods.conf35
-rw-r--r--etc/icinga2/conf.d/users.conf17
-rw-r--r--etc/icinga2/conf.d/win32/hosts.conf43
-rw-r--r--etc/icinga2/conf.d/win32/services.conf92
-rw-r--r--etc/icinga2/constants.conf.cmake28
-rw-r--r--etc/icinga2/features-available/api.conf10
-rw-r--r--etc/icinga2/features-available/checker.conf5
-rw-r--r--etc/icinga2/features-available/command.conf7
-rw-r--r--etc/icinga2/features-available/compatlog.conf7
-rw-r--r--etc/icinga2/features-available/debuglog.conf10
-rw-r--r--etc/icinga2/features-available/elasticsearch.conf8
-rw-r--r--etc/icinga2/features-available/gelf.conf10
-rw-r--r--etc/icinga2/features-available/graphite.conf9
-rw-r--r--etc/icinga2/features-available/icingadb.conf5
-rw-r--r--etc/icinga2/features-available/ido-mysql.conf11
-rw-r--r--etc/icinga2/features-available/ido-pgsql.conf11
-rw-r--r--etc/icinga2/features-available/influxdb.conf25
-rw-r--r--etc/icinga2/features-available/influxdb2.conf27
-rw-r--r--etc/icinga2/features-available/livestatus.conf6
-rw-r--r--etc/icinga2/features-available/mainlog.conf8
-rw-r--r--etc/icinga2/features-available/notification.conf5
-rw-r--r--etc/icinga2/features-available/opentsdb.conf25
-rw-r--r--etc/icinga2/features-available/perfdata.conf6
-rw-r--r--etc/icinga2/features-available/statusdata.conf8
-rw-r--r--etc/icinga2/features-available/syslog.conf8
-rw-r--r--etc/icinga2/features-available/windowseventlog.conf8
-rw-r--r--etc/icinga2/features-enabled/checker.conf1
-rw-r--r--etc/icinga2/features-enabled/notification.conf1
-rw-r--r--etc/icinga2/features-enabled/windowseventlog.conf1
-rw-r--r--etc/icinga2/icinga2.conf57
-rwxr-xr-xetc/icinga2/scripts/mail-host-notification.sh169
-rwxr-xr-xetc/icinga2/scripts/mail-service-notification.sh174
-rw-r--r--etc/icinga2/win32/constants.conf28
-rw-r--r--etc/icinga2/win32/icinga2.conf55
-rw-r--r--etc/icinga2/zones.conf63
-rw-r--r--etc/icinga2/zones.d/README2
-rw-r--r--etc/initsystem/CMakeLists.txt44
-rw-r--r--etc/initsystem/icinga2.init.d.cmake198
-rw-r--r--etc/initsystem/icinga2.service.cmake30
-rw-r--r--etc/initsystem/icinga2.service.limits.conf9
-rw-r--r--etc/initsystem/icinga2.sysconfig.cmake15
-rw-r--r--etc/initsystem/prepare-dirs.cmake52
-rw-r--r--etc/initsystem/safe-reload.cmake52
-rw-r--r--etc/logrotate.d/icinga2.cmake21
54 files changed, 2019 insertions, 0 deletions
diff --git a/etc/CMakeLists.txt b/etc/CMakeLists.txt
new file mode 100644
index 0000000..ff138bd
--- /dev/null
+++ b/etc/CMakeLists.txt
@@ -0,0 +1,66 @@
+# Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+
+
+if(NOT WIN32)
+ configure_file(icinga2/constants.conf.cmake ${CMAKE_CURRENT_BINARY_DIR}/icinga2/constants.conf @ONLY)
+endif()
+
+if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
+ configure_file(logrotate.d/icinga2.cmake ${CMAKE_CURRENT_BINARY_DIR}/logrotate.d/icinga2 @ONLY)
+endif()
+
+if(NOT WIN32)
+ install_if_not_exists(${CMAKE_CURRENT_BINARY_DIR}/icinga2/constants.conf ${ICINGA2_CONFIGDIR})
+ install_if_not_exists(icinga2/icinga2.conf ${ICINGA2_CONFIGDIR})
+else()
+ install_if_not_exists(${CMAKE_CURRENT_SOURCE_DIR}/icinga2/win32/constants.conf ${ICINGA2_CONFIGDIR})
+ install_if_not_exists(icinga2/win32/icinga2.conf ${ICINGA2_CONFIGDIR})
+endif()
+
+install_if_not_exists(icinga2/zones.conf ${ICINGA2_CONFIGDIR})
+install_if_not_exists(icinga2/conf.d/app.conf ${ICINGA2_CONFIGDIR}/conf.d)
+install_if_not_exists(icinga2/conf.d/commands.conf ${ICINGA2_CONFIGDIR}/conf.d)
+install_if_not_exists(icinga2/conf.d/downtimes.conf ${ICINGA2_CONFIGDIR}/conf.d)
+install_if_not_exists(icinga2/conf.d/groups.conf ${ICINGA2_CONFIGDIR}/conf.d)
+
+if(NOT WIN32)
+ install_if_not_exists(icinga2/conf.d/hosts.conf ${ICINGA2_CONFIGDIR}/conf.d)
+ install_if_not_exists(icinga2/conf.d/services.conf ${ICINGA2_CONFIGDIR}/conf.d)
+else()
+ install_if_not_exists(icinga2/conf.d/win32/hosts.conf ${ICINGA2_CONFIGDIR}/conf.d)
+ install_if_not_exists(icinga2/conf.d/win32/services.conf ${ICINGA2_CONFIGDIR}/conf.d)
+endif()
+
+install_if_not_exists(icinga2/conf.d/notifications.conf ${ICINGA2_CONFIGDIR}/conf.d)
+install_if_not_exists(icinga2/conf.d/templates.conf ${ICINGA2_CONFIGDIR}/conf.d)
+install_if_not_exists(icinga2/conf.d/timeperiods.conf ${ICINGA2_CONFIGDIR}/conf.d)
+install_if_not_exists(icinga2/conf.d/users.conf ${ICINGA2_CONFIGDIR}/conf.d)
+install_if_not_exists(icinga2/features-available/api.conf ${ICINGA2_CONFIGDIR}/features-available)
+install_if_not_exists(icinga2/features-available/debuglog.conf ${ICINGA2_CONFIGDIR}/features-available)
+install_if_not_exists(icinga2/features-available/mainlog.conf ${ICINGA2_CONFIGDIR}/features-available)
+if(NOT WIN32)
+ install_if_not_exists(icinga2/features-available/syslog.conf ${ICINGA2_CONFIGDIR}/features-available)
+else()
+ install_if_not_exists(icinga2/features-available/windowseventlog.conf ${ICINGA2_CONFIGDIR}/features-available)
+endif()
+install_if_not_exists(icinga2/scripts/mail-host-notification.sh ${ICINGA2_CONFIGDIR}/scripts)
+install_if_not_exists(icinga2/scripts/mail-service-notification.sh ${ICINGA2_CONFIGDIR}/scripts)
+install_if_not_exists(icinga2/zones.d/README ${ICINGA2_CONFIGDIR}/zones.d)
+
+if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
+ install_if_not_exists(${CMAKE_CURRENT_BINARY_DIR}/logrotate.d/icinga2 ${LOGROTATE_DIR})
+endif()
+
+if(NOT WIN32)
+ install(CODE "file(MAKE_DIRECTORY \"\$ENV{DESTDIR}${ICINGA2_FULL_CONFIGDIR}/features-enabled\")")
+ install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" -E create_symlink ../features-available/mainlog.conf \"\$ENV{DESTDIR}${ICINGA2_FULL_CONFIGDIR}/features-enabled/mainlog.conf\")")
+
+ install(FILES bash_completion.d/icinga2 DESTINATION ${BASHCOMPLETION_DIR})
+else()
+ install_if_not_exists(icinga2/features-enabled/windowseventlog.conf ${ICINGA2_CONFIGDIR}/features-enabled)
+endif()
+
+if(${CMAKE_SYSTEM_NAME} MATCHES "(Linux|Solaris|SunOS)")
+ add_subdirectory(initsystem)
+endif()
+
+set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}" PARENT_SCOPE)
diff --git a/etc/bash_completion.d/icinga2 b/etc/bash_completion.d/icinga2
new file mode 100644
index 0000000..5c49ab0
--- /dev/null
+++ b/etc/bash_completion.d/icinga2
@@ -0,0 +1,17 @@
+_icinga2()
+{
+ local cur opts
+ opts="${COMP_WORDS[*]}"
+ cur="${COMP_WORDS[COMP_CWORD]}"
+ COMPREPLY=($(icinga2 --autocomplete $COMP_CWORD ${COMP_WORDS[*]} < /dev/null))
+ case $COMPREPLY in
+ */|*=)
+ compopt -o nospace
+ ;;
+ esac
+
+ return 0
+}
+
+complete -F _icinga2 icinga2
+
diff --git a/etc/icinga2/conf.d/app.conf b/etc/icinga2/conf.d/app.conf
new file mode 100644
index 0000000..3e4be0d
--- /dev/null
+++ b/etc/icinga2/conf.d/app.conf
@@ -0,0 +1 @@
+object IcingaApplication "app" { }
diff --git a/etc/icinga2/conf.d/commands.conf b/etc/icinga2/conf.d/commands.conf
new file mode 100644
index 0000000..bd511ce
--- /dev/null
+++ b/etc/icinga2/conf.d/commands.conf
@@ -0,0 +1,187 @@
+/* Command objects */
+
+/* Notification Commands
+ *
+ * Please check the documentation for all required and
+ * optional parameters.
+ */
+
+object NotificationCommand "mail-host-notification" {
+ command = [ ConfigDir + "/scripts/mail-host-notification.sh" ]
+
+ arguments += {
+ "-4" = "$notification_address$"
+ "-6" = "$notification_address6$"
+ "-b" = "$notification_author$"
+ "-c" = "$notification_comment$"
+ "-d" = {
+ required = true
+ value = "$notification_date$"
+ }
+ "-f" = {
+ value = "$notification_from$"
+ description = "Set from address. Requires GNU mailutils (Debian/Ubuntu) or mailx (RHEL/SUSE)"
+ }
+ "-i" = "$notification_icingaweb2url$"
+ "-l" = {
+ required = true
+ value = "$notification_hostname$"
+ }
+ "-n" = {
+ required = true
+ value = "$notification_hostdisplayname$"
+ }
+ "-o" = {
+ required = true
+ value = "$notification_hostoutput$"
+ }
+ "-r" = {
+ required = true
+ value = "$notification_useremail$"
+ }
+ "-s" = {
+ required = true
+ value = "$notification_hoststate$"
+ }
+ "-t" = {
+ required = true
+ value = "$notification_type$"
+ }
+ "-v" = "$notification_logtosyslog$"
+ }
+
+ vars += {
+ notification_address = "$address$"
+ notification_address6 = "$address6$"
+ notification_author = "$notification.author$"
+ notification_comment = "$notification.comment$"
+ notification_type = "$notification.type$"
+ notification_date = "$icinga.long_date_time$"
+ notification_hostname = "$host.name$"
+ notification_hostdisplayname = "$host.display_name$"
+ notification_hostoutput = "$host.output$"
+ notification_hoststate = "$host.state$"
+ notification_useremail = "$user.email$"
+ }
+}
+
+object NotificationCommand "mail-service-notification" {
+ command = [ ConfigDir + "/scripts/mail-service-notification.sh" ]
+
+ arguments += {
+ "-4" = "$notification_address$"
+ "-6" = "$notification_address6$"
+ "-b" = "$notification_author$"
+ "-c" = "$notification_comment$"
+ "-d" = {
+ required = true
+ value = "$notification_date$"
+ }
+ "-e" = {
+ required = true
+ value = "$notification_servicename$"
+ }
+ "-f" = {
+ value = "$notification_from$"
+ description = "Set from address. Requires GNU mailutils (Debian/Ubuntu) or mailx (RHEL/SUSE)"
+ }
+ "-i" = "$notification_icingaweb2url$"
+ "-l" = {
+ required = true
+ value = "$notification_hostname$"
+ }
+ "-n" = {
+ required = true
+ value = "$notification_hostdisplayname$"
+ }
+ "-o" = {
+ required = true
+ value = "$notification_serviceoutput$"
+ }
+ "-r" = {
+ required = true
+ value = "$notification_useremail$"
+ }
+ "-s" = {
+ required = true
+ value = "$notification_servicestate$"
+ }
+ "-t" = {
+ required = true
+ value = "$notification_type$"
+ }
+ "-u" = {
+ required = true
+ value = "$notification_servicedisplayname$"
+ }
+ "-v" = "$notification_logtosyslog$"
+ }
+
+ vars += {
+ notification_address = "$address$"
+ notification_address6 = "$address6$"
+ notification_author = "$notification.author$"
+ notification_comment = "$notification.comment$"
+ notification_type = "$notification.type$"
+ notification_date = "$icinga.long_date_time$"
+ notification_hostname = "$host.name$"
+ notification_hostdisplayname = "$host.display_name$"
+ notification_servicename = "$service.name$"
+ notification_serviceoutput = "$service.output$"
+ notification_servicestate = "$service.state$"
+ notification_useremail = "$user.email$"
+ notification_servicedisplayname = "$service.display_name$"
+ }
+}
+
+/*
+ * If you prefer to use the notification scripts with environment
+ * variables instead of command line parameters, you can use
+ * the following commands. They have been updated from < 2.7
+ * to support the new notification scripts and should help
+ * with an upgrade.
+ * Remove the comment blocks and comment the notification commands above.
+ */
+
+/*
+
+object NotificationCommand "mail-host-notification" {
+ command = [ ConfigDir + "/scripts/mail-host-notification.sh" ]
+
+ env = {
+ NOTIFICATIONTYPE = "$notification.type$"
+ HOSTDISPLAYNAME = "$host.display_name$"
+ HOSTNAME = "$host.name$"
+ HOSTADDRESS = "$address$"
+ HOSTSTATE = "$host.state$"
+ LONGDATETIME = "$icinga.long_date_time$"
+ HOSTOUTPUT = "$host.output$"
+ NOTIFICATIONAUTHORNAME = "$notification.author$"
+ NOTIFICATIONCOMMENT = "$notification.comment$"
+ HOSTDISPLAYNAME = "$host.display_name$"
+ USEREMAIL = "$user.email$"
+ }
+}
+
+object NotificationCommand "mail-service-notification" {
+ command = [ ConfigDir + "/scripts/mail-service-notification.sh" ]
+
+ env = {
+ NOTIFICATIONTYPE = "$notification.type$"
+ SERVICENAME = "$service.name$"
+ HOSTNAME = "$host.name$"
+ HOSTDISPLAYNAME = "$host.display_name$"
+ HOSTADDRESS = "$address$"
+ SERVICESTATE = "$service.state$"
+ LONGDATETIME = "$icinga.long_date_time$"
+ SERVICEOUTPUT = "$service.output$"
+ NOTIFICATIONAUTHORNAME = "$notification.author$"
+ NOTIFICATIONCOMMENT = "$notification.comment$"
+ HOSTDISPLAYNAME = "$host.display_name$"
+ SERVICEDISPLAYNAME = "$service.display_name$"
+ USEREMAIL = "$user.email$"
+ }
+}
+
+*/
+
diff --git a/etc/icinga2/conf.d/downtimes.conf b/etc/icinga2/conf.d/downtimes.conf
new file mode 100644
index 0000000..0bed647
--- /dev/null
+++ b/etc/icinga2/conf.d/downtimes.conf
@@ -0,0 +1,20 @@
+/**
+ * The example downtime apply rule.
+ */
+
+apply ScheduledDowntime "backup-downtime" to Service {
+ author = "icingaadmin"
+ comment = "Scheduled downtime for backup"
+
+ ranges = {
+ monday = service.vars.backup_downtime
+ tuesday = service.vars.backup_downtime
+ wednesday = service.vars.backup_downtime
+ thursday = service.vars.backup_downtime
+ friday = service.vars.backup_downtime
+ saturday = service.vars.backup_downtime
+ sunday = service.vars.backup_downtime
+ }
+
+ assign where service.vars.backup_downtime != ""
+}
diff --git a/etc/icinga2/conf.d/groups.conf b/etc/icinga2/conf.d/groups.conf
new file mode 100644
index 0000000..e6004a3
--- /dev/null
+++ b/etc/icinga2/conf.d/groups.conf
@@ -0,0 +1,37 @@
+/**
+ * Host group examples.
+ */
+
+object HostGroup "linux-servers" {
+ display_name = "Linux Servers"
+
+ assign where host.vars.os == "Linux"
+}
+
+object HostGroup "windows-servers" {
+ display_name = "Windows Servers"
+
+ assign where host.vars.os == "Windows"
+}
+
+/**
+ * Service group examples.
+ */
+
+object ServiceGroup "ping" {
+ display_name = "Ping Checks"
+
+ assign where match("ping*", service.name)
+}
+
+object ServiceGroup "http" {
+ display_name = "HTTP Checks"
+
+ assign where match("http*", service.check_command)
+}
+
+object ServiceGroup "disk" {
+ display_name = "Disk Checks"
+
+ assign where match("disk*", service.check_command)
+}
diff --git a/etc/icinga2/conf.d/hosts.conf b/etc/icinga2/conf.d/hosts.conf
new file mode 100644
index 0000000..0118f03
--- /dev/null
+++ b/etc/icinga2/conf.d/hosts.conf
@@ -0,0 +1,52 @@
+/*
+ * 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 variable `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 = "/icingaweb2"
+ //}
+
+ /* Define disks and attributes for service apply rules in `services.conf`. */
+ vars.disks["disk"] = {
+ /* No parameters. */
+ }
+ vars.disks["disk /"] = {
+ disk_partitions = "/"
+ }
+
+ /* Define notification mail attributes for notification apply rules in `notifications.conf`. */
+ vars.notification["mail"] = {
+ /* The UserGroup `icingaadmins` is defined in `users.conf`. */
+ groups = [ "icingaadmins" ]
+ }
+}
+
diff --git a/etc/icinga2/conf.d/notifications.conf b/etc/icinga2/conf.d/notifications.conf
new file mode 100644
index 0000000..ac65875
--- /dev/null
+++ b/etc/icinga2/conf.d/notifications.conf
@@ -0,0 +1,33 @@
+/**
+ * The example notification apply rules.
+ *
+ * Only applied if host/service objects have
+ * the custom variable `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 = host.vars.notification.mail.groups
+ users = host.vars.notification.mail.users
+
+ //interval = 2h
+
+ //vars.notification_logtosyslog = true
+
+ assign where host.vars.notification.mail
+}
+
+apply Notification "mail-icingaadmin" to Service {
+ import "mail-service-notification"
+ user_groups = host.vars.notification.mail.groups
+ users = host.vars.notification.mail.users
+
+ //interval = 2h
+
+ //vars.notification_logtosyslog = true
+
+ assign where host.vars.notification.mail
+}
diff --git a/etc/icinga2/conf.d/services.conf b/etc/icinga2/conf.d/services.conf
new file mode 100644
index 0000000..c8e1b3c
--- /dev/null
+++ b/etc/icinga2/conf.d/services.conf
@@ -0,0 +1,117 @@
+/*
+ * Service apply rules.
+ *
+ * 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"
+
+ assign where host.address
+}
+
+apply Service "ping6" {
+ import "generic-service"
+
+ check_command = "ping6"
+
+ assign where host.address6
+}
+
+/*
+ * Apply the `ssh` service to all hosts
+ * with the `address` attribute defined and
+ * the custom variable `os` set to `Linux`.
+ */
+apply Service "ssh" {
+ import "generic-service"
+
+ check_command = "ssh"
+
+ assign where (host.address || host.address6) && host.vars.os == "Linux"
+}
+
+
+
+apply Service for (http_vhost => config in host.vars.http_vhosts) {
+ import "generic-service"
+
+ check_command = "http"
+
+ vars += config
+}
+
+apply Service for (disk => config in host.vars.disks) {
+ import "generic-service"
+
+ check_command = "disk"
+
+ vars += config
+}
+
+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
+}
+
+
+
diff --git a/etc/icinga2/conf.d/templates.conf b/etc/icinga2/conf.d/templates.conf
new file mode 100644
index 0000000..5655e3f
--- /dev/null
+++ b/etc/icinga2/conf.d/templates.conf
@@ -0,0 +1,83 @@
+/*
+ * Generic template examples.
+ */
+
+
+/**
+ * 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"
+}
+
+/**
+ * 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
+}
+
+/**
+ * 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 ]
+
+ vars += {
+ // notification_icingaweb2url = "https://www.example.com/icingaweb2"
+ // notification_from = "Icinga 2 Host Monitoring <icinga@example.com>"
+ notification_logtosyslog = false
+ }
+
+ 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 ]
+
+ vars += {
+ // notification_icingaweb2url = "https://www.example.com/icingaweb2"
+ // notification_from = "Icinga 2 Service Monitoring <icinga@example.com>"
+ notification_logtosyslog = false
+ }
+
+ period = "24x7"
+}
diff --git a/etc/icinga2/conf.d/timeperiods.conf b/etc/icinga2/conf.d/timeperiods.conf
new file mode 100644
index 0000000..ea162ff
--- /dev/null
+++ b/etc/icinga2/conf.d/timeperiods.conf
@@ -0,0 +1,35 @@
+/**
+ * Sample timeperiods for Icinga 2.
+ * Check the documentation for details.
+ */
+
+object TimePeriod "24x7" {
+ display_name = "Icinga 2 24x7 TimePeriod"
+ ranges = {
+ "monday" = "00:00-24:00"
+ "tuesday" = "00:00-24:00"
+ "wednesday" = "00:00-24:00"
+ "thursday" = "00:00-24:00"
+ "friday" = "00:00-24:00"
+ "saturday" = "00:00-24:00"
+ "sunday" = "00:00-24:00"
+ }
+}
+
+object TimePeriod "9to5" {
+ display_name = "Icinga 2 9to5 TimePeriod"
+ ranges = {
+ "monday" = "09:00-17:00"
+ "tuesday" = "09:00-17:00"
+ "wednesday" = "09:00-17:00"
+ "thursday" = "09:00-17:00"
+ "friday" = "09:00-17:00"
+ }
+}
+
+object TimePeriod "never" {
+ display_name = "Icinga 2 never TimePeriod"
+ ranges = {
+ }
+}
+
diff --git a/etc/icinga2/conf.d/users.conf b/etc/icinga2/conf.d/users.conf
new file mode 100644
index 0000000..515ef21
--- /dev/null
+++ b/etc/icinga2/conf.d/users.conf
@@ -0,0 +1,17 @@
+/**
+ * The example user 'icingaadmin' and the example
+ * group 'icingaadmins'.
+ */
+
+object User "icingaadmin" {
+ import "generic-user"
+
+ display_name = "Icinga 2 Admin"
+ groups = [ "icingaadmins" ]
+
+ email = "icinga@localhost"
+}
+
+object UserGroup "icingaadmins" {
+ display_name = "Icinga 2 Admin Group"
+}
diff --git a/etc/icinga2/conf.d/win32/hosts.conf b/etc/icinga2/conf.d/win32/hosts.conf
new file mode 100644
index 0000000..ecee11a
--- /dev/null
+++ b/etc/icinga2/conf.d/win32/hosts.conf
@@ -0,0 +1,43 @@
+/*
+ * 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 variable `os` for hostgroup assignment in `groups.conf`. */
+ vars.os = "Windows"
+
+ /* Define disks and attributes for service apply rules in `services.conf`. */
+ vars.disks["disk"] = {
+ /* No parameters. */
+ }
+ vars.disks["disk C:"] = {
+ disk_win_path = "C:"
+ }
+
+ /* Define notification mail attributes for notification apply rules in `notifications.conf`. */
+ vars.notification["mail"] = {
+ /* The UserGroup `icingaadmins` is defined in `users.conf`. */
+ groups = [ "icingaadmins" ]
+ }
+}
+
diff --git a/etc/icinga2/conf.d/win32/services.conf b/etc/icinga2/conf.d/win32/services.conf
new file mode 100644
index 0000000..929be54
--- /dev/null
+++ b/etc/icinga2/conf.d/win32/services.conf
@@ -0,0 +1,92 @@
+/*
+ * Service apply rules.
+ *
+ * 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-windows"
+
+ assign where host.address
+}
+
+apply Service "ping6" {
+ import "generic-service"
+
+ check_command = "ping6-windows"
+
+ assign where host.address6
+}
+
+apply Service for (disk => config in host.vars.disks) {
+ import "generic-service"
+
+ check_command = "disk-windows"
+
+ vars += config
+}
+
+apply Service "icinga" {
+ import "generic-service"
+
+ check_command = "icinga"
+
+ assign where host.name == NodeName
+}
+
+apply Service "load" {
+ import "generic-service"
+
+ check_command = "load-windows"
+
+ /* 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-windows"
+
+ assign where host.name == NodeName
+}
+
+apply Service "swap" {
+ import "generic-service"
+
+ check_command = "swap-windows"
+
+ assign where host.name == NodeName
+}
+
+apply Service "users" {
+ import "generic-service"
+
+ check_command = "users-windows"
+
+ assign where host.name == NodeName
+}
+
diff --git a/etc/icinga2/constants.conf.cmake b/etc/icinga2/constants.conf.cmake
new file mode 100644
index 0000000..1dae310
--- /dev/null
+++ b/etc/icinga2/constants.conf.cmake
@@ -0,0 +1,28 @@
+/**
+ * This file defines global constants which can be used in
+ * the other configuration files.
+ */
+
+/* The directory which contains the plugins from the Monitoring Plugins project. */
+const PluginDir = "@ICINGA2_PLUGINDIR@"
+
+/* The directory which contains the Manubulon plugins.
+ * Check the documentation, chapter "SNMP Manubulon Plugin Check Commands", for details.
+ */
+const ManubulonPluginDir = "@ICINGA2_PLUGINDIR@"
+
+/* The directory which you use to store additional plugins which ITL provides user contributed command definitions for.
+ * Check the documentation, chapter "Plugins Contribution", for details.
+ */
+const PluginContribDir = "@ICINGA2_PLUGINDIR@"
+
+/* Our local instance name. By default this is the server's hostname as returned by `hostname --fqdn`.
+ * This should be the common name from the API certificate.
+ */
+//const NodeName = "localhost"
+
+/* Our local zone name. */
+const ZoneName = NodeName
+
+/* Secret key for remote node tickets */
+const TicketSalt = ""
diff --git a/etc/icinga2/features-available/api.conf b/etc/icinga2/features-available/api.conf
new file mode 100644
index 0000000..b072a44
--- /dev/null
+++ b/etc/icinga2/features-available/api.conf
@@ -0,0 +1,10 @@
+/**
+ * The API listener is used for distributed monitoring setups.
+ */
+
+object ApiListener "api" {
+ //accept_config = false
+ //accept_commands = false
+
+ ticket_salt = TicketSalt
+}
diff --git a/etc/icinga2/features-available/checker.conf b/etc/icinga2/features-available/checker.conf
new file mode 100644
index 0000000..6f003b8
--- /dev/null
+++ b/etc/icinga2/features-available/checker.conf
@@ -0,0 +1,5 @@
+/**
+ * The checker component takes care of executing service checks.
+ */
+
+object CheckerComponent "checker" { }
diff --git a/etc/icinga2/features-available/command.conf b/etc/icinga2/features-available/command.conf
new file mode 100644
index 0000000..ffdd143
--- /dev/null
+++ b/etc/icinga2/features-available/command.conf
@@ -0,0 +1,7 @@
+/**
+ * The ExternalCommandListener implements support for the external
+ * commands pipe.
+ */
+
+object ExternalCommandListener "command" { }
+
diff --git a/etc/icinga2/features-available/compatlog.conf b/etc/icinga2/features-available/compatlog.conf
new file mode 100644
index 0000000..6f5cf5f
--- /dev/null
+++ b/etc/icinga2/features-available/compatlog.conf
@@ -0,0 +1,7 @@
+/**
+ * The CompatLogger type is responsible for writing log files in a format
+ * that is compatible with Icinga 1.x.
+ */
+
+object CompatLogger "compatlog" { }
+
diff --git a/etc/icinga2/features-available/debuglog.conf b/etc/icinga2/features-available/debuglog.conf
new file mode 100644
index 0000000..e66518f
--- /dev/null
+++ b/etc/icinga2/features-available/debuglog.conf
@@ -0,0 +1,10 @@
+/**
+ * The FileLogger type writes log information to a log file.
+ * Unlike the mainlog feature this sets up a logger
+ * with severity "debug".
+ */
+
+object FileLogger "debug-file" {
+ severity = "debug"
+ path = LogDir + "/debug.log"
+}
diff --git a/etc/icinga2/features-available/elasticsearch.conf b/etc/icinga2/features-available/elasticsearch.conf
new file mode 100644
index 0000000..8014913
--- /dev/null
+++ b/etc/icinga2/features-available/elasticsearch.conf
@@ -0,0 +1,8 @@
+object ElasticsearchWriter "elasticsearch" {
+ //host = "127.0.0.1"
+ //port = 9200
+ //index = "icinga2"
+ //enable_send_perfdata = false
+ //flush_threshold = 1024
+ //flush_interval = 10s
+}
diff --git a/etc/icinga2/features-available/gelf.conf b/etc/icinga2/features-available/gelf.conf
new file mode 100644
index 0000000..c14c864
--- /dev/null
+++ b/etc/icinga2/features-available/gelf.conf
@@ -0,0 +1,10 @@
+/**
+ * The GelfWriter type writes event log entries
+ * to a GELF tcp socket provided by Graylog,
+ * Logstash or any other receiver.
+ */
+
+object GelfWriter "gelf" {
+ //host = "127.0.0.1"
+ //port = 12201
+}
diff --git a/etc/icinga2/features-available/graphite.conf b/etc/icinga2/features-available/graphite.conf
new file mode 100644
index 0000000..ae8a928
--- /dev/null
+++ b/etc/icinga2/features-available/graphite.conf
@@ -0,0 +1,9 @@
+/**
+ * The GraphiteWriter type writes check result metrics and
+ * performance data to a graphite tcp socket.
+ */
+
+object GraphiteWriter "graphite" {
+ //host = "127.0.0.1"
+ //port = 2003
+}
diff --git a/etc/icinga2/features-available/icingadb.conf b/etc/icinga2/features-available/icingadb.conf
new file mode 100644
index 0000000..9951c83
--- /dev/null
+++ b/etc/icinga2/features-available/icingadb.conf
@@ -0,0 +1,5 @@
+object IcingaDB "icingadb" {
+ //host = "127.0.0.1"
+ //port = 6380
+ //password = "xxx"
+}
diff --git a/etc/icinga2/features-available/ido-mysql.conf b/etc/icinga2/features-available/ido-mysql.conf
new file mode 100644
index 0000000..7b44c23
--- /dev/null
+++ b/etc/icinga2/features-available/ido-mysql.conf
@@ -0,0 +1,11 @@
+/**
+ * The IdoMysqlConnection type implements MySQL support
+ * for DB IDO.
+ */
+
+object IdoMysqlConnection "ido-mysql" {
+ //user = "icinga"
+ //password = "icinga"
+ //host = "localhost"
+ //database = "icinga"
+}
diff --git a/etc/icinga2/features-available/ido-pgsql.conf b/etc/icinga2/features-available/ido-pgsql.conf
new file mode 100644
index 0000000..9f3c132
--- /dev/null
+++ b/etc/icinga2/features-available/ido-pgsql.conf
@@ -0,0 +1,11 @@
+/**
+ * The IdoPgsqlConnection type implements PostgreSQL support
+ * for DB IDO.
+ */
+
+object IdoPgsqlConnection "ido-pgsql" {
+ //user = "icinga"
+ //password = "icinga"
+ //host = "localhost"
+ //database = "icinga"
+}
diff --git a/etc/icinga2/features-available/influxdb.conf b/etc/icinga2/features-available/influxdb.conf
new file mode 100644
index 0000000..f0af37b
--- /dev/null
+++ b/etc/icinga2/features-available/influxdb.conf
@@ -0,0 +1,25 @@
+/**
+ * The InfluxdbWriter type writes check result metrics and
+ * performance data to an InfluxDB v1 HTTP API
+ */
+
+object InfluxdbWriter "influxdb" {
+ //host = "127.0.0.1"
+ //port = 8086
+ //database = "icinga2"
+ //flush_threshold = 1024
+ //flush_interval = 10s
+ //host_template = {
+ // measurement = "$host.check_command$"
+ // tags = {
+ // hostname = "$host.name$"
+ // }
+ //}
+ //service_template = {
+ // measurement = "$service.check_command$"
+ // tags = {
+ // hostname = "$host.name$"
+ // service = "$service.name$"
+ // }
+ //}
+}
diff --git a/etc/icinga2/features-available/influxdb2.conf b/etc/icinga2/features-available/influxdb2.conf
new file mode 100644
index 0000000..53f7a21
--- /dev/null
+++ b/etc/icinga2/features-available/influxdb2.conf
@@ -0,0 +1,27 @@
+/**
+ * The Influxdb2Writer type writes check result metrics and
+ * performance data to an InfluxDB v2 HTTP API
+ */
+
+object Influxdb2Writer "influxdb2" {
+ //host = "127.0.0.1"
+ //port = 8086
+ //organization = "monitoring"
+ //bucket = "icinga2"
+ //auth_token = "ABCDEvwxyz0189-_"
+ //flush_threshold = 1024
+ //flush_interval = 10s
+ //host_template = {
+ // measurement = "$host.check_command$"
+ // tags = {
+ // hostname = "$host.name$"
+ // }
+ //}
+ //service_template = {
+ // measurement = "$service.check_command$"
+ // tags = {
+ // hostname = "$host.name$"
+ // service = "$service.name$"
+ // }
+ //}
+}
diff --git a/etc/icinga2/features-available/livestatus.conf b/etc/icinga2/features-available/livestatus.conf
new file mode 100644
index 0000000..246c085
--- /dev/null
+++ b/etc/icinga2/features-available/livestatus.conf
@@ -0,0 +1,6 @@
+/**
+ * The LivestatusListener type implements the Livestatus query protocol.
+ */
+
+object LivestatusListener "livestatus" { }
+
diff --git a/etc/icinga2/features-available/mainlog.conf b/etc/icinga2/features-available/mainlog.conf
new file mode 100644
index 0000000..a3bb19d
--- /dev/null
+++ b/etc/icinga2/features-available/mainlog.conf
@@ -0,0 +1,8 @@
+/**
+ * The FileLogger type writes log information to a file.
+ */
+
+object FileLogger "main-log" {
+ severity = "information"
+ path = LogDir + "/icinga2.log"
+}
diff --git a/etc/icinga2/features-available/notification.conf b/etc/icinga2/features-available/notification.conf
new file mode 100644
index 0000000..3f9a88e
--- /dev/null
+++ b/etc/icinga2/features-available/notification.conf
@@ -0,0 +1,5 @@
+/**
+ * The notification component is responsible for sending notifications.
+ */
+
+object NotificationComponent "notification" { }
diff --git a/etc/icinga2/features-available/opentsdb.conf b/etc/icinga2/features-available/opentsdb.conf
new file mode 100644
index 0000000..471a622
--- /dev/null
+++ b/etc/icinga2/features-available/opentsdb.conf
@@ -0,0 +1,25 @@
+/**
+ * The OpenTsdbWriter type writes check result metrics and
+ * performance data to a OpenTSDB tcp socket.
+ */
+
+object OpenTsdbWriter "opentsdb" {
+ //host = "127.0.0.1"
+ //port = 4242
+ //enable_generic_metrics = false
+
+ // Custom Tagging, refer to Icinga object type documentation for
+ // OpenTsdbWriter
+ //host_template = {
+ // metric = "icinga.host"
+ // tags = {
+ // zone = "$host.zone$"
+ // }
+ //}
+ //service_template = {
+ // metric = "icinga.service.$service.check_command$"
+ // tags = {
+ // zone = "$service.zone$"
+ // }
+ //}
+}
diff --git a/etc/icinga2/features-available/perfdata.conf b/etc/icinga2/features-available/perfdata.conf
new file mode 100644
index 0000000..3ba8635
--- /dev/null
+++ b/etc/icinga2/features-available/perfdata.conf
@@ -0,0 +1,6 @@
+/**
+ * The PerfdataWriter type writes performance data files and rotates
+ * them in a regular interval.
+ */
+
+object PerfdataWriter "perfdata" { }
diff --git a/etc/icinga2/features-available/statusdata.conf b/etc/icinga2/features-available/statusdata.conf
new file mode 100644
index 0000000..bb81c96
--- /dev/null
+++ b/etc/icinga2/features-available/statusdata.conf
@@ -0,0 +1,8 @@
+/**
+ * The StatusDataWriter type periodically updates the status.dat and objects.cache
+ * files. These are used by the Icinga 1.x CGIs to display the state of
+ * hosts and services.
+ */
+
+object StatusDataWriter "status" { }
+
diff --git a/etc/icinga2/features-available/syslog.conf b/etc/icinga2/features-available/syslog.conf
new file mode 100644
index 0000000..3b794b4
--- /dev/null
+++ b/etc/icinga2/features-available/syslog.conf
@@ -0,0 +1,8 @@
+/**
+ * The SyslogLogger type writes log information to syslog.
+ */
+
+object SyslogLogger "syslog" {
+ severity = "warning"
+}
+
diff --git a/etc/icinga2/features-available/windowseventlog.conf b/etc/icinga2/features-available/windowseventlog.conf
new file mode 100644
index 0000000..8e5c0ae
--- /dev/null
+++ b/etc/icinga2/features-available/windowseventlog.conf
@@ -0,0 +1,8 @@
+/**
+ * The WindowsEventLogLogger type writes log information to the Windows Event Log.
+ */
+
+object WindowsEventLogLogger "windowseventlog" {
+ severity = "information"
+}
+
diff --git a/etc/icinga2/features-enabled/checker.conf b/etc/icinga2/features-enabled/checker.conf
new file mode 100644
index 0000000..0b39650
--- /dev/null
+++ b/etc/icinga2/features-enabled/checker.conf
@@ -0,0 +1 @@
+include "../features-available/checker.conf"
diff --git a/etc/icinga2/features-enabled/notification.conf b/etc/icinga2/features-enabled/notification.conf
new file mode 100644
index 0000000..b549ad4
--- /dev/null
+++ b/etc/icinga2/features-enabled/notification.conf
@@ -0,0 +1 @@
+include "../features-available/notification.conf"
diff --git a/etc/icinga2/features-enabled/windowseventlog.conf b/etc/icinga2/features-enabled/windowseventlog.conf
new file mode 100644
index 0000000..8e57873
--- /dev/null
+++ b/etc/icinga2/features-enabled/windowseventlog.conf
@@ -0,0 +1 @@
+include "../features-available/windowseventlog.conf"
diff --git a/etc/icinga2/icinga2.conf b/etc/icinga2/icinga2.conf
new file mode 100644
index 0000000..17513a3
--- /dev/null
+++ b/etc/icinga2/icinga2.conf
@@ -0,0 +1,57 @@
+/**
+ * Icinga 2 configuration file
+ * - this is where you define settings for the Icinga application including
+ * which hosts/services to check.
+ *
+ * For an overview of all available configuration options please refer
+ * to the documentation that is distributed as part of Icinga 2.
+ */
+
+/**
+ * The constants.conf defines global constants.
+ */
+include "constants.conf"
+
+/**
+ * The zones.conf defines zones for a cluster setup.
+ * Not required for single instance setups.
+ */
+include "zones.conf"
+
+/**
+ * The Icinga Template Library (ITL) provides a number of useful templates
+ * and command definitions.
+ * Common monitoring plugin command definitions are included separately.
+ */
+include <itl>
+include <plugins>
+include <plugins-contrib>
+include <manubulon>
+
+/**
+ * This includes the Icinga 2 Windows plugins. These command definitions
+ * are required on a master node when a client is used as command endpoint.
+ */
+include <windows-plugins>
+
+/**
+ * This includes the NSClient++ check commands. These command definitions
+ * are required on a master node when a client is used as command endpoint.
+ */
+include <nscp>
+
+/**
+ * The features-available directory contains a number of configuration
+ * files for features which can be enabled and disabled using the
+ * icinga2 feature enable / icinga2 feature disable CLI commands.
+ * These commands work by creating and removing symbolic links in
+ * the features-enabled directory.
+ */
+include "features-enabled/*.conf"
+
+/**
+ * Although in theory you could define all your objects in this file
+ * the preferred way is to create separate directories and files in the conf.d
+ * directory. Each of these files must have the file extension ".conf".
+ */
+include_recursive "conf.d"
diff --git a/etc/icinga2/scripts/mail-host-notification.sh b/etc/icinga2/scripts/mail-host-notification.sh
new file mode 100755
index 0000000..744481a
--- /dev/null
+++ b/etc/icinga2/scripts/mail-host-notification.sh
@@ -0,0 +1,169 @@
+#!/usr/bin/env bash
+# Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+
+# Except of function urlencode which is Copyright (C) by Brian White (brian@aljex.com) used under MIT license
+
+PROG="`basename $0`"
+ICINGA2HOST="`hostname`"
+MAILBIN="mail"
+
+if [ -z "`which $MAILBIN`" ] ; then
+ echo "$MAILBIN not found in \$PATH. Consider installing it."
+ exit 1
+fi
+
+## Function helpers
+Usage() {
+cat << EOF
+
+Required parameters:
+ -d LONGDATETIME (\$icinga.long_date_time\$)
+ -l HOSTNAME (\$host.name\$)
+ -n HOSTDISPLAYNAME (\$host.display_name\$)
+ -o HOSTOUTPUT (\$host.output\$)
+ -r USEREMAIL (\$user.email\$)
+ -s HOSTSTATE (\$host.state\$)
+ -t NOTIFICATIONTYPE (\$notification.type\$)
+
+Optional parameters:
+ -4 HOSTADDRESS (\$address\$)
+ -6 HOSTADDRESS6 (\$address6\$)
+ -b NOTIFICATIONAUTHORNAME (\$notification.author\$)
+ -c NOTIFICATIONCOMMENT (\$notification.comment\$)
+ -i ICINGAWEB2URL (\$notification_icingaweb2url\$, Default: unset)
+ -f MAILFROM (\$notification_mailfrom\$, requires GNU mailutils (Debian/Ubuntu) or mailx (RHEL/SUSE))
+ -v (\$notification_sendtosyslog\$, Default: false)
+
+EOF
+}
+
+Help() {
+ Usage;
+ exit 0;
+}
+
+Error() {
+ if [ "$1" ]; then
+ echo $1
+ fi
+ Usage;
+ exit 1;
+}
+
+urlencode() {
+ local LANG=C i=0 c e s="$1"
+
+ while [ $i -lt ${#1} ]; do
+ [ "$i" -eq 0 ] || s="${s#?}"
+ c=${s%"${s#?}"}
+ [ -z "${c#[[:alnum:].~_-]}" ] || c=$(printf '%%%02X' "'$c")
+ e="${e}${c}"
+ i=$((i + 1))
+ done
+ echo "$e"
+}
+
+## Main
+while getopts 4:6::b:c:d:f:hi:l:n:o:r:s:t:v: opt
+do
+ case "$opt" in
+ 4) HOSTADDRESS=$OPTARG ;;
+ 6) HOSTADDRESS6=$OPTARG ;;
+ b) NOTIFICATIONAUTHORNAME=$OPTARG ;;
+ c) NOTIFICATIONCOMMENT=$OPTARG ;;
+ d) LONGDATETIME=$OPTARG ;; # required
+ f) MAILFROM=$OPTARG ;;
+ h) Help ;;
+ i) ICINGAWEB2URL=$OPTARG ;;
+ l) HOSTNAME=$OPTARG ;; # required
+ n) HOSTDISPLAYNAME=$OPTARG ;; # required
+ o) HOSTOUTPUT=$OPTARG ;; # required
+ r) USEREMAIL=$OPTARG ;; # required
+ s) HOSTSTATE=$OPTARG ;; # required
+ t) NOTIFICATIONTYPE=$OPTARG ;; # required
+ v) VERBOSE=$OPTARG ;;
+ \?) echo "ERROR: Invalid option -$OPTARG" >&2
+ Error ;;
+ :) echo "Missing option argument for -$OPTARG" >&2
+ Error ;;
+ *) echo "Unimplemented option: -$OPTARG" >&2
+ Error ;;
+ esac
+done
+
+shift $((OPTIND - 1))
+
+## Keep formatting in sync with mail-service-notification.sh
+for P in LONGDATETIME HOSTNAME HOSTDISPLAYNAME HOSTOUTPUT HOSTSTATE USEREMAIL NOTIFICATIONTYPE ; do
+ eval "PAR=\$${P}"
+
+ if [ ! "$PAR" ] ; then
+ Error "Required parameter '$P' is missing."
+ fi
+done
+
+## Build the message's subject
+SUBJECT="[$NOTIFICATIONTYPE] Host $HOSTDISPLAYNAME is $HOSTSTATE!"
+
+## Build the notification message
+NOTIFICATION_MESSAGE=`cat << EOF
+***** Host Monitoring on $ICINGA2HOST *****
+
+$HOSTDISPLAYNAME is $HOSTSTATE!
+
+Info: $HOSTOUTPUT
+
+When: $LONGDATETIME
+Host: $HOSTNAME
+EOF
+`
+
+## Check whether IPv4 was specified.
+if [ -n "$HOSTADDRESS" ] ; then
+ NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
+IPv4: $HOSTADDRESS"
+fi
+
+## Check whether IPv6 was specified.
+if [ -n "$HOSTADDRESS6" ] ; then
+ NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
+IPv6: $HOSTADDRESS6"
+fi
+
+## Check whether author and comment was specified.
+if [ -n "$NOTIFICATIONCOMMENT" ] ; then
+ NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
+
+Comment by $NOTIFICATIONAUTHORNAME:
+ $NOTIFICATIONCOMMENT"
+fi
+
+## Check whether Icinga Web 2 URL was specified.
+if [ -n "$ICINGAWEB2URL" ] ; then
+ NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
+
+$ICINGAWEB2URL/monitoring/host/show?host=$(urlencode "$HOSTNAME")"
+fi
+
+## Check whether verbose mode was enabled and log to syslog.
+if [ "$VERBOSE" = "true" ] ; then
+ logger "$PROG sends $SUBJECT => $USEREMAIL"
+fi
+
+## Send the mail using the $MAILBIN command.
+## If an explicit sender was specified, try to set it.
+if [ -n "$MAILFROM" ] ; then
+
+ ## Modify this for your own needs!
+
+ ## Debian/Ubuntu use mailutils which requires `-a` to append the header
+ if [ -f /etc/debian_version ]; then
+ /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | $MAILBIN -a "From: $MAILFROM" -s "$SUBJECT" $USEREMAIL
+ ## Other distributions (RHEL/SUSE/etc.) prefer mailx which sets a sender address with `-r`
+ else
+ /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | $MAILBIN -r "$MAILFROM" -s "$SUBJECT" $USEREMAIL
+ fi
+
+else
+ /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" \
+ | $MAILBIN -s "$SUBJECT" $USEREMAIL
+fi
diff --git a/etc/icinga2/scripts/mail-service-notification.sh b/etc/icinga2/scripts/mail-service-notification.sh
new file mode 100755
index 0000000..8e560ac
--- /dev/null
+++ b/etc/icinga2/scripts/mail-service-notification.sh
@@ -0,0 +1,174 @@
+#!/usr/bin/env bash
+# Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+
+# Except of function urlencode which is Copyright (C) by Brian White (brian@aljex.com) used under MIT license
+
+PROG="`basename $0`"
+ICINGA2HOST="`hostname`"
+MAILBIN="mail"
+
+if [ -z "`which $MAILBIN`" ] ; then
+ echo "$MAILBIN not found in \$PATH. Consider installing it."
+ exit 1
+fi
+
+## Function helpers
+Usage() {
+cat << EOF
+
+Required parameters:
+ -d LONGDATETIME (\$icinga.long_date_time\$)
+ -e SERVICENAME (\$service.name\$)
+ -l HOSTNAME (\$host.name\$)
+ -n HOSTDISPLAYNAME (\$host.display_name\$)
+ -o SERVICEOUTPUT (\$service.output\$)
+ -r USEREMAIL (\$user.email\$)
+ -s SERVICESTATE (\$service.state\$)
+ -t NOTIFICATIONTYPE (\$notification.type\$)
+ -u SERVICEDISPLAYNAME (\$service.display_name\$)
+
+Optional parameters:
+ -4 HOSTADDRESS (\$address\$)
+ -6 HOSTADDRESS6 (\$address6\$)
+ -b NOTIFICATIONAUTHORNAME (\$notification.author\$)
+ -c NOTIFICATIONCOMMENT (\$notification.comment\$)
+ -i ICINGAWEB2URL (\$notification_icingaweb2url\$, Default: unset)
+ -f MAILFROM (\$notification_mailfrom\$, requires GNU mailutils (Debian/Ubuntu) or mailx (RHEL/SUSE))
+ -v (\$notification_sendtosyslog\$, Default: false)
+
+EOF
+}
+
+Help() {
+ Usage;
+ exit 0;
+}
+
+Error() {
+ if [ "$1" ]; then
+ echo $1
+ fi
+ Usage;
+ exit 1;
+}
+
+urlencode() {
+ local LANG=C i=0 c e s="$1"
+
+ while [ $i -lt ${#1} ]; do
+ [ "$i" -eq 0 ] || s="${s#?}"
+ c=${s%"${s#?}"}
+ [ -z "${c#[[:alnum:].~_-]}" ] || c=$(printf '%%%02X' "'$c")
+ e="${e}${c}"
+ i=$((i + 1))
+ done
+ echo "$e"
+}
+
+## Main
+while getopts 4:6:b:c:d:e:f:hi:l:n:o:r:s:t:u:v: opt
+do
+ case "$opt" in
+ 4) HOSTADDRESS=$OPTARG ;;
+ 6) HOSTADDRESS6=$OPTARG ;;
+ b) NOTIFICATIONAUTHORNAME=$OPTARG ;;
+ c) NOTIFICATIONCOMMENT=$OPTARG ;;
+ d) LONGDATETIME=$OPTARG ;; # required
+ e) SERVICENAME=$OPTARG ;; # required
+ f) MAILFROM=$OPTARG ;;
+ h) Usage ;;
+ i) ICINGAWEB2URL=$OPTARG ;;
+ l) HOSTNAME=$OPTARG ;; # required
+ n) HOSTDISPLAYNAME=$OPTARG ;; # required
+ o) SERVICEOUTPUT=$OPTARG ;; # required
+ r) USEREMAIL=$OPTARG ;; # required
+ s) SERVICESTATE=$OPTARG ;; # required
+ t) NOTIFICATIONTYPE=$OPTARG ;; # required
+ u) SERVICEDISPLAYNAME=$OPTARG ;; # required
+ v) VERBOSE=$OPTARG ;;
+ \?) echo "ERROR: Invalid option -$OPTARG" >&2
+ Usage ;;
+ :) echo "Missing option argument for -$OPTARG" >&2
+ Usage ;;
+ *) echo "Unimplemented option: -$OPTARG" >&2
+ Usage ;;
+ esac
+done
+
+shift $((OPTIND - 1))
+
+## Keep formatting in sync with mail-host-notification.sh
+for P in LONGDATETIME HOSTNAME HOSTDISPLAYNAME SERVICENAME SERVICEDISPLAYNAME SERVICEOUTPUT SERVICESTATE USEREMAIL NOTIFICATIONTYPE ; do
+ eval "PAR=\$${P}"
+
+ if [ ! "$PAR" ] ; then
+ Error "Required parameter '$P' is missing."
+ fi
+done
+
+## Build the message's subject
+SUBJECT="[$NOTIFICATIONTYPE] $SERVICEDISPLAYNAME on $HOSTDISPLAYNAME is $SERVICESTATE!"
+
+## Build the notification message
+NOTIFICATION_MESSAGE=`cat << EOF
+***** Service Monitoring on $ICINGA2HOST *****
+
+$SERVICEDISPLAYNAME on $HOSTDISPLAYNAME is $SERVICESTATE!
+
+Info: $SERVICEOUTPUT
+
+When: $LONGDATETIME
+Service: $SERVICENAME
+Host: $HOSTNAME
+EOF
+`
+
+## Check whether IPv4 was specified.
+if [ -n "$HOSTADDRESS" ] ; then
+ NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
+IPv4: $HOSTADDRESS"
+fi
+
+## Check whether IPv6 was specified.
+if [ -n "$HOSTADDRESS6" ] ; then
+ NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
+IPv6: $HOSTADDRESS6"
+fi
+
+## Check whether author and comment was specified.
+if [ -n "$NOTIFICATIONCOMMENT" ] ; then
+ NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
+
+Comment by $NOTIFICATIONAUTHORNAME:
+ $NOTIFICATIONCOMMENT"
+fi
+
+## Check whether Icinga Web 2 URL was specified.
+if [ -n "$ICINGAWEB2URL" ] ; then
+ NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE
+
+$ICINGAWEB2URL/monitoring/service/show?host=$(urlencode "$HOSTNAME")&service=$(urlencode "$SERVICENAME")"
+fi
+
+## Check whether verbose mode was enabled and log to syslog.
+if [ "$VERBOSE" = "true" ] ; then
+ logger "$PROG sends $SUBJECT => $USEREMAIL"
+fi
+
+## Send the mail using the $MAILBIN command.
+## If an explicit sender was specified, try to set it.
+if [ -n "$MAILFROM" ] ; then
+
+ ## Modify this for your own needs!
+
+ ## Debian/Ubuntu use mailutils which requires `-a` to append the header
+ if [ -f /etc/debian_version ]; then
+ /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | $MAILBIN -a "From: $MAILFROM" -s "$SUBJECT" $USEREMAIL
+ ## Other distributions (RHEL/SUSE/etc.) prefer mailx which sets a sender address with `-r`
+ else
+ /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | $MAILBIN -r "$MAILFROM" -s "$SUBJECT" $USEREMAIL
+ fi
+
+else
+ /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" \
+ | $MAILBIN -s "$SUBJECT" $USEREMAIL
+fi
diff --git a/etc/icinga2/win32/constants.conf b/etc/icinga2/win32/constants.conf
new file mode 100644
index 0000000..f793d1d
--- /dev/null
+++ b/etc/icinga2/win32/constants.conf
@@ -0,0 +1,28 @@
+/**
+ * This file defines global constants which can be used in
+ * the other configuration files.
+ */
+
+/* The directory which contains the plugins from the Monitoring Plugins project. */
+const PluginDir = PrefixDir + "/sbin"
+
+/* The directory which contains the Manubulon plugins.
+ * Check the documentation, chapter "SNMP Manubulon Plugin Check Commands", for details.
+ */
+const ManubulonPluginDir = PrefixDir + "/sbin"
+
+/* The directory which you use to store additional plugins which ITL provides user contributed command definitions for.
+ * Check the documentation, chapter "Plugins Contribution", for details.
+ */
+const PluginContribDir = PrefixDir + "/sbin"
+
+/* Our local instance name. By default this is the server's hostname as returned by `hostname --fqdn`.
+ * This should be the common name from the API certificate.
+ */
+//const NodeName = "localhost"
+
+/* Our local zone name. */
+const ZoneName = NodeName
+
+/* Secret key for remote node tickets */
+const TicketSalt = ""
diff --git a/etc/icinga2/win32/icinga2.conf b/etc/icinga2/win32/icinga2.conf
new file mode 100644
index 0000000..cc47c41
--- /dev/null
+++ b/etc/icinga2/win32/icinga2.conf
@@ -0,0 +1,55 @@
+/**
+ * Icinga 2 configuration file
+ * - this is where you define settings for the Icinga application including
+ * which hosts/services to check.
+ *
+ * For an overview of all available configuration options please refer
+ * to the documentation that is distributed as part of Icinga 2.
+ */
+
+/**
+ * The constants.conf defines global constants.
+ */
+include "constants.conf"
+
+/**
+ * The zones.conf defines zones for a cluster setup.
+ * Not required for single instance setups.
+ */
+include "zones.conf"
+
+/**
+ * The Icinga Template Library (ITL) provides a number of useful templates
+ * and command definitions.
+ * Common monitoring plugin command definitions are included separately.
+ */
+include <itl>
+include <plugins>
+include <plugins-contrib>
+include <manubulon>
+
+/**
+ * This includes the Icinga 2 Windows plugins.
+ */
+include <windows-plugins>
+
+/**
+ * This includes the NSClient++ check commands.
+ */
+include <nscp>
+
+/**
+ * The features-available directory contains a number of configuration
+ * files for features which can be enabled and disabled using the
+ * icinga2 feature enable / icinga2 feature disable CLI commands.
+ * These commands work by creating and removing symbolic links in
+ * the features-enabled directory.
+ */
+include "features-enabled/*.conf"
+
+/**
+ * Although in theory you could define all your objects in this file
+ * the preferred way is to create separate directories and files in the conf.d
+ * directory. Each of these files must have the file extension ".conf".
+ */
+include_recursive "conf.d"
diff --git a/etc/icinga2/zones.conf b/etc/icinga2/zones.conf
new file mode 100644
index 0000000..70ac766
--- /dev/null
+++ b/etc/icinga2/zones.conf
@@ -0,0 +1,63 @@
+/*
+ * Endpoint and Zone configuration for a cluster setup
+ * This local example requires `NodeName` defined in
+ * constants.conf.
+ */
+
+object Endpoint NodeName {
+ host = NodeName
+}
+
+object Zone ZoneName {
+ endpoints = [ NodeName ]
+}
+
+/*
+ * Defines a global zone for distributed setups with masters,
+ * satellites and clients.
+ * This is required to sync configuration commands,
+ * templates, apply rules, etc. to satellite and clients.
+ * All nodes require the same configuration and must
+ * have `accept_config` enabled in the `api` feature.
+ */
+
+object Zone "global-templates" {
+ global = true
+}
+
+/*
+ * Defines a global zone for the Icinga Director.
+ * This is required to sync configuration commands,
+ * templates, apply rules, etc. to satellite and clients.
+ * All nodes require the same configuration and must
+ * have `accept_config` enabled in the `api` feature.
+ */
+
+object Zone "director-global" {
+ global = true
+}
+
+/*
+ * Read the documentation on how to configure
+ * a cluster setup with multiple zones.
+ */
+
+/*
+object Endpoint "master.example.org" {
+ host = "master.example.org"
+}
+
+object Endpoint "satellite.example.org" {
+ host = "satellite.example.org"
+}
+
+object Zone "master" {
+ endpoints = [ "master.example.org" ]
+}
+
+object Zone "satellite" {
+ parent = "master"
+ endpoints = [ "satellite.example.org" ]
+}
+*/
+
diff --git a/etc/icinga2/zones.d/README b/etc/icinga2/zones.d/README
new file mode 100644
index 0000000..e378eae
--- /dev/null
+++ b/etc/icinga2/zones.d/README
@@ -0,0 +1,2 @@
+Please check the documentation for more details:
+https://icinga.com/docs/icinga2/latest/doc/06-distributed-monitoring/
diff --git a/etc/initsystem/CMakeLists.txt b/etc/initsystem/CMakeLists.txt
new file mode 100644
index 0000000..eb0f9f2
--- /dev/null
+++ b/etc/initsystem/CMakeLists.txt
@@ -0,0 +1,44 @@
+# Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+
+
+
+if(NOT WIN32)
+ configure_file(icinga2.sysconfig.cmake ${CMAKE_CURRENT_BINARY_DIR}/initsystem/icinga2.sysconfig @ONLY)
+ get_filename_component(ICINGA2_SYSCONFIGFILE_NAME ${ICINGA2_SYSCONFIGFILE} NAME)
+ get_filename_component(ICINGA2_SYSCONFIGFILE_DIR ${ICINGA2_SYSCONFIGFILE} PATH)
+ install(
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/initsystem/icinga2.sysconfig
+ DESTINATION ${ICINGA2_SYSCONFIGFILE_DIR}
+ RENAME ${ICINGA2_SYSCONFIGFILE_NAME}
+ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
+ )
+
+ configure_file(prepare-dirs.cmake ${CMAKE_CURRENT_BINARY_DIR}/initsystem/prepare-dirs @ONLY)
+ configure_file(safe-reload.cmake ${CMAKE_CURRENT_BINARY_DIR}/initsystem/safe-reload @ONLY)
+ install(
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/initsystem/prepare-dirs ${CMAKE_CURRENT_BINARY_DIR}/initsystem/safe-reload
+ DESTINATION ${CMAKE_INSTALL_PREFIX}/lib/icinga2
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+ )
+
+ # required for packaging on Gentoo, see Bug #6498
+ option (INSTALL_SYSTEMD_SERVICE_AND_INITSCRIPT
+ "Force install both the systemd service definition file and the SysV initscript in parallel, regardless of how USE_SYSTEMD is set. Only use this for special packaging purposes and if you know what you are doing" OFF)
+
+ if (NOT USE_SYSTEMD OR INSTALL_SYSTEMD_SERVICE_AND_INITSCRIPT)
+ configure_file(icinga2.init.d.cmake ${CMAKE_CURRENT_BINARY_DIR}/initsystem/icinga2 @ONLY)
+ install(
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/initsystem/icinga2
+ DESTINATION ${CMAKE_INSTALL_SYSCONFDIR}/init.d
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+ )
+ endif()
+
+ if (USE_SYSTEMD OR INSTALL_SYSTEMD_SERVICE_AND_INITSCRIPT)
+ configure_file(icinga2.service.cmake ${CMAKE_CURRENT_BINARY_DIR}/initsystem/icinga2.service @ONLY)
+ install(
+ FILES ${CMAKE_CURRENT_BINARY_DIR}/initsystem/icinga2.service
+ DESTINATION ${DESTDIR}/usr/lib/systemd/system
+ PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
+ )
+ endif()
+endif()
diff --git a/etc/initsystem/icinga2.init.d.cmake b/etc/initsystem/icinga2.init.d.cmake
new file mode 100644
index 0000000..56588a7
--- /dev/null
+++ b/etc/initsystem/icinga2.init.d.cmake
@@ -0,0 +1,198 @@
+#!/bin/sh
+#
+# chkconfig: 35 90 12
+# description: Icinga 2
+#
+### BEGIN INIT INFO
+# Provides: icinga2
+# Required-Start: $remote_fs $syslog $network
+# Required-Stop: $remote_fs $syslog $network
+# Should-Start: mysql postgresql
+# Should-Stop: mysql postgresql
+# Default-Start: 2 3 5
+# Default-Stop: 0 1 6
+# Short-Description: icinga2 host/service/network monitoring and management system
+# Description: Icinga 2 is a monitoring and management system for hosts, services and networks.
+### END INIT INFO
+
+# Get function from functions library
+if [ -f /etc/rc.d/init.d/functions ]; then
+ . /etc/rc.d/init.d/functions
+elif [ -f /etc/init.d/functions ]; then
+ . /etc/init.d/functions
+fi
+
+# load system specific defines
+SYSCONFIGFILE=@ICINGA2_SYSCONFIGFILE@
+if [ -f "$SYSCONFIGFILE" ]; then
+ . "$SYSCONFIGFILE"
+else
+ echo "Couldn't load system specific defines from $SYSCONFIGFILE. Using defaults."
+fi
+
+# Set defaults, to overwrite see "@ICINGA2_SYSCONFIGFILE@"
+
+: "${ICINGA2_USER:="@ICINGA2_USER@"}"
+: "${ICINGA2_GROUP:="@ICINGA2_GROUP@"}"
+: "${ICINGA2_COMMAND_GROUP:="@ICINGA2_COMMAND_GROUP@"}"
+: "${DAEMON:="@CMAKE_INSTALL_FULL_SBINDIR@/icinga2"}"
+: "${ICINGA2_CONFIG_FILE:="@ICINGA2_CONFIGDIR@/icinga2.conf"}"
+: "${ICINGA2_ERROR_LOG:=@ICINGA2_LOGDIR@/error.log}"
+: "${ICINGA2_STARTUP_LOG:=@ICINGA2_LOGDIR@/startup.log}"
+: "${ICINGA2_PID_FILE:="@ICINGA2_INITRUNDIR@/icinga2.pid"}"
+
+# Load extra environment variables
+if [ -f /etc/default/icinga2 ]; then
+ . /etc/default/icinga2
+fi
+
+test -x "$DAEMON" || exit 5
+
+if [ ! -e "$ICINGA2_CONFIG_FILE" ]; then
+ echo "Config file '$ICINGA2_CONFIG_FILE' does not exist."
+ exit 6
+fi
+
+if ! getent passwd "$ICINGA2_USER" >/dev/null 2>&1; then
+ echo "Icinga user '$ICINGA2_USER' does not exist. Exiting."
+ exit 6
+fi
+
+if ! getent group "$ICINGA2_GROUP" >/dev/null 2>&1; then
+ echo "Icinga group '$ICINGA2_GROUP' does not exist. Exiting."
+ exit 6
+fi
+
+if ! getent group "$ICINGA2_COMMAND_GROUP" >/dev/null 2>&1; then
+ echo "Icinga command group '$ICINGA2_COMMAND_GROUP' does not exist. Exiting."
+ exit 6
+fi
+
+# Start Icinga 2
+start() {
+ printf "Starting Icinga 2: "
+ @CMAKE_INSTALL_PREFIX@/lib/icinga2/prepare-dirs "$SYSCONFIGFILE"
+
+ if ! "$DAEMON" daemon -c "$ICINGA2_CONFIG_FILE" -d -e "$ICINGA2_ERROR_LOG" > "$ICINGA2_STARTUP_LOG" 2>&1; then
+ echo "Error starting Icinga. Check '$ICINGA2_STARTUP_LOG' for details."
+ exit 1
+ else
+ echo "Done"
+ fi
+}
+
+# Restart Icinga 2
+stop() {
+ printf "Stopping Icinga 2: "
+
+ if [ ! -e "$ICINGA2_PID_FILE" ]; then
+ echo "The PID file '$ICINGA2_PID_FILE' does not exist."
+ if [ "x$1" = "xnofail" ]; then
+ return
+ else
+ exit 7
+ fi
+ fi
+
+ pid=`cat "$ICINGA2_PID_FILE"`
+
+ if icinga2 internal signal -s SIGINT -p "$pid" >/dev/null 2>&1; then
+ for i in 1 2 3 4 5 6 7 8 9 10; do
+ if ! icinga2 internal signal -s SIGCHLD -p "$pid" >/dev/null 2>&1; then
+ break
+ fi
+
+ printf '.'
+ sleep 3
+ done
+ fi
+
+ if icinga2 internal signal -s SIGCHLD -p "$pid" >/dev/null 2>&1; then
+ icinga2 internal signal -s SIGKILL -p "$pid" >/dev/null 2>&1
+ fi
+
+ echo "Done"
+}
+
+# Reload Icinga 2
+reload() {
+ exec @CMAKE_INSTALL_PREFIX@/lib/icinga2/safe-reload "$SYSCONFIGFILE"
+}
+
+# Check the Icinga 2 configuration
+checkconfig() {
+ printf "Checking configuration: "
+
+ if ! "$DAEMON" daemon -c "$ICINGA2_CONFIG_FILE" -C > "$ICINGA2_STARTUP_LOG" 2>&1; then
+ if [ "x$1" = "x" ]; then
+ cat "$ICINGA2_STARTUP_LOG"
+ echo "Icinga 2 detected configuration errors. Check '$ICINGA2_STARTUP_LOG' for details."
+ exit 1
+ else
+ echo "Not ${1}ing Icinga 2 due to configuration errors. Check '$ICINGA2_STARTUP_LOG' for details."
+ if [ "x$2" = "xfail" ]; then
+ exit 1
+ fi
+ fi
+ fi
+
+ echo "Done"
+ # no arguments requires full output
+ if [ "x$1" = "x" ]; then
+ cat "$ICINGA2_STARTUP_LOG"
+ fi
+}
+
+# Print status for Icinga 2
+status() {
+ printf "Icinga 2 status: "
+
+ if [ ! -e "$ICINGA2_PID_FILE" ]; then
+ echo "Not running"
+ exit 3
+ fi
+
+ pid=`cat "$ICINGA2_PID_FILE"`
+ if icinga2 internal signal -s SIGCHLD -p "$pid" >/dev/null 2>&1; then
+ echo "Running"
+ else
+ echo "Not running"
+ exit 3
+ fi
+}
+
+### main logic ###
+case "$1" in
+ start)
+ checkconfig start fail
+ start
+ ;;
+ stop)
+ stop
+ ;;
+ status)
+ status
+ ;;
+ restart)
+ checkconfig restart fail
+ stop nofail
+ start
+ ;;
+ condrestart)
+ status > /dev/null 2>&1 || exit 0
+ checkconfig restart fail
+ stop nofail
+ start
+ ;;
+ reload)
+ reload
+ ;;
+ checkconfig)
+ checkconfig
+ ;;
+ *)
+ echo "Usage: $0 {start|stop|restart|reload|checkconfig|status}"
+ exit 3
+esac
+
+exit 0
diff --git a/etc/initsystem/icinga2.service.cmake b/etc/initsystem/icinga2.service.cmake
new file mode 100644
index 0000000..ca85930
--- /dev/null
+++ b/etc/initsystem/icinga2.service.cmake
@@ -0,0 +1,30 @@
+[Unit]
+Description=Icinga host/service/network monitoring system
+Requires=network-online.target
+After=syslog.target network-online.target icingadb-redis.service postgresql.service mariadb.service carbon-cache.service carbon-relay.service
+
+[Service]
+Type=notify
+NotifyAccess=all
+Environment="ICINGA2_ERROR_LOG=@ICINGA2_LOGDIR@/error.log"
+EnvironmentFile=@ICINGA2_SYSCONFIGFILE@
+ExecStartPre=@CMAKE_INSTALL_PREFIX@/lib/icinga2/prepare-dirs @ICINGA2_SYSCONFIGFILE@
+ExecStart=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2 daemon --close-stdio -e ${ICINGA2_ERROR_LOG}
+PIDFile=@ICINGA2_INITRUNDIR@/icinga2.pid
+ExecReload=@CMAKE_INSTALL_PREFIX@/lib/icinga2/safe-reload @ICINGA2_SYSCONFIGFILE@
+TimeoutStartSec=30m
+KillMode=mixed
+
+# Systemd >228 enforces a lower process number for services.
+# Depending on the distribution and Systemd version, this must
+# be explicitly raised. Packages will set the needed values
+# into /etc/systemd/system/icinga2.service.d/limits.conf
+#
+# Please check the troubleshooting documentation for further details.
+# The values below can be used as examples for customized service files.
+
+#TasksMax=infinity
+#LimitNPROC=62883
+
+[Install]
+WantedBy=multi-user.target
diff --git a/etc/initsystem/icinga2.service.limits.conf b/etc/initsystem/icinga2.service.limits.conf
new file mode 100644
index 0000000..dea0cde
--- /dev/null
+++ b/etc/initsystem/icinga2.service.limits.conf
@@ -0,0 +1,9 @@
+# Icinga 2 sets Systemd default values to extend OS defaults.
+#
+# Please check the troubleshooting documentation for further details.
+
+[Service]
+TasksMax=infinity
+
+# Uncomment this setting in case of further problems.
+#LimitNPROC=62883
diff --git a/etc/initsystem/icinga2.sysconfig.cmake b/etc/initsystem/icinga2.sysconfig.cmake
new file mode 100644
index 0000000..167c125
--- /dev/null
+++ b/etc/initsystem/icinga2.sysconfig.cmake
@@ -0,0 +1,15 @@
+#This is the default environment Icinga 2 runs with.
+#Make your changes here.
+
+#DAEMON=@CMAKE_INSTALL_FULL_SBINDIR@/icinga2
+#ICINGA2_CONFIG_FILE=@ICINGA2_CONFIGDIR@/icinga2.conf
+#ICINGA2_INIT_RUN_DIR=@ICINGA2_INITRUNDIR@
+#ICINGA2_PID_FILE=@ICINGA2_INITRUNDIR@/icinga2.pid
+#ICINGA2_LOG_DIR=@ICINGA2_LOGDIR@
+#ICINGA2_ERROR_LOG=@ICINGA2_LOGDIR@/error.log
+#ICINGA2_STARTUP_LOG=@ICINGA2_LOGDIR@/startup.log
+#ICINGA2_LOG=@ICINGA2_LOGDIR@/icinga2.log
+#ICINGA2_CACHE_DIR=@ICINGA2_CACHEDIR@
+#ICINGA2_USER=@ICINGA2_USER@
+#ICINGA2_GROUP=@ICINGA2_GROUP@
+#ICINGA2_COMMAND_GROUP=@ICINGA2_COMMAND_GROUP@
diff --git a/etc/initsystem/prepare-dirs.cmake b/etc/initsystem/prepare-dirs.cmake
new file mode 100644
index 0000000..0053b90
--- /dev/null
+++ b/etc/initsystem/prepare-dirs.cmake
@@ -0,0 +1,52 @@
+#!/bin/sh
+#
+# This script prepares directories and files needed for running Icinga2
+#
+
+# Load sysconf on systems where the initsystem does not pass the environment
+if [ "$1" != "" ]; then
+ if [ -r "$1" ]; then
+ . "$1"
+ else
+ echo "Unable to read sysconf from '$1'. Exiting." && exit 6
+ fi
+fi
+
+# Set defaults, to overwrite see "@ICINGA2_SYSCONFIGFILE@"
+
+: "${ICINGA2_USER:="@ICINGA2_USER@"}"
+: "${ICINGA2_GROUP:="@ICINGA2_GROUP@"}"
+: "${ICINGA2_COMMAND_GROUP:="@ICINGA2_COMMAND_GROUP@"}"
+: "${ICINGA2_INIT_RUN_DIR:="@ICINGA2_FULL_INITRUNDIR@"}"
+: "${ICINGA2_LOG_DIR:="@ICINGA2_FULL_LOGDIR@"}"
+: "${ICINGA2_CACHE_DIR:="@ICINGA2_FULL_CACHEDIR@"}"
+
+if ! getent passwd "$ICINGA2_USER" >/dev/null 2>&1; then
+ echo "Icinga user '$ICINGA2_USER' does not exist. Exiting."
+ exit 6
+fi
+
+if ! getent group "$ICINGA2_GROUP" >/dev/null 2>&1; then
+ echo "Icinga group '$ICINGA2_GROUP' does not exist. Exiting."
+ exit 6
+fi
+
+if ! getent group "$ICINGA2_COMMAND_GROUP" >/dev/null 2>&1; then
+ echo "Icinga command group '$ICINGA2_COMMAND_GROUP' does not exist. Exiting."
+ exit 6
+fi
+
+if [ ! -e "$ICINGA2_INIT_RUN_DIR" ]; then
+ mkdir -m 755 "$ICINGA2_INIT_RUN_DIR"
+ mkdir -m 2750 "$ICINGA2_INIT_RUN_DIR"/cmd
+fi
+
+chown -R "$ICINGA2_USER:$ICINGA2_COMMAND_GROUP" "$ICINGA2_INIT_RUN_DIR"
+
+test -e "$ICINGA2_LOG_DIR" || install -m 750 -o "$ICINGA2_USER" -g "$ICINGA2_COMMAND_GROUP" -d "$ICINGA2_LOG_DIR"
+
+if type restorecon >/dev/null 2>&1; then
+ restorecon -R "$ICINGA2_INIT_RUN_DIR"/
+fi
+
+test -e "$ICINGA2_CACHE_DIR" || install -m 750 -o "$ICINGA2_USER" -g "$ICINGA2_COMMAND_GROUP" -d "$ICINGA2_CACHE_DIR"
diff --git a/etc/initsystem/safe-reload.cmake b/etc/initsystem/safe-reload.cmake
new file mode 100644
index 0000000..0cba415
--- /dev/null
+++ b/etc/initsystem/safe-reload.cmake
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+# Load sysconf on systems where the initsystem does not pass the environment
+if [ "$1" != "" ]; then
+ if [ -r "$1" ]; then
+ . "$1"
+ else
+ echo "Unable to read sysconf from '$1'. Exiting."
+ exit 6
+ fi
+fi
+
+# Set defaults, to overwrite see "@ICINGA2_SYSCONFIGFILE@"
+
+: "${ICINGA2_PID_FILE:="@ICINGA2_FULL_INITRUNDIR@/icinga2.pid"}"
+: "${DAEMON:="@CMAKE_INSTALL_FULL_SBINDIR@/icinga2"}"
+
+printf "Validating config files: "
+
+OUTPUTFILE=`mktemp`
+
+if type selinuxenabled >/dev/null 2>&1; then
+ if selinuxenabled; then
+ chcon -t icinga2_tmp_t "$OUTPUTFILE" >/dev/null 2>&1
+ fi
+fi
+
+if ! "$DAEMON" daemon --validate --color > "$OUTPUTFILE"; then
+ echo "Failed"
+
+ cat "$OUTPUTFILE"
+ rm -f "$OUTPUTFILE"
+ exit 1
+fi
+
+echo "Done"
+rm -f "$OUTPUTFILE"
+
+printf "Reloading Icinga 2: "
+
+if [ ! -e "$ICINGA2_PID_FILE" ]; then
+ exit 7
+fi
+
+pid=`cat "$ICINGA2_PID_FILE"`
+if ! kill -HUP "$pid" >/dev/null 2>&1; then
+ echo "Error: Icinga not running"
+ exit 7
+fi
+
+echo "Done"
+exit 0
diff --git a/etc/logrotate.d/icinga2.cmake b/etc/logrotate.d/icinga2.cmake
new file mode 100644
index 0000000..f0a9e59
--- /dev/null
+++ b/etc/logrotate.d/icinga2.cmake
@@ -0,0 +1,21 @@
+@ICINGA2_LOGDIR@/icinga2.log @ICINGA2_LOGDIR@/debug.log {
+ daily
+ rotate 7@LOGROTATE_USE_SU@
+ compress
+ delaycompress
+ missingok
+ notifempty@LOGROTATE_CREATE@
+ postrotate
+ /bin/kill -USR1 $(cat @ICINGA2_INITRUNDIR@/icinga2.pid 2> /dev/null) 2> /dev/null || true
+ endscript
+}
+
+@ICINGA2_LOGDIR@/error.log {
+ daily
+ rotate 90@LOGROTATE_USE_SU@
+ compress
+ delaycompress
+ missingok
+ notifempty@LOGROTATE_CREATE@
+ # TODO: figure out how to get Icinga to re-open this log file
+}