pacemaker+heartbeat環境においてVIPの役割ごとに対するMackerelの監視
前提
1.サーバが2台構成(サーバA、サーバB)でそれぞれが別の役割のVIPを保持している場合
2.サーバAはVIP:xxx.xxx.xxx.xxxが設定、サーバBはVIP:yyy.yyy.yyy.yyyが設定されている場合
3.MackerelでサーバA、Bで別々の監視をしたい場合
4.mackerel-agent.confを統一したい場合
手順
1.VIP値を取得する(参考)
get_vip.sh
VIP=`grep xxx-instance_attributes-ip /var/lib/heartbeat/crm/cib.xml |cut -d '"' -f6`
if [ -z "${VIP}" ]; then
echo "0.0.0.0" # ip aで取得されないような文字列ならなんでも良いです
fi
echo ${VIP}
などとしてVIP値を取得するスクリプトなどを作成する。
上記の場合は下記のような設定内容を想定しています。
cib.xml
<nvpair id="xxx-instance_attributes-ip" name="ip" value="xxx.xxx.xxx.xxx"/>
<nvpair id="yyy-instance_attributes-ip" name="ip" value="yyy.yyy.yyy.yyy"/>
もっとスマートな方法はあると思います。
2.Mackerelの設定をする(サーバAのVIP:xxx.xxx.xxx.xxxを監視したい場合)
/etc/mackerel-agent.conf
include = "/etc/mackerel-agent/conf.d/*.conf"
/etc/mackerel-agent/conf.d/check_httpd.conf
[plugin.checks.check_httpd]
command = '(ip a | fgrep -q `get_vip.sh`; exit $(( $? ^ 1 )) ) || check-procs --pattern httpd'
上記はサーバAではhttpdプロセスが起動しており、サーバBではhttpdプロセスが起動していない場合に同一の設定で監視するための設定となります。
あくまでご参考までに。
以上です。