ja:quickguides:configuration_emails_alerts

Email アラート設定

Gmail 経由でのアラートメール送信を Pandora FMS で設定するには、以下のように Pandora および Postfix を設定する必要があります。

Pandora 設定

Gmail アカウントを使用してメール送信を正しく設定するには、Pandora FMS サーバ設定ファイル(/etc/pandora/pandora_server.conf)で、mta_address 以外の以下のコメント行のすべての設定が必要です。mta_address は(postfixサーバーがインストールされている)サーバの IP アドレスもしくは localhost です。

Postfix が Pandora FMS と同じサーバにインストールされている場合は、pandora_server.conf の設定は以下のようになります。

mta_address localhost 
#mta_port 25
#mta_user myuser@mydomain.com
#mta_pass mypassword
#mta_auth LOGIN
#mta_from Pandora FMS <pandora@mydomain.com>

Pandora FMS コンソールでアラートを設定する方法を簡単に見てみましょう。

アクション設定

メールの受信者を設定するには 'mail action to XXX' を使用します。アラートが送信されるメール受信者を追加できます。

アラート設定

この場合、モジュールの設定は、モジュール設定(module configuration) > アラート(Alerts) ファイルで行われています。以下のスクリーンショットではモジュールの新しいアラートが見られます。

アラートが発報されると、アラートがアクションに割り当てられたメールアドレスにどのように届くかを確認できます。

Postfix インストール

Gmail アカウントと共に postfix サーバが正しく動作するためには、Pandora サーバに以下のパッケージがインストールされている必要があります。

yum install postfix mailx cyrus-sasl-plain cyrus-sasl cyrus-sasl-lib cyrus-sasl-md5 cyrus-sasl-scram cyrus-sasl-gssapi

Postfix 設定

Postfix をインストールし、Gmail を通しての送信以外の動作が正しくできるようになったら、以下のステップを実施します。

1– Gmail アカウントで、“less secure pass” オプションが有効になっているか確認します。https://myaccount.google.com/lesssecureapps から有効化できます。

2– /etc/postfix/main.cf を編集し、以下の行を一番後ろに追加します。

myhostname = <hostname> #Add here server hostname
relayhost = [smtp.gmail.com]:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_tls_policy_maps = hash:/etc/postfix/tls_policy
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes
smtp_tls_CAfile = /etc/pki/tls/cert.pem
smtp_tls_security_level = encrypt

3– Gmail のアドレスとパスワードを設定する /etc/postfix/sasl_passwd ファイルを作成します。

nano /etc/postfix/sasl_passwd

ファイルには、Gmail のアドレスとパスワードを含む以下の行を追加します。

[smtp.gmail.com]:587 ACCOUNT@gmail.com:PASSWORD

パーミッションを調整します。

 chmod 600 /etc/postfix/sasl_passwd
 chown root:root /etc/postfix/sasl_passwd

4– 次の内容で /etc/postfix/tls_policy ファイルを作成します。

nano /etc/postfix/tls_policy
[smtp.gmail.com]:587 encrypt

パーミッションを調整します。

chmod 600 /etc/postfix/tls_policy
chown root:root /etc/postfix/tls_policy

5– 以下のコマンドで /etc/postfix/sasl_passwd および /etc/postfix/tls_policy のハッシュインデックスを作成します。

postmap /etc/postfix/sasl_passwd && postmap /etc/postfix/tls_policy

/etc/postfix/sasl_passwd.db および /etc/postfix/tls_policy.db ファイルが作成されます。

6– 最後に、postfix を再起動し変更を反映させます。

/etc/init.d/postfix restart

7– 2つのコンソールに入って動作確認します。以下のコマンドでメール送信の動作を確認します。

tail -f /var/log/maillog

もう一方のコンソールでメールを送信します。

echo "Mail test" | mail test@gmail.com

上記のステップが正しく実行されていれば、最初のコンソールには次のようなものが表示されるはずです。

Dec 18 18:33:40 OKComputer postfix/pickup[10945]: 75D4A243BD: uid=0 from=
Dec 18 18:33:40 OKComputer postfix/cleanup[10951]: 75D4A243BD: message-id=
Dec 18 18:33:40 OKComputer postfix/qmgr[10946]: 75D4A243BD: from=, size=403, nrcpt=1 (queue active)
Dec 18 18:33:44 OKComputer postfix/smtp[10953]: 75D4A243BD: to=prueba@gmail.com, relay=smtp.gmail.com[74.125.93.109]:587, delay=3.7,  delays=0.15/0.14/1.8/1.6, dsn=2.0.0, status=sent (250 2.0.0 OK 1324249500 eb5sm36008464qab.10)
Dec 18 18:33:44 OKComputer postfix/qmgr[10946]: 75D4A243BD: removed

このような結果であれば、Pandora は Postfix サーバにメールを渡し、それらはうまく送られるでしょう。

  • ja/quickguides/configuration_emails_alerts.txt
  • 最終更新: 2021/06/17 14:00
  • by junichi