aboutsummaryrefslogtreecommitdiff
path: root/dio.lua
diff options
context:
space:
mode:
authorAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-14 01:55:33 +0100
committerAdrian C. (anrxc) <anrxc@sysphere.org>2010-03-14 01:55:33 +0100
commit237470c8f45190b213e3a173ce6ae1a74b3e11fe (patch)
tree7f53c8144761947d4bde20715bcad34f4be0d6c0 /dio.lua
parent9a82d4113a8271b7dfc7506f2b07379e3ede89a8 (diff)
downloadvicious-legacy-237470c8f45190b213e3a173ce6ae1a74b3e11fe.tar.xz
API: transform widgets namespace table to a directory
Diffstat (limited to 'dio.lua')
-rw-r--r--dio.lua71
1 files changed, 0 insertions, 71 deletions
diff --git a/dio.lua b/dio.lua
deleted file mode 100644
index 33f1f34..0000000
--- a/dio.lua
+++ /dev/null
@@ -1,71 +0,0 @@
----------------------------------------------------
--- Licensed under the GNU General Public License v2
--- * (c) 2010, Adrian C. <anrxc@sysphere.org>
----------------------------------------------------
-
--- {{{ Grab environment
-local ipairs = ipairs
-local setmetatable = setmetatable
-local table = { insert = table.insert }
-local string = { gmatch = string.gmatch }
-local helpers = require("vicious.helpers")
--- }}}
-
-
--- Disk I/O: provides I/O statistics for requested storage devices
-module("vicious.dio")
-
-
--- Initialise function tables
-local disk_usage = {}
-local disk_total = {}
--- Variable definitions
-local unit = { ["s"] = 1, ["kb"] = 2, ["mb"] = 2048 }
-
--- {{{ Disk I/O widget type
-local function worker(format, disk)
- local disk_lines = { [disk] = {} }
- local disk_stats = helpers.pathtotable("/sys/block/" .. disk)
- local disk_queue = helpers.pathtotable("/sys/block/" .. disk .. "/queue")
-
- if disk_stats.stat then
- local match = string.gmatch(disk_stats.stat, "[%s]+([%d]+)")
- for i = 1, 11 do -- Store disk stats
- table.insert(disk_lines[disk], match())
- end
- end
-
- -- Ensure tables are initialized correctly
- local diff_total = { [disk] = {} }
- if not disk_total[disk] then
- disk_usage[disk] = {}
- disk_total[disk] = {}
-
- while #disk_total[disk] < #disk_lines[disk] do
- table.insert(disk_total[disk], 0)
- end
- end
-
- for i, v in ipairs(disk_lines[disk]) do
- -- Diskstats are absolute, substract our last reading
- diff_total[disk][i] = v - disk_total[disk][i]
-
- -- Store totals
- disk_total[disk][i] = v
- end
-
- -- Calculate and store I/O
- helpers.uformat(disk_usage[disk], "read", diff_total[disk][3], unit)
- helpers.uformat(disk_usage[disk], "write", diff_total[disk][7], unit)
- helpers.uformat(disk_usage[disk], "total", diff_total[disk][7] + diff_total[disk][3], unit)
-
- -- Store I/O scheduler
- if disk_queue.scheduler then
- disk_usage[disk]["{sched}"] = string.gmatch(disk_queue.scheduler, "%[([%a]+)%]")
- end
-
- return disk_usage[disk]
-end
--- }}}
-
-setmetatable(_M, { __call = function(_, ...) return worker(...) end })