ICINGA2 + Check WMI Plus でWindowsホストの監視(3)
今回は、ひととおり監視の設定が出来るようになったIcingaでメール通知の設定をします。
メール送信には mailx パッケージが必要なので、あらかじめインストールしておきます。
sudo yum -y install mailx
- ユーザーの作成
メールの送信先となるユーザーを作成します。 - Notification templateの作成
次に、Notification templateを作成します。
Icinga Directorから、Notification - Notification templates を選択して、Host template, Service template をそれぞれ作成します。必要に応じ、State and transition state filterを設定することで、通知する内容をフィルタすることが出来ます。
- Notificationの作成
最後に、Notificationを作成します。
Icinga Directorから、Notification - Notification templates を選択して、下記のように作成します。
ここで、先ほど作成したNotification Templateを指定します。
以上をDeployすることで、通知が有効になります。
デフォルトでは、サーバがMXレコードを引きメールを送信しようとします。
SMTPサーバを指定したい場合は、スクリプトを修正する必要があります。
- /etc/icinga2/scripts/mail-service-notification.sh
- /etc/icinga2/scripts/mail-host-notification.sh
#!/usr/bin/env bashこのMAILBINの内容に、SMTPサーバの指定を追加してしまいます。
#
# Copyright (C) 2012-2018 Icinga Development Team (https://icinga.com/)
# Except of function urlencode which is Copyright (C) by Brian White (brian@aljex.com) used under MIT licensePROG="`basename $0`"
ICINGA2HOST="`hostname`"
MAILBIN="mail"
MAILBIN="mail -S smtp=[smtpserver] "