From c2f6fb0d7d4841c29b50441e291252581a736dc9 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Sat, 18 Jun 2022 20:17:19 +0800 Subject: [PATCH] update 2022-06-18 20:17:19 --- .../view/gpsysupgrade/system_version.htm | 2 +- .../root/etc/profile.d/opkg.sh | 6 +- luci-app-xray/Makefile | 4 +- my-autocore/Makefile | 20 +- my-autocore/files/arm/tempinfo | 18 ++ my-autocore/files/x86/cpuinfo | 5 - .../files/etc/profile.d/sysinfo.sh | 2 +- .../view/admin_status/index/disc_status.htm | 278 ++++++++++++++++++ .../view/admin_status/index/nvme_status.htm | 228 ++++++++++++++ 9 files changed, 545 insertions(+), 18 deletions(-) create mode 100644 my-autocore/files/arm/tempinfo delete mode 100644 my-autocore/files/x86/cpuinfo create mode 100644 my-default-settings/target/x86/base-files/usr/lib/lua/luci/view/admin_status/index/disc_status.htm create mode 100644 my-default-settings/target/x86/base-files/usr/lib/lua/luci/view/admin_status/index/nvme_status.htm diff --git a/luci-app-gpsysupgrade/luasrc/view/gpsysupgrade/system_version.htm b/luci-app-gpsysupgrade/luasrc/view/gpsysupgrade/system_version.htm index 76d142139..17ad441d9 100644 --- a/luci-app-gpsysupgrade/luasrc/view/gpsysupgrade/system_version.htm +++ b/luci-app-gpsysupgrade/luasrc/view/gpsysupgrade/system_version.htm @@ -147,7 +147,7 @@ local system_version = require "luci.model.cbi.gpsysupgrade.sysupgrade".get_syst } if (kopkg.checked){ - opts = "-k -u"; + opts = "-k"; } if (!kconfig.checked && kopkg.checked){ opts = "-n -k"; diff --git a/luci-app-gpsysupgrade/root/etc/profile.d/opkg.sh b/luci-app-gpsysupgrade/root/etc/profile.d/opkg.sh index c21a8b049..113b20f8a 100644 --- a/luci-app-gpsysupgrade/root/etc/profile.d/opkg.sh +++ b/luci-app-gpsysupgrade/root/etc/profile.d/opkg.sh @@ -55,6 +55,7 @@ local OPKG_OPT="${1:-${OPKG_UCI}}" local OPKG_WR="$(opkg export wr)" local OPKG_WI="$(opkg export wi)" local OPKG_UR="$(opkg export ur)" +local OPKG_CM="$(opkg export cm)" local OPKG_UI="$(opkg export ui)" if uci -q get fstab.rwm > /dev/null \ && grep -q -e "\s/rwm\s" /etc/mtab @@ -65,7 +66,9 @@ sed -e "s/$/\tipkg/" "${OPKG_WI}" fi { sed -e "s/$/\trpkg/" "${OPKG_UR}" +sed -e "s/$/\trpkg/" "${OPKG_CM}" | grep "^-" sed -e "s/$/\tipkg/" "${OPKG_UI}" +sed -e "s/$/\tipkg/" "${OPKG_CM}" | grep "^[^-]" } | opkg uci "${OPKG_OPT}" rm -f "${OPKG_WR}" "${OPKG_WI}" "${OPKG_UR}" "${OPKG_UI}" } @@ -131,7 +134,7 @@ case "${OPKG_OPT}" in (ai|au) opkg_"${OPKG_CMD}"_cmd ;; (ri|wr|wi|or|oi) opkg_"${OPKG_CMD}"_type ;; (ur|ui) opkg_"${OPKG_CMD}"_run ;; -(pr|pi|ig) opkg_"${OPKG_CMD}"_uci ;; +(pr|pi|ig|cm) opkg_"${OPKG_CMD}"_uci ;; esac > "${OPKG_TEMP}" echo "${OPKG_TEMP}" } @@ -178,6 +181,7 @@ case "${OPKG_OPT:1}" in (r) OPKG_TYPE="rpkg"; OPKG_CONF="auto" ;; (i) OPKG_TYPE="ipkg"; OPKG_CONF="auto" ;; (g) OPKG_TYPE="ipkg"; OPKG_CONF="ignore" ;; +(m) OPKG_TYPE="ipkg"; OPKG_CONF="custom" ;; esac uci -q get opkg."${OPKG_CONF}"."${OPKG_TYPE}" \ | sed -e "s/\s/\n/g" diff --git a/luci-app-xray/Makefile b/luci-app-xray/Makefile index e2884f118..6ca8b4216 100644 --- a/luci-app-xray/Makefile +++ b/luci-app-xray/Makefile @@ -1,7 +1,7 @@ include $(TOPDIR)/rules.mk PKG_NAME:=luci-app-xray -PKG_VERSION:=1.14.0 +PKG_VERSION:=1.14.1 PKG_RELEASE:=1 PKG_LICENSE:=MPLv2 @@ -15,7 +15,7 @@ define Package/$(PKG_NAME) SECTION:=Custom CATEGORY:=Extra packages 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 endef diff --git a/my-autocore/Makefile b/my-autocore/Makefile index ba3723231..8ca109ed9 100644 --- a/my-autocore/Makefile +++ b/my-autocore/Makefile @@ -12,6 +12,7 @@ PKG_VERSION:=1 PKG_RELEASE:=7 include $(INCLUDE_DIR)/package.mk +include $(INCLUDE_DIR)/target.mk define Package/my-autocore-arm SECTION:=libs @@ -52,7 +53,7 @@ endef define Build/Compile endef -define Package/my-autocore-arm/install +define Package/autocore/install/Default $(INSTALL_DIR) $(1)/sbin $(INSTALL_BIN) $(DL_DIR)/cpuinfo $(1)/sbin/cpuinfo $(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/ 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 + $(call Package/autocore/install/Default,$(1)) + $(INSTALL_DIR) $(1)/etc/init.d $(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_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 $(eval $(call Download,cpuinfo)) diff --git a/my-autocore/files/arm/tempinfo b/my-autocore/files/arm/tempinfo new file mode 100644 index 000000000..1c1c43fa5 --- /dev/null +++ b/my-autocore/files/arm/tempinfo @@ -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 diff --git a/my-autocore/files/x86/cpuinfo b/my-autocore/files/x86/cpuinfo deleted file mode 100644 index 8c0527f84..000000000 --- a/my-autocore/files/x86/cpuinfo +++ /dev/null @@ -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 " diff --git a/my-default-settings/files/etc/profile.d/sysinfo.sh b/my-default-settings/files/etc/profile.d/sysinfo.sh index abf0007a0..c9384c111 100644 --- a/my-default-settings/files/etc/profile.d/sysinfo.sh +++ b/my-default-settings/files/etc/profile.d/sysinfo.sh @@ -115,7 +115,7 @@ echo "" # fixed newline display "系统存储" "$root_usage" "90" "1" "%" " of $root_total" 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 echo "" echo "" diff --git a/my-default-settings/target/x86/base-files/usr/lib/lua/luci/view/admin_status/index/disc_status.htm b/my-default-settings/target/x86/base-files/usr/lib/lua/luci/view/admin_status/index/disc_status.htm new file mode 100644 index 000000000..8d106101b --- /dev/null +++ b/my-default-settings/target/x86/base-files/usr/lib/lua/luci/view/admin_status/index/disc_status.htm @@ -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 .. "°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 %> +
+

<%:Disks%>

+ + + + + + + + + + + +<% local style=true + for d,dev in ipairs(devinfo) do %> + + + + + + + + + + + + + + + +<% style = not style + end %> +
 <%:Model%><%:Serial number%><%:Firmware%><%:Capacity%><%:Sector size%><%:Temperature%><%:Power state%>
<%=dev.name%><%=dev.model%><%=dev.serial%><%=dev.fw%><%=disp_size(dev.size)%><%=dev.secsize%><%=dev.temp%><%=dev.status%>
+ + <% for _,part in pairs(dev.parts) do %> + + <% end %> +
<%=part.name%> <%=disp_size(part.size)%> <%=part.fs%>
+
+
+<% end + if show_raid == 1 and #raid > 0 then %> +
+

<%:Raid arrays%>

+ + + + + + + + + +<% local style=true + for r,dev in ipairs(raid) do %> + + + + + + + + + + + + + +<% style = not style + end %> +
 <%:Level%><%:# Disks%><%:Capacity%><%:Metadata%><%:Status%>
<%=dev.name%><%=dev.rlevel%><%=dev.ndisks%><%=disp_size(dev.size)%><%=dev.metav%><%=dev.status%>
+ + <% for _,member in pairs(dev.members) do %> + + <% end %> +
<%=member.name%> <%=member.size%> (<%=member.state%>)
+
+
+<% end %> diff --git a/my-default-settings/target/x86/base-files/usr/lib/lua/luci/view/admin_status/index/nvme_status.htm b/my-default-settings/target/x86/base-files/usr/lib/lua/luci/view/admin_status/index/nvme_status.htm new file mode 100644 index 000000000..a67b7deee --- /dev/null +++ b/my-default-settings/target/x86/base-files/usr/lib/lua/luci/view/admin_status/index/nvme_status.htm @@ -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 .. "°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 %> +
+

<%:NVMe SSD%>

+ + + + + + + + + +<% local style=true + for d,dev in ipairs(devinfo) do %> + + + + + + + + + + + + + +<% style = not style + end %> +
 <%:Model%><%:Serial number%><%:Firmware%><%:Capacity%>
<%=dev.name%><%=dev.model%><%=dev.serial%><%=dev.fw%><%=disp_size(dev.size)%>
+ + <% for _,part in pairs(dev.parts) do %> + + <% end %> +
<%=part.name%> <%=disp_size(part.size)%> <%=part.fs%>
+
+
+<% end %>