2021-08-08 15:58:53 -04:00
|
|
|
local format = require 'format'
|
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
|
|
|
|
2021-08-08 19:12:31 -04:00
|
|
|
return function(update_freq, devices)
|
2021-07-18 00:03:44 -04:00
|
|
|
local PLOT_SEC_BREAK = 20
|
|
|
|
local PLOT_HEIGHT = 56
|
2021-08-08 19:12:31 -04:00
|
|
|
local DEVICE_PATHS = sys.get_disk_paths(devices)
|
2017-07-19 00:36:15 -04:00
|
|
|
|
2021-08-08 19:12:31 -04:00
|
|
|
local init_read_bytes, init_write_bytes = 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
|
|
|
|
|
2021-07-29 23:04:39 -04:00
|
|
|
local make_plot = function(y, label, init)
|
|
|
|
return common.make_rate_timeseries(
|
2021-07-29 22:18:29 -04:00
|
|
|
geometry.CENTER_LEFT_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,
|
|
|
|
init
|
2021-07-18 00:03:44 -04:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
|
|
|
-----------------------------------------------------------------------------
|
2021-07-19 23:58:58 -04:00
|
|
|
-- header
|
2021-07-18 00:03:44 -04:00
|
|
|
|
2021-07-29 23:04:39 -04:00
|
|
|
local header = common.make_header(
|
2021-07-29 22:18:29 -04:00
|
|
|
geometry.CENTER_LEFT_X,
|
|
|
|
geometry.TOP_Y,
|
|
|
|
geometry.SECTION_WIDTH,
|
2021-07-19 23:58:58 -04:00
|
|
|
'INPUT / OUTPUT'
|
2021-07-17 16:43:00 -04:00
|
|
|
)
|
2017-07-19 00:36:15 -04:00
|
|
|
|
2021-07-18 00:03:44 -04:00
|
|
|
-----------------------------------------------------------------------------
|
2021-07-19 23:58:58 -04:00
|
|
|
-- reads
|
2021-07-18 00:03:44 -04:00
|
|
|
|
2021-07-29 23:04:39 -04:00
|
|
|
local reads = make_plot(header.bottom_y, 'Reads', init_read_bytes)
|
2021-07-18 00:03:44 -04:00
|
|
|
|
2021-07-19 23:58:58 -04:00
|
|
|
-----------------------------------------------------------------------------
|
|
|
|
-- writes
|
2021-07-18 00:03:44 -04:00
|
|
|
|
2021-07-29 23:04:39 -04:00
|
|
|
local writes = make_plot(
|
2021-07-19 23:58:58 -04:00
|
|
|
header.bottom_y + PLOT_HEIGHT + PLOT_SEC_BREAK * 2,
|
|
|
|
'Writes',
|
|
|
|
init_write_bytes
|
|
|
|
)
|
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
|
|
|
|
2021-07-26 23:45:54 -04:00
|
|
|
local update = function()
|
2021-08-08 19:12:31 -04:00
|
|
|
local read_bytes, write_bytes = sys.get_total_disk_io(DEVICE_PATHS)
|
2021-07-29 22:18:29 -04:00
|
|
|
common.update_rate_timeseries(reads, read_bytes)
|
|
|
|
common.update_rate_timeseries(writes, write_bytes)
|
2021-07-17 00:17:22 -04:00
|
|
|
end
|
|
|
|
|
2021-07-17 16:43:00 -04:00
|
|
|
local draw_static = function(cr)
|
2021-07-29 23:04:39 -04:00
|
|
|
common.draw_header(cr, header)
|
2021-07-30 22:46:20 -04:00
|
|
|
common.tagged_scaled_timeseries_draw_static(reads, cr)
|
|
|
|
common.tagged_scaled_timeseries_draw_static(writes, cr)
|
2021-07-17 16:43:00 -04:00
|
|
|
end
|
|
|
|
|
2021-07-17 00:17:22 -04:00
|
|
|
local draw_dynamic = function(cr)
|
2021-07-30 22:46:20 -04:00
|
|
|
common.tagged_scaled_timeseries_draw_dynamic(reads, cr)
|
|
|
|
common.tagged_scaled_timeseries_draw_dynamic(writes, cr)
|
2021-07-17 00:17:22 -04:00
|
|
|
end
|
|
|
|
|
2021-07-27 23:47:26 -04:00
|
|
|
return {static = draw_static, dynamic = draw_dynamic, update = update}
|
2017-07-19 00:36:15 -04:00
|
|
|
end
|