您的位置:计世网>软件>>数据库>mysql数据收集shell脚本 Intel嵌入式设计开发者秘笈(精品)

mysql数据收集shell脚本 Intel嵌入式设计开发者秘笈(精品)

发布时间:2013-05-17 13:39:00 来源:千龙网

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 STATUSG' >> $PREFIX-${file}-innodbstatus &

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

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

  done

  echo Exiting because $RUNFILE does not exist.

本文关键词:mysql数据收集,shell脚本