mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-04 02:23:56 +08:00
🌴 Sync 2026-10-28 19:48:41
This commit is contained in:
1 parent
6777dc608e
commit
edb4912e45
8 files changed
+116
-37
No files matched your search
+1
-1
@@ -7,7 +7,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
|
|
||||||
PKG_NAME:=autocore
|
PKG_NAME:=autocore
|
||||||
PKG_FLAGS:=nonshared
|
PKG_FLAGS:=nonshared
|
||||||
PKG_RELEASE:=2
|
PKG_RELEASE:=3
|
||||||
|
|
||||||
PKG_CONFIG_DEPENDS:= \
|
PKG_CONFIG_DEPENDS:= \
|
||||||
CONFIG_TARGET_bcm27xx \
|
CONFIG_TARGET_bcm27xx \
|
||||||
|
|||||||
+11
-1
@@ -11,7 +11,17 @@ cpu_arch="$(awk -F ': ' '/model name/ {print $2}' "$CPUINFO_PATH" | head -n1)"
|
|||||||
|
|
||||||
case "$DISTRIB_TARGET" in
|
case "$DISTRIB_TARGET" in
|
||||||
"x86"/*)
|
"x86"/*)
|
||||||
cpu_cores="$(grep "core id" "$CPUINFO_PATH" | sort -u | wc -l)C $(grep -c "processor" "$CPUINFO_PATH")T" ;;
|
procs="$(grep -c "processor" "$CPUINFO_PATH")"
|
||||||
|
sibs="$(awk -F ': *' '/^siblings/ {print $2; exit}' "$CPUINFO_PATH")"
|
||||||
|
case "$sibs" in ''|*[!0-9]*) sibs="" ;; esac
|
||||||
|
if [ -n "$sibs" ] && [ "$procs" -lt "$sibs" ]; then
|
||||||
|
# Partial CPU view (e.g. LXC container): host core ids leak
|
||||||
|
# through /proc/cpuinfo and can repeat - count the assigned
|
||||||
|
# CPUs as cores/threads
|
||||||
|
cpu_cores="${procs}C ${procs}T"
|
||||||
|
else
|
||||||
|
cpu_cores="$(grep "core id" "$CPUINFO_PATH" | sort -u | wc -l)C ${procs}T"
|
||||||
|
fi ;;
|
||||||
*)
|
*)
|
||||||
cpu_cores="$(grep -c "processor" "$CPUINFO_PATH")" ;;
|
cpu_cores="$(grep -c "processor" "$CPUINFO_PATH")" ;;
|
||||||
esac
|
esac
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
|
|
||||||
PKG_NAME:=luci-app-netstat
|
PKG_NAME:=luci-app-netstat
|
||||||
PKG_VERSION:=1.1.5
|
PKG_VERSION:=1.1.5
|
||||||
PKG_RELEASE:=4
|
PKG_RELEASE:=5
|
||||||
|
|
||||||
PKG_MAINTAINER:=NoobLK <liyanagelsofficial@gmail.com>
|
PKG_MAINTAINER:=NoobLK <liyanagelsofficial@gmail.com>
|
||||||
PKG_LICENSE:=GPL-3.0
|
PKG_LICENSE:=GPL-3.0
|
||||||
|
|||||||
@@ -199,7 +199,9 @@ function getNetdevStats()
|
|||||||
|
|
||||||
-- ── Disk space (root filesystem) ──────────────────────────────────────────
|
-- ── Disk space (root filesystem) ──────────────────────────────────────────
|
||||||
local disk_pct, disk_used_mb, disk_total_mb = 0, 0, 0
|
local disk_pct, disk_used_mb, disk_total_mb = 0, 0, 0
|
||||||
local df = read_cmd("df -k / 2>/dev/null | awk 'NR==2{print $2,$3}'")
|
-- Use POSIX output (-P): busybox df wraps long device names onto a second
|
||||||
|
-- line without it, which breaks the NR==2 parse (e.g. LXC root device).
|
||||||
|
local df = read_cmd("df -kP / 2>/dev/null | awk 'NR==2{print $2,$3}'")
|
||||||
if df then
|
if df then
|
||||||
local dtotal, dused = df:match("^(%d+)%s+(%d+)$")
|
local dtotal, dused = df:match("^(%d+)%s+(%d+)$")
|
||||||
dtotal = tonumber(dtotal) or 0
|
dtotal = tonumber(dtotal) or 0
|
||||||
@@ -213,9 +215,42 @@ function getNetdevStats()
|
|||||||
|
|
||||||
-- ── CPU temperature ───────────────────────────────────────────────────────
|
-- ── CPU temperature ───────────────────────────────────────────────────────
|
||||||
local cpu_temp = nil
|
local cpu_temp = nil
|
||||||
-- Scan all available thermal zones and pick the highest valid reading
|
|
||||||
-- (avoids hardcoded zone numbers which vary per device)
|
-- Preferred source: CPU-specific hwmon sensors (k10temp/coretemp/zenpower/
|
||||||
|
-- ...). ACPI thermal zones can be absent or bogus (e.g. inside LXC
|
||||||
|
-- containers the host ACPI zone is not the CPU sensor), while hwmon
|
||||||
|
-- reports the real package temperature on x86.
|
||||||
|
local cpu_hwmon = { k10temp = true, coretemp = true, zenpower = true, cpu_thermal = true, soc_thermal = true }
|
||||||
|
if nixio.fs.access("/sys/class/hwmon") then
|
||||||
|
for h in nixio.fs.dir("/sys/class/hwmon") do
|
||||||
|
local base = "/sys/class/hwmon/" .. h
|
||||||
|
local nf = io.open(base .. "/name", "r")
|
||||||
|
local name = nf and nf:read("*l") or nil
|
||||||
|
if nf then nf:close() end
|
||||||
|
if name and cpu_hwmon[name] then
|
||||||
|
for entry in nixio.fs.dir(base) do
|
||||||
|
if entry:match("^temp%d+_input$") then
|
||||||
|
local sf = io.open(base .. "/" .. entry, "r")
|
||||||
|
local val = sf and sf:read("*l") or nil
|
||||||
|
if sf then sf:close() end
|
||||||
|
local t = tonumber(val)
|
||||||
|
if t and t > 0 then
|
||||||
|
if t > 1000 then t = t / 1000 end
|
||||||
|
t = math.floor(t + 0.5)
|
||||||
|
if cpu_temp == nil or t > cpu_temp then
|
||||||
|
cpu_temp = t
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Fallback: scan all available thermal zones and pick the highest valid
|
||||||
|
-- reading (avoids hardcoded zone numbers which vary per device)
|
||||||
for zone = 0, 9 do
|
for zone = 0, 9 do
|
||||||
|
if cpu_temp ~= nil then break end
|
||||||
local path = "/sys/class/thermal/thermal_zone" .. zone .. "/temp"
|
local path = "/sys/class/thermal/thermal_zone" .. zone .. "/temp"
|
||||||
local tf = io.open(path, "r")
|
local tf = io.open(path, "r")
|
||||||
if tf then
|
if tf then
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ include $(TOPDIR)/rules.mk
|
|||||||
LUCI_TITLE:=LuCI Status Pages
|
LUCI_TITLE:=LuCI Status Pages
|
||||||
LUCI_DEPENDS:=+luci-base +luci-app-oui +luci-mod-dashboard +libiwinfo +rpcd-mod-iwinfo +rpcd-mod-rrdns +ucode +ucode-mod-fs +ucode-mod-ubus +ucode-mod-socket
|
LUCI_DEPENDS:=+luci-base +luci-app-oui +luci-mod-dashboard +libiwinfo +rpcd-mod-iwinfo +rpcd-mod-rrdns +ucode +ucode-mod-fs +ucode-mod-ubus +ucode-mod-socket
|
||||||
|
|
||||||
PKG_RELEASE:=36
|
PKG_RELEASE:=37
|
||||||
PKG_BUILD_DEPENDS:=iwinfo
|
PKG_BUILD_DEPENDS:=iwinfo
|
||||||
PKG_LICENSE:=Apache-2.0
|
PKG_LICENSE:=Apache-2.0
|
||||||
|
|
||||||
|
|||||||
@@ -196,7 +196,9 @@ function getNetdevStats()
|
|||||||
|
|
||||||
-- ── Disk space (root filesystem) ──────────────────────────────────────────
|
-- ── Disk space (root filesystem) ──────────────────────────────────────────
|
||||||
local disk_pct, disk_used_mb, disk_total_mb = 0, 0, 0
|
local disk_pct, disk_used_mb, disk_total_mb = 0, 0, 0
|
||||||
local df = read_cmd("df -k / 2>/dev/null | awk 'NR==2{print $2,$3}'")
|
-- Use POSIX output (-P): busybox df wraps long device names onto a second
|
||||||
|
-- line without it, which breaks the NR==2 parse (e.g. LXC root device).
|
||||||
|
local df = read_cmd("df -kP / 2>/dev/null | awk 'NR==2{print $2,$3}'")
|
||||||
if df then
|
if df then
|
||||||
local dtotal, dused = df:match("^(%d+)%s+(%d+)$")
|
local dtotal, dused = df:match("^(%d+)%s+(%d+)$")
|
||||||
dtotal = tonumber(dtotal) or 0
|
dtotal = tonumber(dtotal) or 0
|
||||||
@@ -210,9 +212,42 @@ function getNetdevStats()
|
|||||||
|
|
||||||
-- ── CPU temperature ───────────────────────────────────────────────────────
|
-- ── CPU temperature ───────────────────────────────────────────────────────
|
||||||
local cpu_temp = nil
|
local cpu_temp = nil
|
||||||
-- Scan all available thermal zones and pick the highest valid reading
|
|
||||||
-- (avoids hardcoded zone numbers which vary per device)
|
-- Preferred source: CPU-specific hwmon sensors (k10temp/coretemp/zenpower/
|
||||||
|
-- ...). ACPI thermal zones can be absent or bogus (e.g. inside LXC
|
||||||
|
-- containers the host ACPI zone is not the CPU sensor), while hwmon
|
||||||
|
-- reports the real package temperature on x86.
|
||||||
|
local cpu_hwmon = { k10temp = true, coretemp = true, zenpower = true, cpu_thermal = true, soc_thermal = true }
|
||||||
|
if nixio.fs.access("/sys/class/hwmon") then
|
||||||
|
for h in nixio.fs.dir("/sys/class/hwmon") do
|
||||||
|
local base = "/sys/class/hwmon/" .. h
|
||||||
|
local nf = io.open(base .. "/name", "r")
|
||||||
|
local name = nf and nf:read("*l") or nil
|
||||||
|
if nf then nf:close() end
|
||||||
|
if name and cpu_hwmon[name] then
|
||||||
|
for entry in nixio.fs.dir(base) do
|
||||||
|
if entry:match("^temp%d+_input$") then
|
||||||
|
local sf = io.open(base .. "/" .. entry, "r")
|
||||||
|
local val = sf and sf:read("*l") or nil
|
||||||
|
if sf then sf:close() end
|
||||||
|
local t = tonumber(val)
|
||||||
|
if t and t > 0 then
|
||||||
|
if t > 1000 then t = t / 1000 end
|
||||||
|
t = math.floor(t + 0.5)
|
||||||
|
if cpu_temp == nil or t > cpu_temp then
|
||||||
|
cpu_temp = t
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Fallback: scan all available thermal zones and pick the highest valid
|
||||||
|
-- reading (avoids hardcoded zone numbers which vary per device)
|
||||||
for zone = 0, 9 do
|
for zone = 0, 9 do
|
||||||
|
if cpu_temp ~= nil then break end
|
||||||
local path = "/sys/class/thermal/thermal_zone" .. zone .. "/temp"
|
local path = "/sys/class/thermal/thermal_zone" .. zone .. "/temp"
|
||||||
local tf = io.open(path, "r")
|
local tf = io.open(path, "r")
|
||||||
if tf then
|
if tf then
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk
|
|||||||
|
|
||||||
PKG_NAME:=my-default-settings
|
PKG_NAME:=my-default-settings
|
||||||
PKG_VERSION:=2
|
PKG_VERSION:=2
|
||||||
PKG_RELEASE:=37
|
PKG_RELEASE:=38
|
||||||
|
|
||||||
include $(INCLUDE_DIR)/package.mk
|
include $(INCLUDE_DIR)/package.mk
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ function get_ip_addresses()
|
|||||||
function storage_info()
|
function storage_info()
|
||||||
{
|
{
|
||||||
# storage info
|
# storage info
|
||||||
RootInfo=$(df -h /)
|
RootInfo=$(df -P -h /)
|
||||||
root_usage=$(awk '/\// {print $(NF-1)}' <<<${RootInfo} | sed 's/%//g')
|
root_usage=$(awk '/\// {print $(NF-1)}' <<<${RootInfo} | sed 's/%//g')
|
||||||
root_total=$(awk '/\// {print $(NF-4)}' <<<${RootInfo})
|
root_total=$(awk '/\// {print $(NF-4)}' <<<${RootInfo})
|
||||||
} # storage_info
|
} # storage_info
|
||||||
@@ -68,32 +68,31 @@ function storage_info()
|
|||||||
storage_info
|
storage_info
|
||||||
critical_load=$(( 1 + $(grep -c processor /proc/cpuinfo) / 2 ))
|
critical_load=$(( 1 + $(grep -c processor /proc/cpuinfo) / 2 ))
|
||||||
|
|
||||||
# get uptime, logged in users and load in one take
|
# uptime and load: read /proc directly - in LXC/LXCFS containers the
|
||||||
UptimeString=$(uptime | tr -d ',')
|
# uptime/free commands are syscall-based and would show the host values.
|
||||||
time=$(awk -F" " '{print $3" "$4}' <<<"${UptimeString}")
|
_secs=$(cut -d. -f1 /proc/uptime 2>/dev/null)
|
||||||
load="$(awk -F"average: " '{print $2}'<<<"${UptimeString}")"
|
case "$_secs" in *[!0-9]*|"") _secs=0 ;; esac
|
||||||
case ${time} in
|
_ud=$(( _secs / 86400 )); _uh=$(( _secs % 86400 / 3600 )); _um=$(( _secs % 3600 / 60 ))
|
||||||
1:*) # 1-2 hours
|
if [ "$_ud" -gt 0 ]; then
|
||||||
time=$(awk -F" " '{print $3" 小时"}' <<<"${UptimeString}")
|
time="${_ud}天 $(printf '%02d:%02d' "$_uh" "$_um")"
|
||||||
;;
|
else
|
||||||
*:*) # 2-24 hours
|
time="$(printf '%02d:%02d' "$_uh" "$_um")"
|
||||||
time=$(awk -F" " '{print $3" 小时"}' <<<"${UptimeString}")
|
fi
|
||||||
;;
|
load="$(awk '{print $1" "$2" "$3}' /proc/loadavg 2>/dev/null)"
|
||||||
*day) # days
|
[ -n "$load" ] || load="0.00 0.00 0.00"
|
||||||
days=$(awk -F" " '{print $3"天"}' <<<"${UptimeString}")
|
|
||||||
time=$(awk -F" " '{print $5}' <<<"${UptimeString}")
|
|
||||||
time="$days "$(awk -F":" '{print $1"小时 "$2"分钟"}' <<<"${time}")
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
|
|
||||||
# memory and swap
|
# memory and swap: read /proc/meminfo directly (same reason as above)
|
||||||
mem_info=$(LC_ALL=C free -w 2>/dev/null | grep "^Mem" || LC_ALL=C free | grep "^Mem")
|
_mt=$(awk '/^MemTotal:/{print $2}' /proc/meminfo)
|
||||||
memory_usage=$(awk '{printf("%.0f",(($2-($4+$6))/$2) * 100)}' <<<${mem_info})
|
_mf=$(awk '/^MemFree:/{print $2}' /proc/meminfo)
|
||||||
memory_total=$(awk '{printf("%d",$2/1024)}' <<<${mem_info})
|
_mb=$(awk '/^Buffers:/{print $2}' /proc/meminfo)
|
||||||
swap_info=$(LC_ALL=C free -m | grep "^Swap")
|
_mc=$(awk '/^Cached:/{print $2}' /proc/meminfo)
|
||||||
swap_usage=$( (awk '/Swap/ { printf("%3.0f", $3/$2*100) }' <<<${swap_info} 2>/dev/null || echo 0) | tr -c -d '[:digit:]')
|
_st=$(awk '/^SwapTotal:/{print $2}' /proc/meminfo)
|
||||||
swap_total=$(awk '{print $(2)}' <<<${swap_info})
|
_sf=$(awk '/^SwapFree:/{print $2}' /proc/meminfo)
|
||||||
|
memory_usage=$(awk -v t="${_mt:-0}" -v f="${_mf:-0}" -v b="${_mb:-0}" -v c="${_mc:-0}" 'BEGIN{ if (t>0) printf "%.0f", (t-f-b-c)/t*100; else print 0 }')
|
||||||
|
memory_total=$(( ${_mt:-0} / 1024 ))
|
||||||
|
swap_usage=$(awk -v t="${_st:-0}" -v f="${_sf:-0}" 'BEGIN{ if (t>0) printf "%.0f", (t-f)/t*100; else print 0 }')
|
||||||
|
swap_total=$(( ${_st:-0} / 1024 ))
|
||||||
|
|
||||||
c=0
|
c=0
|
||||||
while [ ! -n "$(get_ip_addresses)" ];do
|
while [ ! -n "$(get_ip_addresses)" ];do
|
||||||
@@ -115,7 +114,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 -4`)"
|
printf "CPU 信息: \x1B[92m%s\x1B[0m\t" "$(echo `/sbin/cpuinfo | cut -d ' ' -f 1-7`)"
|
||||||
fi
|
fi
|
||||||
echo ""
|
echo ""
|
||||||
echo ""
|
echo ""
|
||||||
Reference in new issue
Block a user