当前位置:Gxlcms > mysql > mysql数据收集shell脚本_MySQL

mysql数据收集shell脚本_MySQL

时间:2021-07-01 10:21:17 帮助过:24人阅读

bitsCN.com

mysql数据收集shell脚本

#!/bin/sh

INTERVAL=5

PREFIX=$INTERVAL-sec-status

RUNFILE=/home/benchmarks/running

mysql -e 'SHOW GLOBAL VARIABLES' >> mysql-variables

while test -e $RUNFILE; do

file=$(date +%F_%I)

sleep=$(date +%s.%N | awk "{print $INTERVAL - (/$1 % $INTERVAL)}")

sleep $sleep

ts="$(date + "TS %s.%N %F %T")"

loadavg="$(uptime)"

echo "$ts $loadavg" >> $PREFIX-${file}-status

mysql -e 'SHOW GLOBAL STATUS' >> $PREFIX-$(file)-status &

echo "$ts $loadavg" >> $PREFIX-${file}-innodbstatus

echo -e 'SHOW ENGINE INNODB STATUS/G' >> $PREFIX-${file}-innodbstatus &

echo "$ts $loadavg" >> $PREFIX-${file}-processlist

mysql -e 'SHOW FULL PROCESSLIST/G' >> $PREFIX-${file}-processlist & echo $ts

done

echo Exiting because $RUNFILE does not exist.

bitsCN.com

人气教程排行