update 2022-06-18 20:17:19

This commit is contained in:
github-actions[bot] 2022-06-18 20:17:19 +08:00
parent 3f2da59989
commit c2f6fb0d7d
9 changed files with 545 additions and 18 deletions

View File

@ -147,7 +147,7 @@ local system_version = require "luci.model.cbi.gpsysupgrade.sysupgrade".get_syst
} }
if (kopkg.checked){ if (kopkg.checked){
opts = "-k -u"; opts = "-k";
} }
if (!kconfig.checked && kopkg.checked){ if (!kconfig.checked && kopkg.checked){
opts = "-n -k"; opts = "-n -k";

View File

@ -55,6 +55,7 @@ local OPKG_OPT="${1:-${OPKG_UCI}}"
local OPKG_WR="$(opkg export wr)" local OPKG_WR="$(opkg export wr)"
local OPKG_WI="$(opkg export wi)" local OPKG_WI="$(opkg export wi)"
local OPKG_UR="$(opkg export ur)" local OPKG_UR="$(opkg export ur)"
local OPKG_CM="$(opkg export cm)"
local OPKG_UI="$(opkg export ui)" local OPKG_UI="$(opkg export ui)"
if uci -q get fstab.rwm > /dev/null \ if uci -q get fstab.rwm > /dev/null \
&& grep -q -e "\s/rwm\s" /etc/mtab && grep -q -e "\s/rwm\s" /etc/mtab
@ -65,7 +66,9 @@ sed -e "s/$/\tipkg/" "${OPKG_WI}"
fi fi
{ {
sed -e "s/$/\trpkg/" "${OPKG_UR}" sed -e "s/$/\trpkg/" "${OPKG_UR}"
sed -e "s/$/\trpkg/" "${OPKG_CM}" | grep "^-"
sed -e "s/$/\tipkg/" "${OPKG_UI}" sed -e "s/$/\tipkg/" "${OPKG_UI}"
sed -e "s/$/\tipkg/" "${OPKG_CM}" | grep "^[^-]"
} | opkg uci "${OPKG_OPT}" } | opkg uci "${OPKG_OPT}"
rm -f "${OPKG_WR}" "${OPKG_WI}" "${OPKG_UR}" "${OPKG_UI}" rm -f "${OPKG_WR}" "${OPKG_WI}" "${OPKG_UR}" "${OPKG_UI}"
} }
@ -131,7 +134,7 @@ case "${OPKG_OPT}" in
(ai|au) opkg_"${OPKG_CMD}"_cmd ;; (ai|au) opkg_"${OPKG_CMD}"_cmd ;;
(ri|wr|wi|or|oi) opkg_"${OPKG_CMD}"_type ;; (ri|wr|wi|or|oi) opkg_"${OPKG_CMD}"_type ;;
(ur|ui) opkg_"${OPKG_CMD}"_run ;; (ur|ui) opkg_"${OPKG_CMD}"_run ;;
(pr|pi|ig) opkg_"${OPKG_CMD}"_uci ;; (pr|pi|ig|cm) opkg_"${OPKG_CMD}"_uci ;;
esac > "${OPKG_TEMP}" esac > "${OPKG_TEMP}"
echo "${OPKG_TEMP}" echo "${OPKG_TEMP}"
} }
@ -178,6 +181,7 @@ case "${OPKG_OPT:1}" in
(r) OPKG_TYPE="rpkg"; OPKG_CONF="auto" ;; (r) OPKG_TYPE="rpkg"; OPKG_CONF="auto" ;;
(i) OPKG_TYPE="ipkg"; OPKG_CONF="auto" ;; (i) OPKG_TYPE="ipkg"; OPKG_CONF="auto" ;;
(g) OPKG_TYPE="ipkg"; OPKG_CONF="ignore" ;; (g) OPKG_TYPE="ipkg"; OPKG_CONF="ignore" ;;
(m) OPKG_TYPE="ipkg"; OPKG_CONF="custom" ;;
esac esac
uci -q get opkg."${OPKG_CONF}"."${OPKG_TYPE}" \ uci -q get opkg."${OPKG_CONF}"."${OPKG_TYPE}" \
| sed -e "s/\s/\n/g" | sed -e "s/\s/\n/g"

View File

