フェイルオーバーの切り替えが発生したときに通知を受け取るように、外部エージェント経由でPacemakerクラスターイベント通知を設定しようとしています。
以下のリンクを探しました
しかし、実際にこれがどのように行われるのか理解していません。
ステップバイステップの説明をお願いします。
ありがとうございました、
ラニヤン
回答:
回答№1は2RedHatのドキュメントは簡潔ですが、Florianのブログエントリはかなり詳細であり、最後の参照は参考になります。
尋ねられた質問は一種の漠然としているので、私は「私はあなたが思うことに答えている」と尋ねている。
簡単に言うと、Florianの投稿の一部を要約すると、ClusterMonはリソースエージェントです(ocf:pacemaker:ClusterMon
実行されます) crm_mon
舞台裏で
私の(SLES 11 SP3)リソースの文書には次のように書かれています。
# crm ra info ocf:pacemaker:ClusterMon
Runs crm_mon in the background, recording the cluster status to an HTML file (ocf:pacemaker:ClusterMon)
This is a ClusterMon Resource Agent.
It outputs current cluster status to the html.
Parameters (* denotes required, [] the default):
user (string, [root]):
The user we want to run crm_mon as
update (integer, [15]): Update interval
How frequently should we update the cluster status
extra_options (string): Extra options
Additional options to pass to crm_mon. Eg. -n -r
pidfile (string, [/tmp/ClusterMon_undef.pid]): PID file
PID file location to ensure only one instance is running
htmlfile (string, [/tmp/ClusterMon_undef.html]): HTML output
Location to write HTML output to.
Operations" defaults (advisory minimum):
start timeout=20
stop timeout=20
monitor timeout=20 interval=10
しかし、本当の力は extra_options
これにより、リソースエージェントに通知させることができます。 crm_mon
結果をどうするか。特に、extra_optionsはコマンドラインオプションとしてそのまま渡されます。 crm_mon
.
フロリアンが述べたように、より最近のヴィンテージcrm_mon(実際には何をしているのか)はSMTP(email)やSNMPのサポートが組み込まれていません。
それで、extra_optionsが何をするのか理解するために、あなたは相談するべきです man crm_mon
.
あなたがリンクしたRedHatのドキュメントから、最初の "extra_options"の値は -T pacemaker@example.com -F pacemaker@nodeX.example.com -P PACEMAKER -H mail.example.com
tell crm_mon
電子メールをpacemaker@example.comに送信するには、pacemaker @ nodeX.example.comから件名プレフィックスPACEMAKERを付けて、メールホスト(smtpサーバー)mail.example.comを介して送信します。
参照しているRedHatドキュメントの2番目の "extra_options"の例には価値がありました -S snmphost.example.com -C public
それは言う crm_mon
publicというコミュニティを使用してsnmphost.example.comにSNMPトラップを送信します。
3番目の "extra_options"の例には値があります -E /usr/local/bin/example.sh -e 192.168.12.1
。これは言う crm_mon
外部プログラム/usr/local/bin/example.shを実行し、実際に環境変数にスローされる「外部受信者」も指定します。 CRM_notify_recipient
スクリプトを生成する前にエクスポートされます。
外部エージェントを実行しているとき、crm_monは以下のスクリプトを呼び出します。 すべて クラスタイベント(正常な監視操作を含む)このスクリプトは何が起こっているのかを伝えるたくさんの環境変数を継承します。
から: http://clusterlabs.org/doc/en-US/Pacemaker/1.1/html/Pacemaker_Explained/s-notification-external.html 設定されている環境変数は次のとおりです。
CRM_notify_recipient The static external-recipient from the resource definition.
CRM_notify_node The node on which the status change happened.
CRM_notify_rsc The name of the resource that changed the status.
CRM_notify_task The operation that caused the status change.
CRM_notify_desc The textual output relevant error code of the operation (if any) that caused the status change.
CRM_notify_rc The return code of the operation.
CRM_notify_target_rc The expected return code of the operation.
CRM_notify_status The numerical representation of the status of the operation.
スクリプトの仕事は、これらの環境変数を消費して、それらを使って妥当なことをすることです。 「合理的」とは、環境によって異なります。
FlorianのブログにあるSNMPトラップの例は、あなたがSNMPトラップに精通していることを前提としています。
SNMPトラップの例は、失敗したモニタイベントまたはモニタイベントではないイベントのいずれかであるイベントを識別するための優れた条件文を提供します。
実行する監視スクリプトの足場入手可能な情報に関してあなたが望むものは何でも、実際にはフロリアンのブログ投稿で参照されているsnmp trapシェルスクリプトの簡略版です。
#!/bin/bash
# if [[ unsuccessful monitor operation ]] or [[ not monitor op ]]
if [[ ${CRM_notify_rc} != 0 && ${CRM_notify_task} == "monitor" ]] ||
[[ ${CRM_notify_task} != "monitor" ]] ; then
# Do whatever you want with the information available in the
# environment variables mentioned above that will do something
# meaningful for you.
# EG: Fire off an email attempting to be human readable
# SUBJ="${CRM_notify_task} ${CRM_notify_desc} for ${CRM_notify_rsc} "
# SUBJ="$SUBJ on ${CRM_notify_node}"
# MSG="The ${CRM_notify_task} operation for ${CRM_notify_rsc} on "
# MSG="$MSG ${CRM_notify_node} exited with status ${CRM_notify_rc} "
# MSG="$MSG (${CRM_notify_desc}) and we expected ${CRM_notify_target_rc}"
# echo "$MSG" | mail -s "$SUBJ" you@host.com
fi
exit 0
しかし、もしあなたが「フロリアンに従う」としたらリソースを複製すると、スクリプトはすべてのノードで実行されます。 SNMPトラップの場合は、これで問題ありません。ただし、スクリプトからEメールを送信するようなことをしている場合は、実際には複製したくない場合があります。
回答№2の場合は0
両方のノード
cat << "EOL">/usr/local/bin/crm_e-mail.sh
#!/bin/bash
echo "Please check your installation @ http://domain.com.com:2224 & http://domain.com.com/clustermon.html" | mail -s "Cluster Change Detected" sysalert@domain.com
EOL
chmod 700 /usr/local/bin/crm_e-mail.sh
chown root.root /usr/local/bin/crm_e-mail.sh
1つのノード
pcs resource create ClusterMon-SMTP ClusterMon user=root
update=10 extra_options="-E /usr/local/bin/crm_e-mail.sh --watch-fencing"
pidfile=/var/run/crm_mon-smtp.pid clone