[quote]#!/bin/sh
#this script converts SHOW GLOBAL STATUS into a tabulated format, one line
#per sample in the input, with the metrics divided by the time elapsed
#between samples.
awk '
BEGIN{
printf "#ts date time load QPS";
fmt = "%.2f";
}
/^TS/{# The timestamp lines begin with TS.
ts = substr($2,1,index($2,".")-1);
load = NF - 2;
diff = ts - prev_ts;
prev_ts = ts;
printf "\n%s %s %s %s",ts,$3,$4,substr($load,1,length($load)-1);
}
/Queries/{
printf fmt,($2-Queries)/diff;
Queries=$2
}
' "$@"[/quote]
#this script converts SHOW GLOBAL STATUS into a tabulated format, one line
#per sample in the input, with the metrics divided by the time elapsed
#between samples.
awk '
BEGIN{
printf "#ts date time load QPS";
fmt = "%.2f";
}
/^TS/{# The timestamp lines begin with TS.
ts = substr($2,1,index($2,".")-1);
load = NF - 2;
diff = ts - prev_ts;
prev_ts = ts;
printf "\n%s %s %s %s",ts,$3,$4,substr($load,1,length($load)-1);
}
/Queries/{
printf fmt,($2-Queries)/diff;
Queries=$2
}
' "$@"[/quote]
本文介绍了一段Shell脚本,该脚本用于将MySQL的全局状态信息转换为表格格式,并计算每秒查询率(QPS),通过监测MySQL的运行状态,帮助用户更好地理解数据库负载的变化。

被折叠的 条评论
为什么被折叠?