@ -1,7 +1,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
PKG_NAME:=luci-app-xray PKG_NAME:=luci-app-xray
PKG_VERSION:=1.14.0 PKG_VERSION:=1.14.1
PKG_RELEASE:=1 PKG_RELEASE:=1
PKG_LICENSE:=MPLv2 PKG_LICENSE:=MPLv2
@ -15,7 +15,7 @@ define Package/$(PKG_NAME)
SECTION:=Custom SECTION:=Custom
CATEGORY:=Extra packages CATEGORY:=Extra packages
TITLE:=LuCI Support for Xray TITLE:=LuCI Support for Xray
DEPENDS:=+luci-base +xray-core +dnsmasq +ca-bundle +PACKAGE_firewall4:kmod-nft-tproxy +PACKAGE_firewall3:ipset +PACKAGE_firewall3:iptables +PACKAGE_firewall3:iptables-mod-tproxy DEPENDS:=+luci-base +xray-core +dnsmasq +ca-bundle +PACKAGE_firewall4:kmod-nft-tproxy +PACKAGE_firewall:ipset +PACKAGE_firewall:iptables +PACKAGE_firewall:iptables-mod-tproxy
PKGARCH:=all PKGARCH:=all
endef endef

View File

@ -12,6 +12,7 @@ PKG_VERSION:=1
PKG_RELEASE:=7 PKG_RELEASE:=7
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
include $(INCLUDE_DIR)/target.mk
define Package/my-autocore-arm define Package/my-autocore-arm
SECTION:=libs SECTION:=libs
@ -52,7 +53,7 @@ endef
define Build/Compile define Build/Compile
endef endef
define Package/my-autocore-arm/install define Package/autocore/install/Default
$(INSTALL_DIR) $(1)/sbin $(INSTALL_DIR) $(1)/sbin
$(INSTALL_BIN) $(DL_DIR)/cpuinfo $(1)/sbin/cpuinfo $(INSTALL_BIN) $(DL_DIR)/cpuinfo $(1)/sbin/cpuinfo
$(INSTALL_BIN) ./files/common/ethinfo $(1)/sbin/ethinfo $(INSTALL_BIN) ./files/common/ethinfo $(1)/sbin/ethinfo
@ -62,18 +63,21 @@ define Package/my-autocore-arm/install
$(INSTALL_DATA) ./files/common/disc_status.htm $(1)/usr/lib/lua/luci/view/admin_status/index/ $(INSTALL_DATA) ./files/common/disc_status.htm $(1)/usr/lib/lua/luci/view/admin_status/index/
endef endef
define Package/my-autocore-arm/install
$(call Package/autocore/install/Default,$(1))
ifneq ($(filter ipq% %mt7622, $(TARGETID)),)
$(INSTALL_BIN) ./files/arm/tempinfo $(1)/sbin/
endif
endef
define Package/my-autocore-x86/install define Package/my-autocore-x86/install
$(call Package/autocore/install/Default,$(1))
$(INSTALL_DIR) $(1)/etc/init.d $(INSTALL_DIR) $(1)/etc/init.d
$(INSTALL_BIN) ./files/x86/autocore $(1)/etc/init.d/autocore $(INSTALL_BIN) ./files/x86/autocore $(1)/etc/init.d/autocore
$(INSTALL_DIR) $(1)/sbin
$(INSTALL_BIN) $(DL_DIR)/cpuinfo $(1)/sbin/cpuinfo
$(INSTALL_BIN) ./files/common/ethinfo $(1)/sbin/ethinfo
$(INSTALL_DIR) $(1)/www/luci-static/resources/view/status/include
$(INSTALL_DATA) ./files/common/29_eth.js $(1)/www/luci-static/resources/view/status/include/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/admin_status/index/ $(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/admin_status/index/
$(INSTALL_DATA) ./files/x86/nvme_status.htm $(1)/usr/lib/lua/luci/view/admin_status/index/ $(INSTALL_DATA) ./files/x86/nvme_status.htm $(1)/usr/lib/lua/luci/view/admin_status/index/
$(INSTALL_DIR) $(1)/usr/lib/lua/luci/view/admin_status/index
$(INSTALL_DATA) ./files/common/disc_status.htm $(1)/usr/lib/lua/luci/view/admin_status/index/
endef endef
$(eval $(call Download,cpuinfo)) $(eval $(call Download,cpuinfo))

View File

@ -0,0 +1,18 @@
#!/bin/sh
IEEE_PATH="/sys/class/ieee80211"
THERMAL_PATH="/sys/class/thermal"
wifi_temp1="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/hwmon*/temp1_input | awk '$1=$1')"
wifi_temp2="$(awk '{printf("%.1f°C ", $0 / 1000)}' "$IEEE_PATH"/phy*/device/hwmon/hwmon*/temp1_input | awk '$1=$1')"
NSS_LOAD="$(awk '{print$1}' "$DRV"/stats/cpu_load_ubi | awk '$1=$1' | tail -n 1)"
if grep -q "ipq40xx" "/etc/openwrt_release"; then
if [ -e "$IEEE_PATH/phy0/hwmon0/temp1_input" ]; then
mt76_temp=" $(awk -F ': ' '{print $2}' "$IEEE_PATH/phy0/hwmon0/temp1_input")°C"
fi
echo -n "WiFi:${mt76_temp} ${wifi_temp}"
else
cpu_temp="$(awk '{printf("%.1f°C", $0 / 1000)}' "$THERMAL_PATH/thermal_zone0/temp")"
echo -n "CPU: ${cpu_temp}, WiFi: ${wifi_temp1} ${wifi_temp2}"
fi

View File

@ -1,5 +0,0 @@
#!/bin/sh
MHz=`grep 'MHz' /proc/cpuinfo | cut -c11- |sed -n '1p'`
TEMP=`sensors 2>/dev/null | grep 'Core 0' | cut -c12-`
echo "$MHz MHz $TEMP "

View File

@ -115,7 +115,7 @@ echo "" # fixed newline
display "系统存储" "$root_usage" "90" "1" "%" " of $root_total" display "系统存储" "$root_usage" "90" "1" "%" " of $root_total"
if [ -x /sbin/cpuinfo ]; then if [ -x /sbin/cpuinfo ]; then
printf "CPU 信息: \x1B[92m%s\x1B[0m\t" "$(echo `/sbin/cpuinfo | cut -d ' ' -f -3`)" printf "CPU 信息: \x1B[92m%s\x1B[0m\t" "$(echo `/sbin/cpuinfo | cut -d ' ' -f -4`)"
fi fi
echo "" echo ""
echo "" echo ""

View File

@ -0,0 +1,278 @@
<% 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 .. "&deg;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">
<h3><%:Disks%></h3>
<table class="cbi-section-table" style="white-space: nowrap">
<tr>
<th width="5%">&nbsp;</th>
<th width="30%"><%:Model%></th>
<th width="15%"><%:Serial number%></th>
<th width="10%"><%:Firmware%></th>
<th width="10%"><%:Capacity%></th>
<th width="5%"><%:Sector size%></th>
<th width="5%"><%:Temperature%></th>
<th width="20%"><%: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: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">
<h3><%:Raid arrays%></h3>
<table class="cbi-section-table" style="white-space:nowrap">
<tr>
<th width="5%">&nbsp;</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 %>

View File

@ -0,0 +1,228 @@
<% local raid = {}
local devs = {}
local devinfo = {}
local colors = { "c0c0ff", "fbbd00", "e97c30", "a0e0a0", "b2c005", "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/nvme/*/device/nvme/*") do
local section
local model = nixio.fs.readfile(dev .. "/model")
local fw = nixio.fs.readfile(dev .. "/firmware_rev")
for bdev in nixio.fs.glob(dev .. "/nvme*") 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 -d nvme -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 == "Serial Number" then
serial = val
elseif attrib == "194" then
temp = val .. "&deg;C"
end
end
table.insert(devinfo, {name=name, model=model, fw=fw, size=size, serial=serial, parts=get_parts(name,status,size) })
end
end
end
if show_raid == 1 and #devinfo > 0 then %>
<div class="cbi-section">
<h3><%:NVMe SSD%></h3>
<table class="cbi-section-table" style="white-space: nowrap">
<tr>
<th width="5%">&nbsp;</th>
<th width="30%"><%:Model%></th>
<th width="25%"><%:Serial number%></th>
<th width="20%"><%:Firmware%></th>
<th width="20%"><%:Capacity%></th>
<!-- <th width="10%"><%:Temperature%></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.temp%></td>-->
</tr>
<tr style="height:0px" />
<tr class="cbi-section-table-row cbi-rowstyle-<%=(style and 1 or 2)%>">
<td style="padding: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 %>