好了,今天接着來學習性能,在今天開始前,我今天在網上又看到了理發師經典模型,這里稍微提一下,詳情可以百度哈,下面這張圖是網上找到的經典場景性能相關的圖,大致說明下:
這張圖中展示的是1個標准的軟件性能模型。在圖中有三條曲線,分別表示資源的利用情況(Utilization,包括硬件資源和軟件資源)、吞吐量(Throughput,這里是指每秒事務數)以及響應時間(Response Time)。圖中坐標軸的橫軸從左到右表現了並發用戶數(Number of Concurrent Users)的不斷增長。
在這張圖中我們可以看到,最開始,隨着並發用戶數的增長,資源占用率和吞吐量會相應的增長,但是響應時間的變化不大;不過當並發用戶數增長到一定程度后,資源占用達到飽和,吞吐量增長明顯放緩甚至停止增長,而響應時間卻進一步延長。如果並發用戶數繼續增長,你會發現軟硬件資源占用繼續維持在飽和狀態,但是吞吐量開始下降,響應時間明顯的超出了用戶可接受的范圍,並且最終導致用戶放棄了這次請求甚至離開。
根據這種性能表現,圖中划分了三個區域,分別是Light Load(較輕的壓力)、Heavy Load(較重的壓力)和Buckle Zone(用戶無法忍受並放棄請求)。在Light Load和Heavy Load 兩個區域交界處的並發用戶數,我們稱為“最佳並發用戶數(The Optimum Number of Concurrent Users)”,而Heavy Load和Buckle Zone兩個區域交界處的並發用戶數則稱為“最大並發用戶數(The Maximum Number of Concurrent Users)”。
我們在進行性能測試時,首先需要確定的就是性能指標,然后開始性能建模,接着確定性能方案,最后進行性能場景。
下面是性能測試的大致過程:
下面是性能建模的各個接口單個小時的指標計算,最后發現單個線程就能滿足TPS了。(所以說用戶不等於線程數)
上面稍微提了一下性能的過程和指標計算,這些會在后面詳細講解,今天的主要目的實際上是來做性能監控的,性能監控的數據我們用influxdb進行保存,然后數據展示用grafana。
- 這里我們先來安裝下influxdb,influxdb 1.5.4 下載地址 :https://www.influxdata.com/ , 下載之后通過yum localinstall安裝rpm包(跟着官網干的)
下圖是啟動influxdb然后通過influx命令進入influxdb數據庫,創建jmeter數據庫,show MEASURENENTS (這個是查看所有鍵)。在頁面上可以試着訪問下ip+8086,如果出現404 page not found證明OK,因為是通用http請求的。
- 創建一個新的管理員用戶
CREATE USER <username> WITH PASSWORD '<password>' WITH ALL PRIVILEGES
- 為一個已有用戶授權管理員權限
GRANT ALL PRIVILEGES TO <username>
2.安裝grafana,下載地址:https://grafana.com/grafana/download,下載之后通過yum localinstall安裝rpm包。
安裝完成后啟動服務:systemctl start grafana-server,記住要關閉防火牆喔,systemctl stop firewalld(臨時關閉)和systemctl disable firewalld(禁止開機啟動)
然后訪問,ip+3000端口,默認用戶名和密碼是admin;
安裝好了grafana之后,我們可以配置一下grafana從influxdb中讀取數據,從設置->Data Sources然后進行如下的配置:
3.配置完后,我們可以通過jmeter通過Backend Listener將測試的數據寫入influxdb的jmeter表中,如下圖:這里用三個java請求跑一下看下效果
我們可以查詢看下jmeter表里面有哪些字段及意思:
time 時間戳 application jmeter中指定的application的名稱 avg 平均響應時間 count 所有產生東西的統計 countError 錯誤統計 endedT 結束的線程 hit max 最大的響應時間 maxAT 最大的活動線程數 meanAT min 最小的響應時間 minAT pct90.0 90%的響應時間 pct95.0 95%的響應時間 pct99.0 99%的響應時間 startedT 開始的線程 statut 狀態 transaction 事務
4.我們通過New dashboard -> add -> Singlestat來添加剛剛的請求數,剛剛15個線程跑三個java請求各100次,應該是4500次,但是因為兩個請求又包成了一層事務,所以總的請求次數為6000:
下圖是三個請求的TPS:
最終模仿着別人的寫出來了自己的模板,效果如下:
如果需要源文件可以私撩我 ,對於添加各種數據圖表的話,大家可以查看該地址:https://testerhome.com/topics/11256
5.上面是從jmeter結果中讀取的數據,主要還是請求性能的參數指標,那么我們在真正的性能測試過程中,我們經常還需要統計服務器的資源使用情況,那么這個時候我們怎么將服務器的資源使用情況也寫進來呢?
我們可以查看influxdb官網的API接口,通過curl -i -XPOST http://localhost:8086/query --data-urlencode "q=CREATE DATABASE mydb"可以創建mydb數據庫
然后我們可以先將監控數據保存在txt文檔內,最后再將txt監控數據寫入到influxdb數據庫中,最終通過grafana展示出來。
寫入influxdb數據庫的命令:
curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary 'cpu_load_short,host=server01,region=us-west value=0.64 1434055562000000000'
- 或:curl -i -XPOST 'http://localhost:8086/write?db=mydb' --data-binary @cpu_data.txt
對於linux的指標監控我們用的是vmstat,這里來簡單說明一下各個字段的意思:
字段說明:
Procs(進程)
- r:運行隊列中進程數量,以8核為例,如果隊列數量超過8,證明有排隊的,但這不代表壓力很大,因為很快就能處理完了,如果該參數長期大於和等於邏輯cpu個數,則CPU資源可能存在較大的瓶頸。
- b: 等待IO的進程數量。意味着進程被阻塞。主要是指被資源阻塞的進程對列數(比如IO資源、頁面調度等),當這個值較大時,需要根據應用程序來進行分析
Memory(內存)
- swpd: 使用虛擬內存大小,如果swpd的值不為0,但是SI,SO的值長期為0,這種情況不會影響系統性能。
- free: 空閑物理內存大小。
- buff: 用作緩沖的內存大小。
- cache: 用作緩存的內存大小,如果cache的值大的時候,說明cache處的文件數多,如果頻繁訪問到的文件都能被cache處,那么磁盤的讀IO bi會非常小。
Swap
- si: 每秒從交換區寫到內存的大小,由磁盤調入內存。
- so: 每秒寫入交換區的內存大小,由內存調入磁盤。
注意:內存夠用的時候,這2個值都是0,如果這2個值長期大於0時,系統性能會受到影響,磁盤IO和CPU資源都會被消耗。有些朋友看到空閑內存(free)很少的或接近於0時,就認為內存不夠用了,不能光看這一點,還要結合si和so,如果free很少,但是si和so也很少(大多時候是0),那么不用擔心,系統性能這時不會受到影響的。
IO(現在的Linux版本塊的大小為1kb)
- bi: 每秒讀取的塊數
- bo: 每秒寫入的塊數
注意:隨機磁盤讀寫的時候,這2個值越大(如超出1024k),能看到CPU在IO等待的值也會越大。
system(系統)
- in: 每秒中斷數,包括時鍾中斷。(分為軟中斷(訪問應用軟件超時等)和硬中斷(訪問硬件報錯,硬中斷+1))
- cs: 每秒上下文切換數。(進程和線程的交互,經驗來講,2C4G最好小於2W次,4C8G在6W~8W,8核16G是在20W到30W)
注意:上面2個值越大,會看到由內核消耗的CPU時間會越大。
CPU(以百分比表示)
- us: 用戶進程執行時間百分比(user time)
us的值比較高時,說明用戶進程消耗的CPU時間多,但是如果長期超50%的使用,那么我們就該考慮優化程序算法或者進行加速。
- sy: 內核系統進程執行時間百分比(system time)
sy的值高時,說明系統內核消耗的CPU資源多,這並不是良性表現,我們應該檢查原因。
- id: 空閑時間百分比
- wa: IO等待時間百分比
wa的值高時,說明IO等待比較嚴重,這可能由於磁盤大量作隨機訪問造成,也有可能磁盤出現瓶頸(塊操作)。
- st: 當虛擬機1資源不夠的時候會去偷宿主機資源(宿主機資源不夠情況可以再去虛擬機2拿),最終給虛擬機1,這個過程就是st
6.字段說明完了之后,我們就來寫shell腳本通過vmstat去收集數據然后再插入influxdb數據庫中,最后再從grafana中通過sql語句讀取出數據展現在圖表中。
首先,我先寫個sh文件,通過vmstat收集數據然后post到influxdb中,sh腳本內容如下:
#!/bin/bash while true;do value=`vmstat 1 2|tail -n 1` vm_r=`echo $value|cut -d " " -f1` vm_b=`echo $value|cut -d " " -f2` vm_swpd=`echo $value|cut -d " " -f3` vm_free=`echo $value|cut -d " " -f4` vm_buff=`echo $value|cut -d " " -f5` vm_cache=`echo $value|cut -d " " -f6` vm_si=`echo $value|cut -d " " -f7` vm_so=`echo $value|cut -d " " -f8` vm_bi=`echo $value|cut -d " " -f9` vm_bo=`echo $value|cut -d " " -f10` vm_in=`echo $value|cut -d " " -f11` vm_cs=`echo $value|cut -d " " -f12` vm_us=`echo $value|cut -d " " -f13` vm_sy=`echo $value|cut -d " " -f14` vm_id=`echo $value|cut -d " " -f15` vm_wa=`echo $value|cut -d " " -f16` vm_st=`echo $value|cut -d " " -f17` ip=`ip addr |grep eno16777736|tail -n 1|awk '{print $2}'|awk -F '/' '{ print $1}'` curl -i -XPOST "http://10.10.18.131:8086/write?db=vmstat" --data-binary "linux_load_count,ip=$ip r=$vm_r linux_load_count,ip=$ip b=$vm_b linux_load_count,ip=$ip swpd=$vm_swpd linux_load_count,ip=$ip free=$vm_free linux_load_count,ip=$ip buff=$vm_buff linux_load_count,ip=$ip cache=$vm_cache linux_load_count,ip=$ip si=$vm_si linux_load_count,ip=$ip so=$vm_so linux_load_count,ip=$ip bi=$vm_bi linux_load_count,ip=$ip bo=$vm_bo linux_load_count,ip=$ip in=$vm_in linux_load_count,ip=$ip cs=$vm_cs linux_load_count,ip=$ip us=$vm_us linux_load_count,ip=$ip sy=$vm_sy linux_load_count,ip=$ip id=$vm_id linux_load_count,ip=$ip wa=$vm_wa linux_load_count,ip=$ip st=$vm_st" sleep 3 done
推送完成后,我們就去grafana寫sql展示(記得新建一個data source),效果圖如下:
其實不是很難,我把這個模板的json貼出來,有興趣的可以一起深入研究研究。
下面是linux監控的json模板:
{ "__inputs": [ { "name": "DS_VMSTAT", "label": "vmstat", "description": "", "type": "datasource", "pluginId": "influxdb", "pluginName": "InfluxDB" } ], "__requires": [ { "type": "grafana", "id": "grafana", "name": "Grafana", "version": "5.2.1" }, { "type": "panel", "id": "graph", "name": "Graph", "version": "5.0.0" }, { "type": "datasource", "id": "influxdb", "name": "InfluxDB", "version": "5.0.0" } ], "annotations": { "list": [ { "builtIn": 1, "datasource": "-- Grafana --", "enable": true, "hide": true, "iconColor": "rgba(0, 211, 255, 1)", "name": "Annotations & Alerts", "type": "dashboard" } ] }, "description": "監控linux機器的資源使用情況", "editable": true, "gnetId": null, "graphTooltip": 0, "id": null, "links": [], "panels": [ { "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, "datasource": "${DS_VMSTAT}", "description": "us: 用戶進程執行時間百分比(user time)\nus的值比較高時,說明用戶進程消耗的CPU時間多,但是如果長期超50%的使用,那么我們就該考慮優化程序算法或者進行加速。\n\nsy: 內核系統進程執行時間百分比(system time)\nsy的值高時,說明系統內核消耗的CPU資源多,這並不是良性表現,我們應該檢查原因。\n\nid: 空閑時間百分比\nwa: IO等待時間百分比\nwa的值高時,說明IO等待比較嚴重,這可能由於磁盤大量作隨機訪問造成,也有可能磁盤出現瓶頸(塊操作)。\n\nst: 當虛擬機1資源不夠的時候會去偷宿主機資源(宿主機資源不夠情況可以再去虛擬機2拿),最終給虛擬機1,這個過程就是st", "fill": 2, "gridPos": { "h": 9, "w": 12, "x": 0, "y": 0 }, "id": 2, "legend": { "avg": false, "current": false, "max": false, "min": false, "show": true, "total": false, "values": false }, "lines": true, "linewidth": 2, "links": [], "nullPointMode": "null", "percentage": false, "pointradius": 5, "points": false, "renderer": "flot", "seriesOverrides": [], "spaceLength": 10, "stack": false, "steppedLine": false, "targets": [ { "alias": "$col", "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "orderByTime": "ASC", "policy": "default", "query": "SELECT us from linux_load_count WHERE $timeFilter fill(null)", "rawQuery": true, "refId": "A", "resultFormat": "time_series", "select": [ [ { "params": [ "value" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] }, { "alias": "$col", "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "orderByTime": "ASC", "policy": "default", "query": "SELECT sy from linux_load_count WHERE $timeFilter fill(null)", "rawQuery": true, "refId": "B", "resultFormat": "time_series", "select": [ [ { "params": [ "value" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] }, { "alias": "$col", "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "orderByTime": "ASC", "policy": "default", "query": "SELECT id from linux_load_count WHERE $timeFilter fill(null)", "rawQuery": true, "refId": "C", "resultFormat": "time_series", "select": [ [ { "params": [ "value" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] }, { "alias": "$col", "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "orderByTime": "ASC", "policy": "default", "query": "SELECT wa from linux_load_count WHERE $timeFilter fill(null)", "rawQuery": true, "refId": "D", "resultFormat": "time_series", "select": [ [ { "params": [ "value" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] }, { "alias": "$col", "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "orderByTime": "ASC", "policy": "default", "query": "SELECT st from linux_load_count WHERE $timeFilter fill(null)", "rawQuery": true, "refId": "E", "resultFormat": "time_series", "select": [ [ { "params": [ "value" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] } ], "thresholds": [], "timeFrom": null, "timeShift": null, "title": "CPU Load", "tooltip": { "shared": true, "sort": 0, "value_type": "individual" }, "type": "graph", "xaxis": { "buckets": null, "mode": "time", "name": null, "show": true, "values": [] }, "yaxes": [ { "format": "percent", "label": null, "logBase": 1, "max": null, "min": null, "show": true }, { "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true } ], "yaxis": { "align": false, "alignLevel": null } }, { "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, "datasource": "${DS_VMSTAT}", "description": "swpd: 使用虛擬內存大小,如果swpd的值不為0,但是SI,SO的值長期為0,這種情況不會影響系統性能。\n\nfree: 空閑物理內存大小。\n\nbuff: 用作緩沖的內存大小。\n\ncache: 用作緩存的內存大小,如果cache的值大的時候,說明cache處的文件數多,如果頻繁訪問到的文件都能被cache處,那么磁盤的讀IO bi會非常小。\n\nsi: 每秒從交換區寫到內存的大小,由磁盤調入內存。\n\nso: 每秒寫入交換區的內存大小,由內存調入磁盤.\n\n注意:內存夠用的時候,這2個值都是0,如果這2個值長期大於0時,系統性能會受到影響,磁盤IO和CPU資源都會被消耗。有些朋友看到空閑內存(free)很少的或接近於0時,就認為內存不夠用了,不能光看這一點,還要結合si和so,如果free很少,但是si和so也很少(大多時候是0),那么不用擔心,系統性能這時不會受到影響的。", "fill": 2, "gridPos": { "h": 9, "w": 12, "x": 12, "y": 0 }, "id": 4, "legend": { "avg": false, "current": false, "max": false, "min": false, "show": true, "total": false, "values": false }, "lines": true, "linewidth": 2, "links": [], "nullPointMode": "null", "percentage": false, "pointradius": 5, "points": false, "renderer": "flot", "seriesOverrides": [], "spaceLength": 10, "stack": false, "steppedLine": false, "targets": [ { "alias": "memory_$col", "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "orderByTime": "ASC", "policy": "default", "query": "SELECT free from linux_load_count WHERE $timeFilter fill(null)", "rawQuery": true, "refId": "A", "resultFormat": "time_series", "select": [ [ { "params": [ "value" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] }, { "alias": "memory_$col", "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "orderByTime": "ASC", "policy": "default", "query": "SELECT buff from linux_load_count WHERE $timeFilter fill(null)", "rawQuery": true, "refId": "B", "resultFormat": "time_series", "select": [ [ { "params": [ "value" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] }, { "alias": "memory_$col", "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "orderByTime": "ASC", "policy": "default", "query": "SELECT cache from linux_load_count WHERE $timeFilter fill(null)", "rawQuery": true, "refId": "C", "resultFormat": "time_series", "select": [ [ { "params": [ "value" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] }, { "alias": "memory_$col", "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "orderByTime": "ASC", "policy": "default", "query": "SELECT swpd from linux_load_count WHERE $timeFilter fill(null)", "rawQuery": true, "refId": "D", "resultFormat": "time_series", "select": [ [ { "params": [ "value" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] }, { "alias": "memory_$col", "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "orderByTime": "ASC", "policy": "default", "query": "SELECT si from linux_load_count WHERE $timeFilter fill(null)", "rawQuery": true, "refId": "E", "resultFormat": "time_series", "select": [ [ { "params": [ "value" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] }, { "alias": "memory_$col", "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "orderByTime": "ASC", "policy": "default", "query": "SELECT so from linux_load_count WHERE $timeFilter fill(null)", "rawQuery": true, "refId": "F", "resultFormat": "time_series", "select": [ [ { "params": [ "value" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] } ], "thresholds": [], "timeFrom": null, "timeShift": null, "title": "Memory Load", "tooltip": { "shared": true, "sort": 0, "value_type": "individual" }, "type": "graph", "xaxis": { "buckets": null, "mode": "time", "name": null, "show": true, "values": [] }, "yaxes": [ { "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true }, { "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true } ], "yaxis": { "align": false, "alignLevel": null } }, { "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, "datasource": "${DS_VMSTAT}", "description": "r:運行隊列中進程數量,以8核為例,如果隊列數量超過8,證明有排隊的,但這不代表壓力很大,因為很快就能處理完了,如果該參數長期大於和等於邏輯cpu個數,則CPU資源可能存在較大的瓶頸。\n\nb: 等待IO的進程數量。意味着進程被阻塞。主要是指被資源阻塞的進程對列數(比如IO資源、頁面調度等),當這個值較大時,需要根據應用程序來進行分析", "fill": 2, "gridPos": { "h": 9, "w": 8, "x": 0, "y": 9 }, "id": 10, "legend": { "avg": false, "current": false, "max": false, "min": false, "show": true, "total": false, "values": false }, "lines": true, "linewidth": 2, "links": [], "nullPointMode": "null", "percentage": false, "pointradius": 5, "points": false, "renderer": "flot", "seriesOverrides": [], "spaceLength": 10, "stack": false, "steppedLine": false, "targets": [ { "alias": "$col", "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "orderByTime": "ASC", "policy": "default", "query": "select \"r\" as process_queue from linux_load_count WHERE $timeFilter fill(null)", "rawQuery": true, "refId": "A", "resultFormat": "time_series", "select": [ [ { "params": [ "value" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] }, { "alias": "$col", "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "orderByTime": "ASC", "policy": "default", "query": "select \"b\" as block_queue from linux_load_count WHERE $timeFilter fill(null)", "rawQuery": true, "refId": "B", "resultFormat": "time_series", "select": [ [ { "params": [ "value" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] } ], "thresholds": [], "timeFrom": null, "timeShift": null, "title": "Procs_queue", "tooltip": { "shared": true, "sort": 0, "value_type": "individual" }, "type": "graph", "xaxis": { "buckets": null, "mode": "time", "name": null, "show": true, "values": [] }, "yaxes": [ { "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true }, { "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true } ], "yaxis": { "align": false, "alignLevel": null } }, { "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, "datasource": "${DS_VMSTAT}", "description": "in: 每秒中斷數,包括時鍾中斷。(分為軟中斷(訪問應用軟件超時等)和硬中斷(訪問硬件報錯,硬中斷+1))\n\ncs: 每秒上下文切換數。(進程和線程的交互,經驗來講,2C4G最好小於2W次,4C8G在6W~8W,8核16G是在20W到30W)\n\n注意:上面2個值越大,會看到由內核消耗的CPU時間會越大。", "fill": 2, "gridPos": { "h": 9, "w": 8, "x": 8, "y": 9 }, "id": 8, "legend": { "avg": false, "current": false, "max": false, "min": false, "show": true, "total": false, "values": false }, "lines": true, "linewidth": 2, "links": [], "nullPointMode": "null", "percentage": false, "pointradius": 5, "points": false, "renderer": "flot", "seriesOverrides": [], "spaceLength": 10, "stack": false, "steppedLine": false, "targets": [ { "alias": "$col", "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "orderByTime": "ASC", "policy": "default", "query": "select \"in\" as Interruption from linux_load_count WHERE $timeFilter fill(null)", "rawQuery": true, "refId": "A", "resultFormat": "time_series", "select": [ [ { "params": [ "value" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] }, { "alias": "$col", "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "orderByTime": "ASC", "policy": "default", "query": "select \"cs\" as context_switch from linux_load_count WHERE $timeFilter fill(null)", "rawQuery": true, "refId": "B", "resultFormat": "time_series", "select": [ [ { "params": [ "value" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] } ], "thresholds": [], "timeFrom": null, "timeShift": null, "title": "System", "tooltip": { "shared": true, "sort": 0, "value_type": "individual" }, "type": "graph", "xaxis": { "buckets": null, "mode": "time", "name": null, "show": true, "values": [] }, "yaxes": [ { "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true }, { "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true } ], "yaxis": { "align": false, "alignLevel": null } }, { "aliasColors": {}, "bars": false, "dashLength": 10, "dashes": false, "datasource": "${DS_VMSTAT}", "description": "bi: 每秒讀取的塊數\n\nbo: 每秒寫入的塊數\n\n注意:隨機磁盤讀寫的時候,這2個值越大(如超出1024k),能看到CPU在IO等待的值也會越大。", "fill": 2, "gridPos": { "h": 9, "w": 8, "x": 16, "y": 9 }, "id": 6, "legend": { "avg": false, "current": false, "max": false, "min": false, "show": true, "total": false, "values": false }, "lines": true, "linewidth": 2, "links": [], "nullPointMode": "null", "percentage": false, "pointradius": 5, "points": false, "renderer": "flot", "seriesOverrides": [], "spaceLength": 10, "stack": false, "steppedLine": false, "targets": [ { "alias": "$col", "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "orderByTime": "ASC", "policy": "default", "query": "select bi as block_in from linux_load_count WHERE $timeFilter fill(null)", "rawQuery": true, "refId": "A", "resultFormat": "time_series", "select": [ [ { "params": [ "value" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] }, { "alias": "$col", "groupBy": [ { "params": [ "$__interval" ], "type": "time" }, { "params": [ "null" ], "type": "fill" } ], "orderByTime": "ASC", "policy": "default", "query": "select bo as block_out from linux_load_count WHERE $timeFilter fill(null)", "rawQuery": true, "refId": "B", "resultFormat": "time_series", "select": [ [ { "params": [ "value" ], "type": "field" }, { "params": [], "type": "mean" } ] ], "tags": [] } ], "thresholds": [], "timeFrom": null, "timeShift": null, "title": "IO_Load", "tooltip": { "shared": true, "sort": 0, "value_type": "individual" }, "type": "graph", "xaxis": { "buckets": null, "mode": "time", "name": null, "show": true, "values": [] }, "yaxes": [ { "format": "kbytes", "label": null, "logBase": 1, "max": null, "min": null, "show": true }, { "format": "short", "label": null, "logBase": 1, "max": null, "min": null, "show": true } ], "yaxis": { "align": false, "alignLevel": null } } ], "refresh": false, "schemaVersion": 16, "style": "dark", "tags": [], "templating": { "list": [] }, "time": { "from": "2018-07-25T02:07:25.151Z", "to": "2018-07-25T02:17:25.151Z" }, "timepicker": { "refresh_intervals": [ "5s", "10s", "30s", "1m", "5m", "15m", "30m", "1h", "2h", "1d" ], "time_options": [ "5m", "15m", "1h", "6h", "12h", "24h", "2d", "7d", "30d" ] }, "timezone": "", "title": "linux_load", "uid": "zeTsFdKik", "version": 10 }