From 1b41fc2132ded9dab6d8bc63f0627bda06084dc0 Mon Sep 17 00:00:00 2001 From: Elric Milon Date: Fri, 20 Jan 2017 20:48:06 +0100 Subject: [PATCH 1/2] Add iotime field to dio widget. --- widgets/dio_linux.lua | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/widgets/dio_linux.lua b/widgets/dio_linux.lua index b73cd21..82fa50f 100644 --- a/widgets/dio_linux.lua +++ b/widgets/dio_linux.lua @@ -27,16 +27,17 @@ local disk_stats = {} local disk_time = 0 -- Constant definitions local unit = { ["s"] = 1, ["kb"] = 2, ["mb"] = 2048 } +local time_unit = { ["ms"] = 1, ["s"] = 1000 } -- {{{ Disk I/O widget type local function worker(format) local disk_lines = {} for line in io.lines("/proc/diskstats") do - local device, read, write = + local device, read, write, iotime = -- Linux kernel documentation: Documentation/iostats.txt - string.match(line, "([^%s]+) %d+ %d+ (%d+) %d+ %d+ %d+ (%d+)") - disk_lines[device] = { read, write } + string.match(line, "([^%s]+) %d+ %d+ (%d+) %d+ %d+ %d+ (%d+) %d+ %d+ (%d+)") + disk_lines[device] = { read, write, iotime } end local time = os.time() @@ -49,18 +50,20 @@ local function worker(format) -- Check for overflows and counter resets (> 2^32) if stats[1] < last_stats[1] or stats[2] < last_stats[2] then - last_stats[1], last_stats[2] = stats[1], stats[2] + last_stats[1], last_stats[2], last_stats[3] = stats[1], stats[2], stats[3] end -- Diskstats are absolute, substract our last reading -- * divide by timediff because we don't know the timer value local read = (stats[1] - last_stats[1]) / interval local write = (stats[2] - last_stats[2]) / interval + local iotime = (stats[3] - last_stats[3]) / interval -- Calculate and store I/O helpers.uformat(disk_usage, device.." read", read, unit) helpers.uformat(disk_usage, device.." write", write, unit) helpers.uformat(disk_usage, device.." total", read + write, unit) + helpers.uformat(disk_usage, device.." iotime", iotime, time_unit) end disk_time = time From e66ce03a51fd24f733f1eec91bb622ddc568c2b6 Mon Sep 17 00:00:00 2001 From: Elric Milon Date: Sun, 29 Jan 2017 12:02:19 +0100 Subject: [PATCH 2/2] Add iotime keys to README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f71f925..36720f9 100644 --- a/README.md +++ b/README.md @@ -213,7 +213,7 @@ Supported platforms: Linux. - Returns: * returns a table with string keys: `{sda total_s}`, `{sda total_kb}`, `{sda total_mb}`, `{sda read_s}`, `{sda read_kb}`, `{sda read_mb}`, `{sda write_s}`, - `{sda write_kb}`, `{sda write_mb}`, `{sdb1 total_s}` etc. + `{sda write_kb}`, `{sda write_mb}`, `{sda iotime_ms}`, `{sda iotime_s}`, `{sdb1 total_s}` etc. **vicious.widget.fanspeed**