mysql資料庫統計QPS指令碼

來源:互聯網
上載者:User

標籤:mysql資料庫統計qps指令碼

如下腳步是對mysql資料庫統計QPS指令碼:

#!/bin/bash

mysqladmin -uroot-p‘xxxx‘ extended-status -i1|awk ‘BEGIN{local_switch=0;print"QPS   Commit Rollback   TPS   Threads_con Threads_run\n------------------------------------------------------- "}

    $2 ~/Queries$/           {q=$4-lq;lq=$4;}

    $2 ~ /Com_commit$/         {c=$4-lc;lc=$4;}

    $2 ~ /Com_rollback$/       {r=$4-lr;lr=$4;}

    $2 ~ /Threads_connected$/  {tc=$4;}

    $2 ~ /Threads_running$/    {tr=$4;

       if(local_switch==0)

                {local_switch=1;count=0}

       else {

               if(count>10)

                        {count=0;print"------------------------------------------------------- \nQPS  Commit Rollback   TPS    Threads_con Threads_run\n------------------------------------------------------- ";}

               else{

                        count+=1;

                       printf "%-6d %-8d %-7d %-8d %-10d %d \n", q,c,r,c+r,tc,tr;

               }

       }

}‘

 

 

執行之後的結果是:

QPS  Commit Rollback   TPS    Threads_con Threads_run

-------------------------------------------------------

35    7       0      7       182        1

1     0       0      0       182        1

7     1       0      1       182        1

11    2       0      2       182        1

10    1       0      1       182        1

90    9       0      9       182        1

316   42       0      42      182        1

1     0       0      0       182        1

15    1       0      1       182        1

16    2       0      2       182        1

267   38       0      38       183       1

 

可是通過此指令碼動態查看mysql 的QPS及相關情況!!!!


本文出自 “一點點” 部落格,請務必保留此出處http://pengai.blog.51cto.com/6326789/1887266

mysql資料庫統計QPS指令碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.