Created
January 30, 2015 08:05
-
-
Save hmkz/b4040e01893d2ef55553 to your computer and use it in GitHub Desktop.
muninプラグイン。 マルチソースレプリケーションを設定している場合のConnection_nameを識別してそれぞれのSeconds_Behind_Masterを取得してグラフを描く。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
ARGS=$1; shift | |
MYSQL="mysql -uroot " | |
LIST_CONN_CMD=$(echo 'show all slaves status\G' | ${MYSQL} | grep 'Connection_name' | awk '{print $2}') | |
function show_seconds_behind_master () { | |
conn=$1; shift; | |
SECONDS=$(echo "show slave '${conn}' status\G" | ${MYSQL} | grep Seconds_Behind_Master | awk '{print $2}') | |
echo ${conn}.value ${SECONDS} | |
} | |
function show_config () { | |
conn=$1; shift; | |
echo "${conn}.label ${conn}" | |
#echo "${conn}.type DERIVE" | |
#echo "${conn}.max 300000" | |
echo "${conn}.draw LINE2" | |
echo "${conn}.min 0" | |
echo "${conn}.info The seconds of ${conn} Seconds_Behind_Master." | |
} | |
if [ "${ARGS}" == "config" ]; then | |
echo "graph_title MySQL Multi Master Slave Status" | |
echo "graph_args --base 1000 -l 0" | |
echo "graph_vlabel Seconds" | |
echo "graph_category mysql" | |
#echo "graph_period second" | |
echo "graph_info This graph shows the MySQL Multi Masters Slave Status." | |
fi | |
if [ "${ARGS}" == "autoconf" ]; then | |
echo "yes" | |
exit | |
fi | |
for conn in `echo ${LIST_CONN_CMD}` | |
do | |
if [ "${ARGS}" == "config" ]; then | |
show_config ${conn} | |
else | |
show_seconds_behind_master ${conn} | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment