2021-08-08 15:58:53 -04:00
|
|
|
local format = require 'format'
|
2022-07-14 22:59:14 -04:00
|
|
|
local pure = require 'pure'
|
2021-07-29 22:18:29 -04:00
|
|
|
local common = require 'common'
|
|
|
|
local geometry = require 'geometry'
|
2021-08-08 19:12:31 -04:00
|
|
|
local sys = require 'sys'
|
2017-07-19 00:36:15 -04:00
|
|
|
|
2022-07-14 20:13:29 -04:00
|
|
|
return function(update_freq, devices, point)
|
2021-07-18 00:03:44 -04:00
|
|
|
local PLOT_SEC_BREAK = 20
|
|
|
|
local PLOT_HEIGHT = 56
|
2022-07-13 01:17:58 -04:00
|
|
|
-- TODO currently this will find any block device
|
2021-08-08 19:12:31 -04:00
|
|
|
local DEVICE_PATHS = sys.get_disk_paths(devices)
|
2017-07-19 00:36:15 -04:00
|
|
|
|
2022-07-14 22:59:14 -04:00
|
|
|
local state = {read = 0, write = 0}
|
|
|
|
state.read, state.write = sys.get_total_disk_io(DEVICE_PATHS)
|
2021-07-18 00:03:44 -04:00
|
|
|
|
|
|
|
local format_value_function = function(bps)
|
2021-08-08 15:58:53 -04:00
|
|
|
local unit, value = format.convert_data_val(bps)
|
|
|
|
return format.precision_round_to_string(value, 3)..' '..unit..'B/s'
|
2021-07-18 00:03:44 -04:00
|
|
|
end
|
|
|
|
|
2022-07-14 22:59:14 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- r/w plots
|
|
|
|
|
|
|
|
local mk_plot = function(label, key, y)
|
|
|
|
local obj = common.make_rate_timeseries(
|
2022-07-14 20:13:29 -04:00
|
|
|
point.x,
|
2021-07-18 00:03:44 -04:00
|
|
|
y,
|
2021-07-29 22:18:29 -04:00
|
|
|
geometry.SECTION_WIDTH,
|
2021-07-18 00:03:44 -04:00
|
|
|
PLOT_HEIGHT,
|
|
|
|
format_value_function,
|
2021-07-29 22:18:29 -04:00
|
|
|
common.converted_y_label_format_generator('B'),
|
2021-07-18 00:03:44 -04:00
|
|
|
PLOT_SEC_BREAK,
|
|
|
|
label,
|
|
|
|
2,
|
2021-07-19 23:58:58 -04:00
|
|
|
update_freq,
|
2022-07-14 22:59:14 -04:00
|
|
|
state[key]
|
|
|
|
)
|
|
|
|
return common.mk_acc(
|
|
|
|
PLOT_HEIGHT + PLOT_SEC_BREAK,
|
|
|
|
function() common.update_rate_timeseries(obj, state[key]) end,
|
|
|
|
pure.partial(common.tagged_scaled_timeseries_draw_static, obj),
|
|
|
|
pure.partial(common.tagged_scaled_timeseries_draw_dynamic, obj)
|
2021-07-18 00:03:44 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2022-07-14 22:59:14 -04:00
|
|
|
local mk_reads = pure.partial(mk_plot, 'Reads', 'read')
|
|
|
|
local mk_writes = pure.partial(mk_plot, 'Writes', 'write')
|
2021-07-18 01:31:51 -04:00
|
|
|
|
2021-07-19 23:58:58 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- main drawing functions
|
2021-07-17 00:17:22 -04:00
|
|
|
|
2022-07-14 22:59:14 -04:00
|
|
|
local rbs = common.reduce_blocks_(
|
|
|
|
'INPUT / OUTPUT',
|
|
|
|
point,
|
|
|
|
geometry.SECTION_WIDTH,
|
|
|
|
{
|
|
|
|
common.mk_block(mk_reads, true, 0),
|
|
|
|
common.mk_block(mk_writes, true, PLOT_SEC_BREAK),
|
|
|
|
}
|
|
|
|
)
|
2021-07-17 00:17:22 -04:00
|
|
|
|
2022-07-14 22:59:14 -04:00
|
|
|
return pure.map_at(
|
|
|
|
"update",
|
|
|
|
function(f)
|
|
|
|
return function()
|
|
|
|
state.read, state.write = sys.get_total_disk_io(DEVICE_PATHS)
|
|
|
|
f()
|
|
|
|
end
|
|
|
|
end,
|
|
|
|
rbs)
|
2017-07-19 00:36:15 -04:00
|
|
|
end
|