raid: import raid state widget type by Hagen
This widget type returns 1st value as the number of assigned, and 2nd as active, devices in the array provided as the widget argument.
This commit is contained in:
parent
9af29ce1e6
commit
a9347ec0d0
7
README
7
README
|
@ -172,6 +172,12 @@ vicious.widgets.dio
|
||||||
{read_s}, {read_kb}, {read_mb}, {write_s}, {write_kb}, {write_mb}
|
{read_s}, {read_kb}, {read_mb}, {write_s}, {write_kb}, {write_mb}
|
||||||
and {sched}
|
and {sched}
|
||||||
|
|
||||||
|
vicious.widgets.raid
|
||||||
|
- provides state information for a requested RAID array
|
||||||
|
- takes the RAID array ID as an argument
|
||||||
|
- returns 1st value as the number of assigned, and 2nd as active,
|
||||||
|
devices in the array
|
||||||
|
|
||||||
vicious.widgets.hddtemp
|
vicious.widgets.hddtemp
|
||||||
- provides hard drive temperatures using the hddtemp daemon
|
- provides hard drive temperatures using the hddtemp daemon
|
||||||
- takes the hddtemp listening port as an argument, or defaults to
|
- takes the hddtemp listening port as an argument, or defaults to
|
||||||
|
@ -501,3 +507,4 @@ Vicious contributors:
|
||||||
- Henning Glawe <glaweh debian.org>
|
- Henning Glawe <glaweh debian.org>
|
||||||
- Rémy C. <shikamaru mandriva.org>
|
- Rémy C. <shikamaru mandriva.org>
|
||||||
- Hiltjo Posthuma <hiltjo codemadness.org>
|
- Hiltjo Posthuma <hiltjo codemadness.org>
|
||||||
|
- Hagen Schink <troja84 googlemail.com>
|
||||||
|
|
|
@ -16,6 +16,7 @@ require("vicious.widgets.mem")
|
||||||
require("vicious.widgets.os")
|
require("vicious.widgets.os")
|
||||||
require("vicious.widgets.fs")
|
require("vicious.widgets.fs")
|
||||||
require("vicious.widgets.dio")
|
require("vicious.widgets.dio")
|
||||||
|
require("vicious.widgets.raid")
|
||||||
require("vicious.widgets.hddtemp")
|
require("vicious.widgets.hddtemp")
|
||||||
require("vicious.widgets.net")
|
require("vicious.widgets.net")
|
||||||
require("vicious.widgets.wifi")
|
require("vicious.widgets.wifi")
|
||||||
|
|
|
@ -0,0 +1,56 @@
|
||||||
|
-----------------------------------------------------
|
||||||
|
-- Licensed under the GNU General Public License v2
|
||||||
|
-- * (c) 2010, Hagen Schink <troja84@googlemail.com>
|
||||||
|
-----------------------------------------------------
|
||||||
|
|
||||||
|
-- {{{ Grab environment
|
||||||
|
local io = { lines = io.lines }
|
||||||
|
local setmetatable = setmetatable
|
||||||
|
local string = {
|
||||||
|
len = string.len,
|
||||||
|
sub = string.sub,
|
||||||
|
match = string.match,
|
||||||
|
gmatch = string.gmatch
|
||||||
|
}
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
|
||||||
|
-- Raid: provides state information for a requested RAID array
|
||||||
|
module("vicious.widgets.raid")
|
||||||
|
|
||||||
|
|
||||||
|
-- {{{ RAID widget type
|
||||||
|
local function worker(format, warg)
|
||||||
|
if not warg then return end
|
||||||
|
|
||||||
|
local found = false
|
||||||
|
local mddev = {}
|
||||||
|
mddev[warg] = {
|
||||||
|
["active"] = 0,
|
||||||
|
["assigned"] = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
-- Linux manual page: md(4)
|
||||||
|
for line in io.lines("/proc/mdstat") do
|
||||||
|
if found then
|
||||||
|
local updev = string.match(line, "%[[_U]+%]")
|
||||||
|
|
||||||
|
for i in string.gmatch(updev, "U") do
|
||||||
|
mddev[warg]["active"] = mddev[warg]["active"] + 1
|
||||||
|
end
|
||||||
|
|
||||||
|
break
|
||||||
|
elseif string.sub(line, 1, string.len(warg)) == warg then
|
||||||
|
found = true
|
||||||
|
|
||||||
|
for i in string.gmatch(line, "%[%d%]") do
|
||||||
|
mddev[warg]["assigned"] = mddev[warg]["assigned"] + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
return {mddev[warg]["assigned"], mddev[warg]["active"]}
|
||||||
|
end
|
||||||
|
-- }}}
|
||||||
|
|
||||||
|
setmetatable(_M, { __call = function(_, ...) return worker(...) end })
|
Loading…
Reference in New Issue