mysqladmin -h127.0.0.1 -r -i 2 extended-status |awk -F "|" 'BEGIN { count=0; } { if($2 ~ /Variable_name/ && ++count%15 == 1){print "----------|---------|--- MySQL Command Status --|----- Innodb row operation -----|-- Buffer Pool Read --"; print "---Time---|---QPS---|select insert update delete| read inserted updated deleted| logical physical";} else if ($2 ~ /Queries/){queries=$3;} else if ($2 ~ /Com_select /){com_select=$3;} else if ($2 ~ /Com_insert /){com_insert=$3;} else if ($2 ~ /Com_update /){com_update=$3;} else if ($2 ~ /Com_delete /){com_delete=$3;} else if ($2 ~ /Innodb_rows_read/){innodb_rows_read=$3;} else if ($2 ~ /Innodb_rows_deleted/){innodb_rows_deleted=$3;} else if ($2 ~ /Innodb_rows_inserted/){innodb_rows_inserted=$3;} else if ($2 ~ /Innodb_rows_updated/){innodb_rows_updated=$3;} else if ($2 ~ /Innodb_buffer_pool_read_requests/){innodb_lor=$3;} else if ($2 ~ /Innodb_buffer_pool_reads/){innodb_phr=$3;} else if ($2 ~ /Uptime / && count >= 2){ printf(" %s |%9d",strftime("%H:%M:%S"),queries);printf("|%6d %6d %6d %6d",com_select,com_insert,com_update,com_delete);printf("|%8d %7d %7d %7d",innodb_rows_read,innodb_rows_inserted,innodb_rows_updated,innodb_rows_deleted); printf("|%10d %11d\n",innodb_lor,innodb_phr);}}'
輸出結果以下:mysql
----------|---------|--- MySQL Command Status --|----- Innodb row operation -----|-- Buffer Pool Read -- ---Time---|---QPS---|select insert update delete| read inserted updated deleted| logical physical 09:32:20 | 92| 8 8 15 0| 15 8 15 0| 2465 0 09:32:22 | 3| 1 0 0 0| 0 0 0 0| 56 0 09:32:24 | 11| 3 0 2 0| 10 0 2 0| 70 0 09:32:26 | 51| 25 0 0 0| 38 0 0 0| 110 0 09:32:28 | 7| 3 0 0 0| 0 0 0 0| 30 0 09:32:30 | 5| 2 0 0 0| 0 0 0 0| 20 0 09:32:32 | 6| 1 0 0 0| 28 0 0 0| 100 0 09:32:34 | 33| 0 0 16 0| 24 0 16 0| 205 0 09:32:36 | 7| 3 0 0 0| 2 0 0 0| 11 0 09:32:38 | 9| 4 0 0 0| 2 0 0 0| 55 0 09:32:40 | 117| 10 10 18 0| 18 10 18 0| 1907 0 09:32:42 | 516| 506 0 0 0| 41 0 0 0| 1280 0 09:32:44 | 21| 2 0 8 0| 18 0 8 0| 158 0 09:32:46 | 17| 0 0 8 0| 8 0 8 0| 84 0 ----------|---------|--- MySQL Command Status --|----- Innodb row operation -----|-- Buffer Pool Read -- ---Time---|---QPS---|select insert update delete| read inserted updated deleted| logical physical 09:32:48 | 24| 3 9 4 0| 6 0 4 0| 50 0 09:32:50 | 81| 1 71 2 0| 50 0 2 0| 85 0 09:32:52 | 107| 103 0 0 0| 2 0 0 0| 10 0 09:32:54 | 91| 8 6 20 0| 28 6 20 0| 1393 0 09:32:56 | 20| 5 0 3 0| 176 0 3 0| 764 0 09:32:58 | 14| 2 0 4 1| 6 0 4 2| 85 0 09:33:00 | 11| 2 0 3 0| 3 0 3 0| 51 0 09:33:02 | 1| 0 0 0 0| 0 0 0 0| 0 0 09:33:04 | 1| 0 0 0 0| 0 0 0 0| 786 0 09:33:06 | 7| 1 0 2 0| 16 0 2 0| 59 0
能夠清楚的看見QPS,以及各類SQL的執行頻率,經過上面的執行結果來看,我如今主要是讀比較頻繁。好了,就說到這裏了。^_^算法