mirror of
https://github.com/sirpdboy/sirpdboy-package.git
synced 2025-01-08 11:57:57 +08:00
nodiskdisp
This commit is contained in:
parent
c007a41813
commit
3bab76f7e2
@ -710,10 +710,18 @@
|
||||
<tr><td width="33%"><%:CPU usage (%)%></td><td id="cpuusage">-</td></tr>
|
||||
<tr><td width="33%"><%:help%></td>
|
||||
<td id="cpr">
|
||||
<input type="button" class="cbi-button cbi-button-apply" value="更新建议" onclick="window.open('https://github.com/sirpdboy/openwrt18.06/issues')" />
|
||||
<input type="button" class="cbi-button cbi-button-apply" value="TG聊天群" onclick="window.open('https://t.me/joinchat/AAAAAEpRF88NfOK5vBXGBQ')" />
|
||||
<input type="button" class="cbi-button cbi-button-apply" value="<%:更新建议%>" onclick="window.open('https://github.com/sirpdboy/openwrt18.06/issues')" />
|
||||
<input type="button" class="cbi-button cbi-button-apply" value="<%:TG聊天群%>" onclick="window.open('https://t.me/joinchat/AAAAAEpRF88NfOK5vBXGBQ')" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:天气%></legend>
|
||||
|
||||
<table width="100%" cellspacing="10">
|
||||
<tr><td width="33%"><%:城市天气%></td><td > <iframe width="680" scrolling="no" height="120" frameborder="0" allowtransparency="true" src="//i.tianqi.com/index.php?c=code&id=22&icon=1&temp=1&num=5&site=12"></iframe>
|
||||
</table>
|
||||
</fieldset>
|
||||
<fieldset class="cbi-section">
|
||||
@ -725,7 +733,6 @@
|
||||
<tr><td width="33%"><%:Buffered%></td><td id="membuff">-</td></tr>
|
||||
</table>
|
||||
</fieldset>
|
||||
|
||||
<% if swapinfo.total > 0 then %>
|
||||
<fieldset class="cbi-section">
|
||||
<legend><%:Swap%></legend>
|
||||
|
@ -868,289 +868,6 @@
|
||||
</fieldset>
|
||||
<% end %>
|
||||
|
||||
|
||||
<% local raid = {}
|
||||
local devs = {}
|
||||
local devinfo = {}
|
||||
local colors = { "c0c0ff", "fbbd00", "e97c30", "a0e0a0", "e0c0ff" }
|
||||
local mounts = nixio.fs.readfile("/proc/mounts")
|
||||
|
||||
local show_raid = 1
|
||||
local show_disc = 1
|
||||
|
||||
if self then
|
||||
if self.hide_raid then
|
||||
show_raid = 0
|
||||
end
|
||||
if self.hide_disc then
|
||||
show_disc = 0
|
||||
end
|
||||
end
|
||||
|
||||
function disp_size(s)
|
||||
local units = { "kB", "MB", "GB", "TB" }
|
||||
local i, unit
|
||||
s = s / 2
|
||||
for i, unit in ipairs(units) do
|
||||
if (i == #units) or (s < 1024) then
|
||||
return math.floor(s * 100) / 100 .. unit
|
||||
end
|
||||
s = s / 1024
|
||||
end
|
||||
end
|
||||
|
||||
function first_line(s)
|
||||
local n = s:find("\n")
|
||||
if n then
|
||||
return s:sub(1, n-1)
|
||||
end
|
||||
return s
|
||||
end
|
||||
|
||||
function get_fs(pname, status)
|
||||
for r,raid in ipairs(raid) do
|
||||
for m,member in ipairs(raid.members) do
|
||||
if member.name == pname then
|
||||
return "(raid member)"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local mounted_fs = mounts:match("\n[a-z/]*" .. pname .. " [^ ]* ([^ ]*)")
|
||||
if mounted_fs then
|
||||
if status == "standby" then
|
||||
return "(" .. mounted_fs .. ")"
|
||||
end
|
||||
local df = luci.sys.exec("df /dev/" .. pname):match(" ([0-9]+)%% ")
|
||||
return "(" .. mounted_fs .. " " .. df .. "%)"
|
||||
end
|
||||
|
||||
if status == "standby" then
|
||||
return
|
||||
end
|
||||
|
||||
local blkid = luci.sys.exec(" blkid -s TYPE /dev/" .. pname):match("TYPE=\"(.*)\"")
|
||||
if blkid then
|
||||
return "(" .. blkid .. ")"
|
||||
end
|
||||
end
|
||||
|
||||
function get_status(raid)
|
||||
for m,member in ipairs(raid.members) do
|
||||
for d,dev in ipairs(devinfo) do
|
||||
if member.name == dev.name then
|
||||
return dev.status
|
||||
end
|
||||
for p,part in ipairs(dev.parts) do
|
||||
if member.name == part.name then
|
||||
return dev.status
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function get_parts(dev,status,size)
|
||||
local c = 1
|
||||
local unused = size
|
||||
local parts = {}
|
||||
|
||||
for part in nixio.fs.glob("/sys/block/" .. dev .."/" .. dev .. "*") do
|
||||
local pname = nixio.fs.basename(part)
|
||||
local psize = nixio.fs.readfile(part .. "/size")
|
||||
table.insert(parts, {name=pname, size=psize, perc=math.floor(psize*100/size), fs=get_fs(pname,status), color=colors[c]})
|
||||
c = c + 1
|
||||
unused = unused - psize
|
||||
end
|
||||
if unused > 2048 then
|
||||
table.insert(parts, { name="", fs=get_fs(dev,status), size=unused, color=colors[c] })
|
||||
end
|
||||
return parts
|
||||
end
|
||||
|
||||
for dev in nixio.fs.glob("/sys/block/*") do
|
||||
if nixio.fs.access(dev .. "/md") then
|
||||
local name = nixio.fs.basename(dev)
|
||||
local rlevel = first_line(nixio.fs.readfile(dev .. "/md/level"))
|
||||
local ndisks = tonumber(nixio.fs.readfile(dev .. "/md/raid_disks"))
|
||||
local size = tonumber(nixio.fs.readfile(dev .. "/size"))
|
||||
local metav = nixio.fs.readfile(dev .. "/md/metadata_version")
|
||||
local degr = tonumber(nixio.fs.readfile(dev .. "/md/degraded"))
|
||||
local sync = first_line(nixio.fs.readfile(dev .. "/md/sync_action"))
|
||||
local sync_speed = tonumber(nixio.fs.readfile(dev .. "/md/sync_speed"))
|
||||
local sync_compl = nixio.fs.readfile(dev .. "/md/sync_completed")
|
||||
local status = "active"
|
||||
if sync ~= "idle" then
|
||||
local progress, total = nixio.fs.readfile(dev .. "/md/sync_completed"):match("^([0-9]*)[^0-9]*([0-9]*)")
|
||||
local rem = (total - progress) / sync_speed / 2
|
||||
local rems = math.floor(rem % 60)
|
||||
if rems < 10 then rems = "0" .. rems end
|
||||
rem = math.floor(rem / 60)
|
||||
local remm = math.floor(rem % 60)
|
||||
if remm < 10 then remm = "0" .. remm end
|
||||
local remh = math.floor(rem / 60)
|
||||
local remstr = remh .. ":" .. remm .. ":" .. rems
|
||||
status = sync .. " (" .. math.floor(sync_speed/1024) .. "MB/s, " .. math.floor(progress * 1000 / total) /10 .. "%, rem. " .. remstr .. ")"
|
||||
elseif degr == 1 then
|
||||
status = "degraded"
|
||||
end
|
||||
|
||||
local members = {}
|
||||
local c = 1
|
||||
for member in nixio.fs.glob("/sys/block/" .. name .. "/md/dev-*") do
|
||||
local dname = nixio.fs.basename(nixio.fs.readlink(member .. "/block"))
|
||||
local dsize = disp_size(tonumber(nixio.fs.readfile(member .. "/block/size")))
|
||||
local dstate = nixio.fs.readfile(member .. "/state"):gsub("_", " "):match "^%s*(.-)%s*$"
|
||||
table.insert(members, { name = dname, size = dsize, state = dstate, color = colors[c] })
|
||||
c = c + 1
|
||||
end
|
||||
table.insert(raid, {name=name, rlevel=rlevel, ndisks=ndisks, size=size, metav=metav, status=status, members=members })
|
||||
end
|
||||
end
|
||||
|
||||
if show_disc == 1 then
|
||||
for dev in nixio.fs.glob("/sys/class/scsi_disk/*/device") do
|
||||
local section
|
||||
local model = nixio.fs.readfile(dev .. "/model")
|
||||
local fw = nixio.fs.readfile(dev .. "/rev")
|
||||
for bdev in nixio.fs.glob(dev .. "/block/*") do
|
||||
local section
|
||||
local name = nixio.fs.basename(bdev)
|
||||
local size = tonumber(nixio.fs.readfile(bdev .. "/size"))
|
||||
local unused = size
|
||||
local status = "-"
|
||||
local temp = "-"
|
||||
local serial = "-"
|
||||
local secsize = "-"
|
||||
|
||||
for _,line in ipairs(luci.util.execl("smartctl -A -i -n standby -f brief /dev/" .. name)) do
|
||||
local attrib, val
|
||||
if section == 1 then
|
||||
attrib, val = line:match "^(.*):%s*(.*)"
|
||||
elseif section == 2 then
|
||||
attrib, val = line:match("^([0-9 ]*) [^ ]* * [POSRCK-]* *[0-9-]* *[0-9-]* *[0-9-]* *[0-9-]* *([0-9-]*)")
|
||||
else
|
||||
attrib = line:match "^=== START OF (.*) SECTION ==="
|
||||
if attrib == "INFORMATION" then
|
||||
section = 1
|
||||
elseif attrib == "READ SMART DATA" then
|
||||
section = 2
|
||||
elseif status == "-" then
|
||||
val = line:match "^Device is in (.*) mode"
|
||||
if val then
|
||||
status = val:lower()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if not attrib then
|
||||
if section ~= 2 then section = 0 end
|
||||
elseif (attrib == "Power mode is") or (attrib == "Power mode was") then
|
||||
status = val:lower():match "(%S*)"
|
||||
elseif attrib == "Sector Sizes" then
|
||||
secsize = val:match "([0-9]*) bytes physical"
|
||||
elseif attrib == "Sector Size" then
|
||||
secsize = val:match "([0-9]*)"
|
||||
elseif attrib == "Serial Number" then
|
||||
serial = val
|
||||
elseif attrib == "194" then
|
||||
temp = val .. "°C"
|
||||
end
|
||||
end
|
||||
table.insert(devinfo, {name=name, model=model, fw=fw, size=size, status=status, temp=temp, serial=serial, secsize=secsize, parts=get_parts(name,status,size) })
|
||||
end
|
||||
end
|
||||
|
||||
for r,dev in ipairs(raid) do
|
||||
table.insert(devinfo, {name=dev.name, model="Linux RAID", size=dev.size, status=get_status(dev), secsize=secsize, parts=get_parts(dev.name,status,dev.size) })
|
||||
end
|
||||
end
|
||||
|
||||
if show_disc == 1 then %>
|
||||
<div class="cbi-section">
|
||||
<h4><%:Disks%></h4>
|
||||
<table class="cbi-section-table" style="white-space: nowrap">
|
||||
|
||||
<tr>
|
||||
<th width="5%"><%:Path%></th>
|
||||
<th width="30%"><%:Disks Model%></th>
|
||||
<th width="15%"><%:Serial Number%></th>
|
||||
<th width="10%"><%:Firmware%></th>
|
||||
<th width="10%"><%:Capacity%></th>
|
||||
<th width="7%"><%:Sector size%></th>
|
||||
<th width="7%"><%:Temperature%></th>
|
||||
<th width="16%"><%:Power state%></th>
|
||||
</tr>
|
||||
<% local style=true
|
||||
for d,dev in ipairs(devinfo) do %>
|
||||
<tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
|
||||
<td class="cbi-vluae-field" style="padding-bottom:0px; border-bottom-width:0px; vertical-align:middle" rowspan="4"><%=dev.name%></td>
|
||||
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.model%></td>
|
||||
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.serial%></td>
|
||||
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.fw%></td>
|
||||
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=disp_size(dev.size)%></td>
|
||||
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.secsize%></td>
|
||||
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.temp%></td>
|
||||
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.status%></td>
|
||||
</tr>
|
||||
<tr style="height:0px" />
|
||||
<tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
|
||||
<td style="padding-top:0px; border-top-width:0px" colspan="7" rowspan="2">
|
||||
<table style="border: 0pt; border-collapse:collapse; width:100%; padding:0px; margin:0px"><tr>
|
||||
<% for _,part in pairs(dev.parts) do %>
|
||||
<td style="text-align:center; padding: 0px 4px; border-radius: 3px; background-color:#<%=part.color%>" width="<%=part.perc%>%"><%=part.name%> <%=disp_size(part.size)%> <%=part.fs%></td>
|
||||
<% end %>
|
||||
</tr></table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="height:0px" />
|
||||
<% style = not style
|
||||
end %>
|
||||
</table>
|
||||
</div>
|
||||
<% end
|
||||
if show_raid == 1 and #raid > 0 then %>
|
||||
<div class="cbi-section">
|
||||
<h4><%:Raid arrays%></h4>
|
||||
<table class="cbi-section-table" style="white-space:nowrap">
|
||||
<tr>
|
||||
<th width="5%"><%:Path%></th>
|
||||
<th width="13%"><%:Level%></th>
|
||||
<th width="13%"><%:# Disks%></th>
|
||||
<th width="13%"><%:Capacity%></th>
|
||||
<th width="13%"><%:Metadata%></th>
|
||||
<th width="43%"><%:Status%></th>
|
||||
</tr>
|
||||
<% local style=true
|
||||
for r,dev in ipairs(raid) do %>
|
||||
<tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
|
||||
<td class="cbi-vluae-field" style="padding-bottom:0px; border-bottom-width:0px; vertical-align:middle" rowspan="4"><%=dev.name%></td>
|
||||
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.rlevel%></td>
|
||||
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.ndisks%></td>
|
||||
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=disp_size(dev.size)%></td>
|
||||
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.metav%></td>
|
||||
<td class="cbi-value-field" style="padding-bottom:0px; border-bottom-width:0px" rowspan="2"><%=dev.status%></td>
|
||||
</tr>
|
||||
<tr style="height:0px" />
|
||||
<tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
|
||||
<td style="padding-top:0px; border-top-width:0px" colspan="6" rowspan="2">
|
||||
<table style="border: 0pt; border-collapse:collapse; width:100%; padding:0px; margin:0px"><tr>
|
||||
<% for _,member in pairs(dev.members) do %>
|
||||
<td style="text-align:center; padding: 0px 4px; border-radius: 3px; background-color:#<%=member.color%>; white-space: nowrap"><%=member.name%> <%=member.size%> (<%=member.state%>)</td>
|
||||
<% end %>
|
||||
</tr></table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr style="height:0px" />
|
||||
<% style = not style
|
||||
end %>
|
||||
</table>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
||||
<%-
|
||||
local incdir = util.libpath() .. "/view/admin_status/index/"
|
||||
if fs.access(incdir) then
|
||||
|
@ -30,7 +30,7 @@ uci set network.@wan[0].mtu=1400
|
||||
uci commit network
|
||||
#rm -f /usr/lib/lua/luci/view/admin_status/index/mwan.htm
|
||||
#rm -f /usr/lib/lua/luci/view/admin_status/index/upnp.htm
|
||||
#rm -f /usr/lib/lua/luci/view/admin_status/index/ddns.htm
|
||||
rm -f /usr/lib/lua/luci/view/admin_status/index/ddns.htm
|
||||
rm -f /usr/lib/lua/luci/view/admin_status/index/minidlna.htm
|
||||
sed -i '/coremark/d' /etc/crontabs/root
|
||||
sed -i 's/\"services\"/\"nas\"/g' /usr/lib/lua/luci/controller/aria2.lua
|
||||
|
@ -30,10 +30,10 @@ msgid "Enable"
|
||||
msgstr "启用"
|
||||
|
||||
msgid "Browser management port"
|
||||
msgstr "登陆账号密码:admin 网页管理端口"
|
||||
msgstr "登陆账号和密码:admin 端口"
|
||||
|
||||
msgid "Update"
|
||||
msgstr "请先手动设置中保存应用后再更新"
|
||||
msgstr "更新"
|
||||
#button change
|
||||
msgid "Update core version"
|
||||
msgstr "更新核心版本"
|
||||
@ -54,8 +54,10 @@ msgstr "快速配置"
|
||||
msgid "core version:"
|
||||
msgstr "核心版本:"
|
||||
#description change
|
||||
|
||||
msgid "no config"
|
||||
msgstr "没有配置文件"
|
||||
|
||||
msgid "no core"
|
||||
msgstr "没有核心"
|
||||
#
|
||||
|
@ -17,6 +17,6 @@
|
||||
<iframe id="netdata" style="width: 100%; min-height: 1200px; border: none; border-radius: 3px;"></iframe>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
document.getElementById("netdata").src = window.location.protocol + "//" + window.location.hostname + ":19999";
|
||||
document.getElementById("netdata").src ="http://" + window.location.hostname + ":19999";
|
||||
</script>
|
||||
<%+footer%>
|
||||
|
@ -4,6 +4,6 @@
|
||||
<iframe id="terminal" style="width: 100%; min-height: 500px; border: none; border-radius: 3px;"></iframe>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
document.getElementById("terminal").src = window.location.protocol + "//" + window.location.hostname + ":7681";
|
||||
document.getElementById("terminal").src = "http://" + window.location.hostname + ":7681";
|
||||
</script>
|
||||
<%+footer%>
|
Loading…
Reference in New Issue
Block a user