MySQL監控SQL狀態及命中率
[root@hank-yoon scrips]# vi mysqlstat.sh
/export/servers/mysql/bin/mysqladmin -P3306 -uyoon -pyoon -h127.0.0.1 -r -i 2 ext |\
awk -F"|" \
"BEGIN{ count=0; }"\
'{ if($2 ~ /Variable_name/ && ((++count)%20 == 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("|%6d %8d %7d %7d",innodb_rows_read,innodb_rows_inserted,innodb_rows_updated,innodb_rows_deleted);\
printf("|%10d %11d\n",innodb_lor,innodb_phr);\
}}'
[root@hank-yoon scrips]# sh mysqlstat.sh
Warning: Using a password on the command line interface can be insecure.
----------|---------|--- MySQL Command Status --|----- Innodb row operation ----|-- Buffer Pool Read --
---Time---|---QPS---|select insert update delete| read inserted updated deleted| logical physical
17:00:35 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:37 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:39 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:41 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:43 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:45 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:45 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:49 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:51 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:53 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:55 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:57 | 1| 0 0 0 0| 0 0 0 0| 0 0
/export/servers/mysql/bin/mysqladmin -P3306 -uyoon -pyoon -h127.0.0.1 -r -i 2 ext |\
awk -F"|" \
"BEGIN{ count=0; }"\
'{ if($2 ~ /Variable_name/ && ((++count)%20 == 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("|%6d %8d %7d %7d",innodb_rows_read,innodb_rows_inserted,innodb_rows_updated,innodb_rows_deleted);\
printf("|%10d %11d\n",innodb_lor,innodb_phr);\
}}'
[root@hank-yoon scrips]# sh mysqlstat.sh
Warning: Using a password on the command line interface can be insecure.
----------|---------|--- MySQL Command Status --|----- Innodb row operation ----|-- Buffer Pool Read --
---Time---|---QPS---|select insert update delete| read inserted updated deleted| logical physical
17:00:35 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:37 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:39 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:41 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:43 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:45 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:45 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:49 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:51 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:53 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:55 | 1| 0 0 0 0| 0 0 0 0| 0 0
17:00:57 | 1| 0 0 0 0| 0 0 0 0| 0 0
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28939273/viewspace-2063263/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- MySQL MHA 執行狀態監控MySql
- MySQL監控InnoDB Buffer Pool命中率MySql
- 7. 監控MySQL主從狀態MySql
- Galera Cluster for MySQL監控狀態說明MySql
- 配置CACTI監控MySQL資料庫狀態(5)增加MySQL監控模板MySql資料庫
- MySQL執行狀態監控(pt-mysql-summary)MySql
- Shell指令碼監控MySQL主從狀態指令碼MySql
- 巧用Zabbix自定義監控Mysql效能狀態MySql
- zabbix應用-監控mysql slave 主從狀態MySql
- mysql主從同步(4)-Slave延遲狀態監控MySql主從同步
- 監控Nginx的工作狀態Nginx
- Nginx服務狀態監控Nginx
- 更改/etc/init.d/mysql,讓HeartBeat只是監控MYSQL的狀態MySql
- 專案實戰:zabbix監控MySQL狀態、服務資訊MySql
- 配置CACTI監控MySQL資料庫狀態(4)配置cactiMySql資料庫
- Docker 之 執行狀態監控Docker
- nagios監控drbd同步狀態iOS
- memcached的執行狀態監控
- 配置CACTI監控MySQL資料庫狀態(1)準備工作MySql資料庫
- 配置CACTI監控MySQL資料庫狀態(3)配置apache模組MySql資料庫Apache
- 監控 SQL Server 的執行狀況SQLServer
- nagios監控 ogg同步狀態iOS
- Nginx狀態圖形化監控工具Nginx
- 利用btrace線上監控java程式狀態Java
- 用c#監控網路狀態C#
- mysql狀態檢視 QPSTPS快取命中率檢視MySql快取
- 監控SQL Server的執行狀況(1)SQLServer
- 利用superlance監控supervisor執行狀態
- 利用shell指令碼監控網站狀態指令碼網站
- 自己開發的MYMON工具監控MYSQL執行狀態幫助文件MySql
- 值得收藏!9個最佳SSD狀態監控及效能最佳化工具
- mysql狀態檢視 QPS/TPS/快取命中率檢視MySql快取
- Oracle-監控緩衝區的命中率Oracle
- 【SQL監控】SQL完全監控的指令碼SQL指令碼
- 資料庫效能大揭秘:玩轉MySQL監控指標狀態變數資料庫MySql指標變數
- 怎麼監控 Linux 伺服器狀態?Linux伺服器
- 基於websocket的celery任務狀態監控Web
- springCloud入門學習--Hystrix狀態監控SpringGCCloud