MySQL获取系统性能和状态代码
程序员文章站
2024-02-23 19:18:34
复制代码 代码如下: #!/bin/ksh interval=5 prefix=$interval-sec-status touch /tmp/running runfil...
复制代码 代码如下:
#!/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 status\g' >> $prefix-${file}-innodbstatus &
echo "$ts $loadavg" >> $prefix-${file}-processlist
my -e 'show full processlist\g' >> $prefix-${file}-processlist &
echo $ts
done
echo exiting because $runfile does not exist.