From f3f2e4ff9f1a2e3b6e8f3af538702dc65c846039 Mon Sep 17 00:00:00 2001 From: mhoellein Date: Fri, 10 Jul 2020 12:08:02 +0200 Subject: [PATCH] committing changes in /etc after apt run Package changes: -icinga2 2.8.1-0ubuntu2 amd64 -icinga2-bin 2.8.1-0ubuntu2 amd64 -icinga2-common 2.8.1-0ubuntu2 all +libboost-context1.67.0-icinga 1.67.0-13.1.bionic amd64 +libboost-coroutine1.67.0-icinga 1.67.0-13.1.bionic amd64 +libboost-filesystem1.67.0-icinga 1.67.0-13.1.bionic amd64 +libboost-program-options1.67.0-icinga 1.67.0-13.1.bionic amd64 +libboost-regex1.67.0-icinga 1.67.0-13.1.bionic amd64 +libboost-system1.67.0-icinga 1.67.0-13.1.bionic amd64 +libboost-thread1.67.0-icinga 1.67.0-13.1.bionic amd64 -libicinga2 2.8.1-0ubuntu2 amd64 --- .etckeeper | 92 +++++++++++++++++-- icinga2/conf.d/commands.conf | 8 +- icinga2/conf.d/hosts.conf | 2 +- icinga2/conf.d/notifications.conf | 2 +- icinga2/conf.d/services.conf | 2 +- icinga2/features-available/checker.conf | 2 - icinga2/features-available/command.conf | 2 - icinga2/features-available/compatlog.conf | 2 - icinga2/features-available/debuglog.conf | 3 +- icinga2/features-available/elasticsearch.conf | 2 - icinga2/features-available/gelf.conf | 2 - icinga2/features-available/graphite.conf | 2 - icinga2/features-available/influxdb.conf | 2 - icinga2/features-available/livestatus.conf | 4 +- icinga2/features-available/mainlog.conf | 3 +- icinga2/features-available/notification.conf | 4 +- icinga2/features-available/opentsdb.conf | 2 - icinga2/features-available/perfdata.conf | 2 - icinga2/features-available/statusdata.conf | 2 - icinga2/scripts/mail-host-notification.sh | 43 ++++++--- icinga2/scripts/mail-service-notification.sh | 44 ++++++--- icinga2/zones.d/README | 4 +- init.d/icinga2 | 16 ++-- logrotate.d/icinga2 | 1 - systemd/system/icinga2.service.d/limits.conf | 9 ++ 25 files changed, 174 insertions(+), 83 deletions(-) create mode 100644 systemd/system/icinga2.service.d/limits.conf diff --git a/.etckeeper b/.etckeeper index ed2a533d..073c5cf6 100755 --- a/.etckeeper +++ b/.etckeeper @@ -2735,51 +2735,127 @@ maybe chmod 0644 'icinga/objects/usg.cfg' maybe chown 'nagios' 'icinga2' maybe chgrp 'nagios' 'icinga2' maybe chmod 0750 'icinga2' -maybe chmod 0755 'icinga2/conf.d' +maybe chown 'nagios' 'icinga2/conf.d' +maybe chgrp 'nagios' 'icinga2/conf.d' +maybe chmod 0750 'icinga2/conf.d' +maybe chown 'nagios' 'icinga2/conf.d/api-users.conf' +maybe chgrp 'nagios' 'icinga2/conf.d/api-users.conf' maybe chmod 0644 'icinga2/conf.d/api-users.conf' +maybe chown 'nagios' 'icinga2/conf.d/app.conf' +maybe chgrp 'nagios' 'icinga2/conf.d/app.conf' maybe chmod 0644 'icinga2/conf.d/app.conf' +maybe chown 'nagios' 'icinga2/conf.d/apt.conf' +maybe chgrp 'nagios' 'icinga2/conf.d/apt.conf' maybe chmod 0644 'icinga2/conf.d/apt.conf' +maybe chown 'nagios' 'icinga2/conf.d/commands.conf' +maybe chgrp 'nagios' 'icinga2/conf.d/commands.conf' maybe chmod 0644 'icinga2/conf.d/commands.conf' +maybe chown 'nagios' 'icinga2/conf.d/downtimes.conf' +maybe chgrp 'nagios' 'icinga2/conf.d/downtimes.conf' maybe chmod 0644 'icinga2/conf.d/downtimes.conf' +maybe chown 'nagios' 'icinga2/conf.d/groups.conf' +maybe chgrp 'nagios' 'icinga2/conf.d/groups.conf' maybe chmod 0644 'icinga2/conf.d/groups.conf' +maybe chown 'nagios' 'icinga2/conf.d/hosts.conf' +maybe chgrp 'nagios' 'icinga2/conf.d/hosts.conf' maybe chmod 0644 'icinga2/conf.d/hosts.conf' +maybe chown 'nagios' 'icinga2/conf.d/notifications.conf' +maybe chgrp 'nagios' 'icinga2/conf.d/notifications.conf' maybe chmod 0644 'icinga2/conf.d/notifications.conf' +maybe chown 'nagios' 'icinga2/conf.d/services.conf' +maybe chgrp 'nagios' 'icinga2/conf.d/services.conf' maybe chmod 0644 'icinga2/conf.d/services.conf' +maybe chown 'nagios' 'icinga2/conf.d/templates.conf' +maybe chgrp 'nagios' 'icinga2/conf.d/templates.conf' maybe chmod 0644 'icinga2/conf.d/templates.conf' +maybe chown 'nagios' 'icinga2/conf.d/timeperiods.conf' +maybe chgrp 'nagios' 'icinga2/conf.d/timeperiods.conf' maybe chmod 0644 'icinga2/conf.d/timeperiods.conf' +maybe chown 'nagios' 'icinga2/conf.d/users.conf' +maybe chgrp 'nagios' 'icinga2/conf.d/users.conf' maybe chmod 0644 'icinga2/conf.d/users.conf' -maybe chmod 0644 'icinga2/constants.conf' -maybe chmod 0755 'icinga2/features-available' +maybe chown 'nagios' 'icinga2/constants.conf' +maybe chgrp 'nagios' 'icinga2/constants.conf' +maybe chmod 0640 'icinga2/constants.conf' +maybe chown 'nagios' 'icinga2/features-available' +maybe chgrp 'nagios' 'icinga2/features-available' +maybe chmod 0750 'icinga2/features-available' +maybe chown 'nagios' 'icinga2/features-available/api.conf' +maybe chgrp 'nagios' 'icinga2/features-available/api.conf' maybe chmod 0644 'icinga2/features-available/api.conf' +maybe chown 'nagios' 'icinga2/features-available/checker.conf' +maybe chgrp 'nagios' 'icinga2/features-available/checker.conf' maybe chmod 0644 'icinga2/features-available/checker.conf' +maybe chown 'nagios' 'icinga2/features-available/command.conf' +maybe chgrp 'nagios' 'icinga2/features-available/command.conf' maybe chmod 0644 'icinga2/features-available/command.conf' +maybe chown 'nagios' 'icinga2/features-available/compatlog.conf' +maybe chgrp 'nagios' 'icinga2/features-available/compatlog.conf' maybe chmod 0644 'icinga2/features-available/compatlog.conf' +maybe chown 'nagios' 'icinga2/features-available/debuglog.conf' +maybe chgrp 'nagios' 'icinga2/features-available/debuglog.conf' maybe chmod 0644 'icinga2/features-available/debuglog.conf' +maybe chown 'nagios' 'icinga2/features-available/elasticsearch.conf' +maybe chgrp 'nagios' 'icinga2/features-available/elasticsearch.conf' maybe chmod 0644 'icinga2/features-available/elasticsearch.conf' +maybe chown 'nagios' 'icinga2/features-available/gelf.conf' +maybe chgrp 'nagios' 'icinga2/features-available/gelf.conf' maybe chmod 0644 'icinga2/features-available/gelf.conf' +maybe chown 'nagios' 'icinga2/features-available/graphite.conf' +maybe chgrp 'nagios' 'icinga2/features-available/graphite.conf' maybe chmod 0644 'icinga2/features-available/graphite.conf' +maybe chown 'nagios' 'icinga2/features-available/influxdb.conf' +maybe chgrp 'nagios' 'icinga2/features-available/influxdb.conf' maybe chmod 0644 'icinga2/features-available/influxdb.conf' +maybe chown 'nagios' 'icinga2/features-available/livestatus.conf' +maybe chgrp 'nagios' 'icinga2/features-available/livestatus.conf' maybe chmod 0644 'icinga2/features-available/livestatus.conf' +maybe chown 'nagios' 'icinga2/features-available/mainlog.conf' +maybe chgrp 'nagios' 'icinga2/features-available/mainlog.conf' maybe chmod 0644 'icinga2/features-available/mainlog.conf' +maybe chown 'nagios' 'icinga2/features-available/notification.conf' +maybe chgrp 'nagios' 'icinga2/features-available/notification.conf' maybe chmod 0644 'icinga2/features-available/notification.conf' +maybe chown 'nagios' 'icinga2/features-available/opentsdb.conf' +maybe chgrp 'nagios' 'icinga2/features-available/opentsdb.conf' maybe chmod 0644 'icinga2/features-available/opentsdb.conf' +maybe chown 'nagios' 'icinga2/features-available/perfdata.conf' +maybe chgrp 'nagios' 'icinga2/features-available/perfdata.conf' maybe chmod 0644 'icinga2/features-available/perfdata.conf' +maybe chown 'nagios' 'icinga2/features-available/statusdata.conf' +maybe chgrp 'nagios' 'icinga2/features-available/statusdata.conf' maybe chmod 0644 'icinga2/features-available/statusdata.conf' +maybe chown 'nagios' 'icinga2/features-available/syslog.conf' +maybe chgrp 'nagios' 'icinga2/features-available/syslog.conf' maybe chmod 0644 'icinga2/features-available/syslog.conf' -maybe chmod 0755 'icinga2/features-enabled' -maybe chmod 0644 'icinga2/icinga2.conf' +maybe chown 'nagios' 'icinga2/features-enabled' +maybe chgrp 'nagios' 'icinga2/features-enabled' +maybe chmod 0750 'icinga2/features-enabled' +maybe chown 'nagios' 'icinga2/icinga2.conf' +maybe chgrp 'nagios' 'icinga2/icinga2.conf' +maybe chmod 0640 'icinga2/icinga2.conf' maybe chmod 0644 'icinga2/init.conf' maybe chown 'nagios' 'icinga2/pki' maybe chgrp 'nagios' 'icinga2/pki' maybe chmod 0700 'icinga2/pki' +maybe chown 'nagios' 'icinga2/pki/ca.crt' +maybe chgrp 'nagios' 'icinga2/pki/ca.crt' maybe chmod 0644 'icinga2/pki/ca.crt' +maybe chown 'nagios' 'icinga2/pki/home.hoellein.online.crt' +maybe chgrp 'nagios' 'icinga2/pki/home.hoellein.online.crt' maybe chmod 0644 'icinga2/pki/home.hoellein.online.crt' +maybe chown 'nagios' 'icinga2/pki/home.hoellein.online.key' +maybe chgrp 'nagios' 'icinga2/pki/home.hoellein.online.key' maybe chmod 0600 'icinga2/pki/home.hoellein.online.key' maybe chmod 0755 'icinga2/scripts' maybe chmod 0755 'icinga2/scripts/mail-host-notification.sh' maybe chmod 0755 'icinga2/scripts/mail-service-notification.sh' -maybe chmod 0644 'icinga2/zones.conf' -maybe chmod 0755 'icinga2/zones.d' +maybe chown 'nagios' 'icinga2/zones.conf' +maybe chgrp 'nagios' 'icinga2/zones.conf' +maybe chmod 0640 'icinga2/zones.conf' +maybe chown 'nagios' 'icinga2/zones.d' +maybe chgrp 'nagios' 'icinga2/zones.d' +maybe chmod 0750 'icinga2/zones.d' maybe chmod 0644 'icinga2/zones.d/README' maybe chgrp 'icingaweb2' 'icingaweb2' maybe chmod 2770 'icingaweb2' @@ -8741,6 +8817,8 @@ maybe chmod 0755 'systemd/system/final.target.wants' maybe chmod 0755 'systemd/system/getty.target.wants' maybe chmod 0755 'systemd/system/graphical.target.wants' maybe chmod 0644 'systemd/system/hddtemp.service' +maybe chmod 0755 'systemd/system/icinga2.service.d' +maybe chmod 0644 'systemd/system/icinga2.service.d/limits.conf' maybe chmod 0755 'systemd/system/mariadb.service.d' maybe chmod 0644 'systemd/system/mariadb.service.d/migrated-from-my.cnf-settings.conf' maybe chmod 0755 'systemd/system/multi-user.target.wants' diff --git a/icinga2/conf.d/commands.conf b/icinga2/conf.d/commands.conf index 9c515381..bd511ceb 100644 --- a/icinga2/conf.d/commands.conf +++ b/icinga2/conf.d/commands.conf @@ -7,7 +7,7 @@ */ object NotificationCommand "mail-host-notification" { - command = [ SysconfDir + "/icinga2/scripts/mail-host-notification.sh" ] + command = [ ConfigDir + "/scripts/mail-host-notification.sh" ] arguments += { "-4" = "$notification_address$" @@ -66,7 +66,7 @@ object NotificationCommand "mail-host-notification" { } object NotificationCommand "mail-service-notification" { - command = [ SysconfDir + "/icinga2/scripts/mail-service-notification.sh" ] + command = [ ConfigDir + "/scripts/mail-service-notification.sh" ] arguments += { "-4" = "$notification_address$" @@ -146,7 +146,7 @@ object NotificationCommand "mail-service-notification" { /* object NotificationCommand "mail-host-notification" { - command = [ SysconfDir + "/icinga2/scripts/mail-host-notification.sh" ] + command = [ ConfigDir + "/scripts/mail-host-notification.sh" ] env = { NOTIFICATIONTYPE = "$notification.type$" @@ -164,7 +164,7 @@ object NotificationCommand "mail-host-notification" { } object NotificationCommand "mail-service-notification" { - command = [ SysconfDir + "/icinga2/scripts/mail-service-notification.sh" ] + command = [ ConfigDir + "/scripts/mail-service-notification.sh" ] env = { NOTIFICATIONTYPE = "$notification.type$" diff --git a/icinga2/conf.d/hosts.conf b/icinga2/conf.d/hosts.conf index 5ff1f9b6..0118f033 100644 --- a/icinga2/conf.d/hosts.conf +++ b/icinga2/conf.d/hosts.conf @@ -23,7 +23,7 @@ object Host NodeName { address = "127.0.0.1" address6 = "::1" - /* Set custom attribute `os` for hostgroup assignment in `groups.conf`. */ + /* Set custom variable `os` for hostgroup assignment in `groups.conf`. */ vars.os = "Linux" /* Define http vhost attributes for service apply rules in `services.conf`. */ diff --git a/icinga2/conf.d/notifications.conf b/icinga2/conf.d/notifications.conf index 6a7e1f5a..ac658754 100644 --- a/icinga2/conf.d/notifications.conf +++ b/icinga2/conf.d/notifications.conf @@ -2,7 +2,7 @@ * The example notification apply rules. * * Only applied if host/service objects have - * the custom attribute `notification` defined + * the custom variable `notification` defined * and containing `mail` as key. * * Check `hosts.conf` for an example. diff --git a/icinga2/conf.d/services.conf b/icinga2/conf.d/services.conf index 416915bc..c8e1b3cc 100644 --- a/icinga2/conf.d/services.conf +++ b/icinga2/conf.d/services.conf @@ -42,7 +42,7 @@ apply Service "ping6" { /* * Apply the `ssh` service to all hosts * with the `address` attribute defined and - * the custom attribute `os` set to `Linux`. + * the custom variable `os` set to `Linux`. */ apply Service "ssh" { import "generic-service" diff --git a/icinga2/features-available/checker.conf b/icinga2/features-available/checker.conf index 1139e626..6f003b8f 100644 --- a/icinga2/features-available/checker.conf +++ b/icinga2/features-available/checker.conf @@ -2,6 +2,4 @@ * The checker component takes care of executing service checks. */ -library "checker" - object CheckerComponent "checker" { } diff --git a/icinga2/features-available/command.conf b/icinga2/features-available/command.conf index 35830560..ffdd143a 100644 --- a/icinga2/features-available/command.conf +++ b/icinga2/features-available/command.conf @@ -3,7 +3,5 @@ * commands pipe. */ -library "compat" - object ExternalCommandListener "command" { } diff --git a/icinga2/features-available/compatlog.conf b/icinga2/features-available/compatlog.conf index 58c5df71..6f5cf5f5 100644 --- a/icinga2/features-available/compatlog.conf +++ b/icinga2/features-available/compatlog.conf @@ -3,7 +3,5 @@ * that is compatible with Icinga 1.x. */ -library "compat" - object CompatLogger "compatlog" { } diff --git a/icinga2/features-available/debuglog.conf b/icinga2/features-available/debuglog.conf index 6e8e5813..e66518fe 100644 --- a/icinga2/features-available/debuglog.conf +++ b/icinga2/features-available/debuglog.conf @@ -6,6 +6,5 @@ object FileLogger "debug-file" { severity = "debug" - path = LocalStateDir + "/log/icinga2/debug.log" + path = LogDir + "/debug.log" } - diff --git a/icinga2/features-available/elasticsearch.conf b/icinga2/features-available/elasticsearch.conf index 86a05a24..8014913a 100644 --- a/icinga2/features-available/elasticsearch.conf +++ b/icinga2/features-available/elasticsearch.conf @@ -1,5 +1,3 @@ -library "perfdata" - object ElasticsearchWriter "elasticsearch" { //host = "127.0.0.1" //port = 9200 diff --git a/icinga2/features-available/gelf.conf b/icinga2/features-available/gelf.conf index 2db44ef7..c14c8640 100644 --- a/icinga2/features-available/gelf.conf +++ b/icinga2/features-available/gelf.conf @@ -4,8 +4,6 @@ * Logstash or any other receiver. */ -library "perfdata" - object GelfWriter "gelf" { //host = "127.0.0.1" //port = 12201 diff --git a/icinga2/features-available/graphite.conf b/icinga2/features-available/graphite.conf index f2e59d9e..ae8a9288 100644 --- a/icinga2/features-available/graphite.conf +++ b/icinga2/features-available/graphite.conf @@ -3,8 +3,6 @@ * performance data to a graphite tcp socket. */ -library "perfdata" - object GraphiteWriter "graphite" { //host = "127.0.0.1" //port = 2003 diff --git a/icinga2/features-available/influxdb.conf b/icinga2/features-available/influxdb.conf index 20f9ed25..af842357 100644 --- a/icinga2/features-available/influxdb.conf +++ b/icinga2/features-available/influxdb.conf @@ -3,8 +3,6 @@ * performance data to an InfluxDB HTTP API */ -library "perfdata" - object InfluxdbWriter "influxdb" { //host = "127.0.0.1" //port = 8086 diff --git a/icinga2/features-available/livestatus.conf b/icinga2/features-available/livestatus.conf index 45d44d6b..246c085e 100644 --- a/icinga2/features-available/livestatus.conf +++ b/icinga2/features-available/livestatus.conf @@ -1,8 +1,6 @@ /** - * The livestatus library implements the livestatus query protocol. + * The LivestatusListener type implements the Livestatus query protocol. */ -library "livestatus" - object LivestatusListener "livestatus" { } diff --git a/icinga2/features-available/mainlog.conf b/icinga2/features-available/mainlog.conf index ded9a7c7..a3bb19da 100644 --- a/icinga2/features-available/mainlog.conf +++ b/icinga2/features-available/mainlog.conf @@ -4,6 +4,5 @@ object FileLogger "main-log" { severity = "information" - path = LocalStateDir + "/log/icinga2/icinga2.log" + path = LogDir + "/icinga2.log" } - diff --git a/icinga2/features-available/notification.conf b/icinga2/features-available/notification.conf index aa22f605..3f9a88ed 100644 --- a/icinga2/features-available/notification.conf +++ b/icinga2/features-available/notification.conf @@ -1,7 +1,5 @@ /** - * The notification component takes care of executing service checks. + * The notification component is responsible for sending notifications. */ -library "notification" - object NotificationComponent "notification" { } diff --git a/icinga2/features-available/opentsdb.conf b/icinga2/features-available/opentsdb.conf index fcb547d0..540556c1 100644 --- a/icinga2/features-available/opentsdb.conf +++ b/icinga2/features-available/opentsdb.conf @@ -3,8 +3,6 @@ * performance data to a OpenTSDB tcp socket. */ -library "perfdata" - object OpenTsdbWriter "opentsdb" { //host = "127.0.0.1" //port = 4242 diff --git a/icinga2/features-available/perfdata.conf b/icinga2/features-available/perfdata.conf index 356431f3..3ba86354 100644 --- a/icinga2/features-available/perfdata.conf +++ b/icinga2/features-available/perfdata.conf @@ -3,6 +3,4 @@ * them in a regular interval. */ -library "perfdata" - object PerfdataWriter "perfdata" { } diff --git a/icinga2/features-available/statusdata.conf b/icinga2/features-available/statusdata.conf index af02aa52..bb81c961 100644 --- a/icinga2/features-available/statusdata.conf +++ b/icinga2/features-available/statusdata.conf @@ -4,7 +4,5 @@ * hosts and services. */ -library "compat" - object StatusDataWriter "status" { } diff --git a/icinga2/scripts/mail-host-notification.sh b/icinga2/scripts/mail-host-notification.sh index d6e22ce9..93f942e1 100755 --- a/icinga2/scripts/mail-host-notification.sh +++ b/icinga2/scripts/mail-host-notification.sh @@ -1,6 +1,6 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/) +#!/bin/sh +# 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`" @@ -49,6 +49,19 @@ Error() { 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 @@ -79,14 +92,14 @@ done shift $((OPTIND - 1)) -## Check required parameters (TODO: better error message) ## Keep formatting in sync with mail-service-notification.sh -if [ ! "$LONGDATETIME" ] \ -|| [ ! "$HOSTNAME" ] || [ ! "$HOSTDISPLAYNAME" ] \ -|| [ ! "$HOSTOUTPUT" ] || [ ! "$HOSTSTATE" ] \ -|| [ ! "$USEREMAIL" ] || [ ! "$NOTIFICATIONTYPE" ]; then - Error "Requirement parameters are missing." -fi +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!" @@ -128,7 +141,7 @@ fi if [ -n "$ICINGAWEB2URL" ] ; then NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE -$ICINGAWEB2URL/monitoring/host/show?host=$HOSTNAME" +$ICINGAWEB2URL/monitoring/host/show?host=$(urlencode "$HOSTNAME")" fi ## Check whether verbose mode was enabled and log to syslog. @@ -144,13 +157,15 @@ if [ -n "$MAILFROM" ] ; then ## 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 + /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | tr -d '\015' \ + | $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 + /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | tr -d '\015' \ + | $MAILBIN -r "$MAILFROM" -s "$SUBJECT" $USEREMAIL fi else - /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" \ + /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | tr -d '\015' \ | $MAILBIN -s "$SUBJECT" $USEREMAIL fi diff --git a/icinga2/scripts/mail-service-notification.sh b/icinga2/scripts/mail-service-notification.sh index b94001dc..8ccb8d45 100755 --- a/icinga2/scripts/mail-service-notification.sh +++ b/icinga2/scripts/mail-service-notification.sh @@ -1,6 +1,6 @@ -#!/usr/bin/env bash -# -# Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/) +#!/bin/sh +# 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`" @@ -51,6 +51,19 @@ Error() { 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 @@ -83,15 +96,14 @@ done shift $((OPTIND - 1)) -## Check required parameters (TODO: better error message) ## Keep formatting in sync with mail-host-notification.sh -if [ ! "$LONGDATETIME" ] \ -|| [ ! "$HOSTNAME" ] || [ ! "$HOSTDISPLAYNAME" ] \ -|| [ ! "$SERVICENAME" ] || [ ! "$SERVICEDISPLAYNAME" ] \ -|| [ ! "$SERVICEOUTPUT" ] || [ ! "$SERVICESTATE" ] \ -|| [ ! "$USEREMAIL" ] || [ ! "$NOTIFICATIONTYPE" ]; then - Error "Requirement parameters are missing." -fi +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!" @@ -134,7 +146,7 @@ fi if [ -n "$ICINGAWEB2URL" ] ; then NOTIFICATION_MESSAGE="$NOTIFICATION_MESSAGE -$ICINGAWEB2URL/monitoring/service/show?host=$HOSTNAME&service=$SERVICENAME" +$ICINGAWEB2URL/monitoring/service/show?host=$(urlencode "$HOSTNAME")&service=$(urlencode "$SERVICENAME")" fi ## Check whether verbose mode was enabled and log to syslog. @@ -150,13 +162,15 @@ if [ -n "$MAILFROM" ] ; then ## 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 + /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | tr -d '\015' \ + | $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 + /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | tr -d '\015' \ + | $MAILBIN -r "$MAILFROM" -s "$SUBJECT" $USEREMAIL fi else - /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" \ + /usr/bin/printf "%b" "$NOTIFICATION_MESSAGE" | tr -d '\015' \ | $MAILBIN -s "$SUBJECT" $USEREMAIL fi diff --git a/icinga2/zones.d/README b/icinga2/zones.d/README index ceff6bd8..e378eae9 100644 --- a/icinga2/zones.d/README +++ b/icinga2/zones.d/README @@ -1,2 +1,2 @@ -This directory contains configuration files for cluster zones. If you're not -running a cluster you can safely ignore this directory. +Please check the documentation for more details: +https://icinga.com/docs/icinga2/latest/doc/06-distributed-monitoring/ diff --git a/init.d/icinga2 b/init.d/icinga2 index 4ee354ce..daad9a94 100755 --- a/init.d/icinga2 +++ b/init.d/icinga2 @@ -47,14 +47,16 @@ trap '' 13 # SIGPIPE # check run directory check_run () { - test -d '/var/run/icinga2' || mkdir /var/run/icinga2 - test -d '/var/run/icinga2/cmd' || mkdir /var/run/icinga2/cmd + if [ ! -e '/var/run/icinga2' ]; then + mkdir /var/run/icinga2 + mkdir /var/run/icinga2/cmd - chown "$DAEMON_USER":"$DAEMON_GROUP" /var/run/icinga2 - chmod 0755 /var/run/icinga2 + chown "$DAEMON_USER":"$DAEMON_CMDGROUP" /var/run/icinga2/cmd + chmod 2710 /var/run/icinga2/cmd - chown "$DAEMON_USER":"$DAEMON_CMDGROUP" /var/run/icinga2/cmd - chmod 2710 /var/run/icinga2/cmd + chown "$DAEMON_USER":"$DAEMON_GROUP" /var/run/icinga2 + chmod 0755 /var/run/icinga2 + fi } check_config () { @@ -128,7 +130,7 @@ do_reload() { # restarting (for example, when it is sent a SIGHUP), # then implement that here. # - start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME + start-stop-daemon --stop --signal HUP --quiet --pidfile $PIDFILE --name $NAME return 0 } diff --git a/logrotate.d/icinga2 b/logrotate.d/icinga2 index 867502d0..df45df74 100644 --- a/logrotate.d/icinga2 +++ b/logrotate.d/icinga2 @@ -21,4 +21,3 @@ create 644 nagios nagios # TODO: figure out how to get Icinga to re-open this log file } - diff --git a/systemd/system/icinga2.service.d/limits.conf b/systemd/system/icinga2.service.d/limits.conf new file mode 100644 index 00000000..ad24f7ea --- /dev/null +++ b/systemd/system/icinga2.service.d/limits.conf @@ -0,0 +1,9 @@ +# Icinga 2 sets some default values to extend OS defaults +# +# Please refer to our troubleshooting documentations for details +# and reasons on these values. +[Service] +TasksMax=infinity + +# May also cause problems, uncomment if you have any +#LimitNPROC=62883 -- 2.43.0