🌴 Sync 2026-10-28 19:48:41

This commit is contained in:
github-actions[bot] committed 2026-10-28 19:48:41 +08:00
1 parent 6777dc608e
commit edb4912e45
8 files changed
+116 -37

No files matched your search

+1 -1
View File
@@ -10,7 +10,7 @@ include $(INCLUDE_DIR)/kernel.mk
PKG_NAME:=my-default-settings
PKG_VERSION:=2
PKG_RELEASE:=37
PKG_RELEASE:=38
include $(INCLUDE_DIR)/package.mk
@@ -57,7 +57,7 @@ function get_ip_addresses()
function storage_info()
{
# storage info
RootInfo=$(df -h /)
RootInfo=$(df -P -h /)
root_usage=$(awk '/\// {print $(NF-1)}' <<<${RootInfo} | sed 's/%//g')
root_total=$(awk '/\// {print $(NF-4)}' <<<${RootInfo})
} # storage_info
@@ -68,32 +68,31 @@ function storage_info()
storage_info
critical_load=$(( 1 + $(grep -c processor /proc/cpuinfo) / 2 ))
# get uptime, logged in users and load in one take
UptimeString=$(uptime | tr -d ',')
time=$(awk -F" " '{print $3" "$4}' <<<"${UptimeString}")
load="$(awk -F"average: " '{print $2}'<<<"${UptimeString}")"
case ${time} in
1:*) # 1-2 hours
time=$(awk -F" " '{print $3" 小时"}' <<<"${UptimeString}")
;;
*:*) # 2-24 hours
time=$(awk -F" " '{print $3" 小时"}' <<<"${UptimeString}")
;;
*day) # days
days=$(awk -F" " '{print $3"天"}' <<<"${UptimeString}")
time=$(awk -F" " '{print $5}' <<<"${UptimeString}")
time="$days "$(awk -F":" '{print $1"小时 "$2"分钟"}' <<<"${time}")
;;
esac
# uptime and load: read /proc directly - in LXC/LXCFS containers the
# uptime/free commands are syscall-based and would show the host values.
_secs=$(cut -d. -f1 /proc/uptime 2>/dev/null)
case "$_secs" in *[!0-9]*|"") _secs=0 ;; esac
_ud=$(( _secs / 86400 )); _uh=$(( _secs % 86400 / 3600 )); _um=$(( _secs % 3600 / 60 ))
if [ "$_ud" -gt 0 ]; then
time="${_ud}天 $(printf '%02d:%02d' "$_uh" "$_um")"
else
time="$(printf '%02d:%02d' "$_uh" "$_um")"
fi
load="$(awk '{print $1" "$2" "$3}' /proc/loadavg 2>/dev/null)"
[ -n "$load" ] || load="0.00 0.00 0.00"
# memory and swap
mem_info=$(LC_ALL=C free -w 2>/dev/null | grep "^Mem" || LC_ALL=C free | grep "^Mem")
memory_usage=$(awk '{printf("%.0f",(($2-($4+$6))/$2) * 100)}' <<<${mem_info})
memory_total=$(awk '{printf("%d",$2/1024)}' <<<${mem_info})
swap_info=$(LC_ALL=C free -m | grep "^Swap")
swap_usage=$( (awk '/Swap/ { printf("%3.0f", $3/$2*100) }' <<<${swap_info} 2>/dev/null || echo 0) | tr -c -d '[:digit:]')
swap_total=$(awk '{print $(2)}' <<<${swap_info})
# memory and swap: read /proc/meminfo directly (same reason as above)
_mt=$(awk '/^MemTotal:/{print $2}' /proc/meminfo)
_mf=$(awk '/^MemFree:/{print $2}' /proc/meminfo)
_mb=$(awk '/^Buffers:/{print $2}' /proc/meminfo)
_mc=$(awk '/^Cached:/{print $2}' /proc/meminfo)
_st=$(awk '/^SwapTotal:/{print $2}' /proc/meminfo)
_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
while [ ! -n "$(get_ip_addresses)" ];do
@@ -115,7 +114,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 -4`)"
printf "CPU 信息: \x1B[92m%s\x1B[0m\t" "$(echo `/sbin/cpuinfo | cut -d ' ' -f 1-7`)"
fi
echo ""
echo ""