萬盛學電腦網

 萬盛學電腦網 >> 數據庫 >> mysql教程 >> MySQL獲取系統性能和狀態代碼

MySQL獲取系統性能和狀態代碼

使用MySQL獲取系統性能和狀態的代碼片段,由此需求的朋友可以參考下,希望對大家有所幫助   復制代碼 代碼如下:


#!/bin/ksh
INTERVAL=5
PREFIX=$INTERVAL-sec-status
touch /tmp/running
RUNFILE=/tmp/running
my -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
my -e 'show global status' >> $PREFIX-${file}-status &
echo "$ts $loadavg" >> $PREFIX-${file}-innodbstatus
my -e 'show engine innodb statusG' >> $PREFIX-${file}-innodbstatus &
echo "$ts $loadavg" >> $PREFIX-${file}-processlist
my -e 'show full processlistG' >> $PREFIX-${file}-processlist &
echo $ts
done
echo Exiting because $RUNFILE does not exist.

copyright © 萬盛學電腦網 all rights reserved