修改sysbench输出格式为csv或json, 添加自定义指标

修改sysbench输出格式为csv或json, 添加自定义指标

在oltp_common.lua添加(二选一)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19

-- 输出csv

-- function sysbench.hooks.report_intermediate(stat)

-- sysbench.report_csv(stat)

-- end



-- 输出json

-- function sysbench.hooks.report_intermediate(stat)

-- sysbench.report_json(stat)

-- end

自己去掉 -- 注释

加hook

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

sysbench.hooks.report_intermediate =

function (stat)

if con == nil then

con = assert(sysbench.sql.driver():connect())

end

sysbench.report_default(stat)

create_time, node_219, node_220 = con:query_row([[

select create_time,(select delay from test.test_mgr_delay_detail where ip='192.168.2.219' order by create_time desc limit 1) as 'node_219',(select delay from test.test_mgr_delay_detail where ip='192.168.2.220' order by create_time desc limit 1) as 'node_220' from test.test_mgr_delay_detail order by create_time desc limit 1;]])

print("create_time: "..create_time.." node_219: "..node_219.." node_220: "..node_220)

end

这样的效果就是

1
2
3
4
5
6
[ 5s ] thds: 30 tps: 73.76 qps: 1538.67 (r/w/o: 1084.35/300.82/153.51) lat (ms,95%): 733.00 err/s: 0.00 reconn/s: 0.00
create_time: 2018-01-01 10:10:00 node_219: 10 node_220: 20
[ 10s ] thds: 30 tps: 75.80 qps: 1519.27 (r/w/o: 1062.85/304.81/151.61) lat (ms,95%): 590.56 err/s: 0.00 reconn/s: 0.00
create_time: 2018-01-01 10:15:00 node_219: 10 node_220: 20
[ 15s ] thds: 30 tps: 58.39 qps: 1183.57 (r/w/o: 831.24/235.55/116.78) lat (ms,95%): 926.33 err/s: 0.00 reconn/s: 0.00
create_time: 2018-01-01 10:20:00 node_219: 10 node_220: 20

总之就是你可以自定以一些sql查询或者系统命令去增加一些指标. 我这里就是想看不同XX下对从库复制延迟的影响

Powered by Hexo and Hexo-theme-hiker

Copyright © 2013 - 2021 Fan() All Rights Reserved.

访客数 : | 访问量 :