Improvements
This commit is contained in:
parent
be806706d6
commit
cb14fc26c4
3 changed files with 39 additions and 19 deletions
|
@ -23,6 +23,29 @@ function check_connection() {
|
|||
fi
|
||||
}
|
||||
|
||||
function format_uptime() {
|
||||
local uptime=$1
|
||||
local upDays=$((uptime / 60 / 60 / 24))
|
||||
local upHours=$((uptime / 60 / 60 % 24))
|
||||
local upMins=$((uptime / 60 % 60))
|
||||
local output=""
|
||||
if [ $upDays -gt 0 ]; then
|
||||
output="$output$upDays day"
|
||||
[ $upDays -gt 1 ] && output="${output}s"
|
||||
output="$output "
|
||||
fi
|
||||
if [ $upHours -gt 0 ]; then
|
||||
output="$output$upHours hour"
|
||||
[ $upHours -gt 1 ] && output="${output}s"
|
||||
output="$output "
|
||||
fi
|
||||
if [ $upMins -gt 0 ] || [ -z "$output" ]; then
|
||||
output="$output$upMins minute"
|
||||
[ $upMins -gt 1 ] && output="${output}s"
|
||||
fi
|
||||
echo "$output"
|
||||
}
|
||||
|
||||
function system_menu_ui() {
|
||||
memfree=`cat /proc/meminfo | grep MemFree | awk {'print $2'}`
|
||||
memtotal=`cat /proc/meminfo | grep MemTotal | awk {'print $2'}`
|
||||
|
@ -30,10 +53,8 @@ function system_menu_ui() {
|
|||
diskused=`df -h | grep /dev/mmcblk0p10 | awk {'print $3 " / " $2 " (" $4 " available)" '}`
|
||||
process=`ps ax | wc -l | tr -d " "`
|
||||
uptime=`cat /proc/uptime | cut -f1 -d.`
|
||||
upDays=$((uptime/60/60/24))
|
||||
upHours=$((uptime/60/60%24))
|
||||
upMins=$((uptime/60%60))
|
||||
load=`cat /proc/loadavg | awk {'print $1 " (1 min.) / " $2 " (5 min.) / " $3 " (15 min.)"'}`
|
||||
formatted_uptime=$(format_uptime $uptime)
|
||||
load=`awk -v cpus=2 '{printf "%.2f%% (1 min) | %.2f%% (5 min) | %.2f%% (15 min)\n", $1*100/cpus, $2*100/cpus, $3*100/cpus}' /proc/loadavg`
|
||||
device_sn=$(cat /usr/data/creality/userdata/config/system_config.json | grep -o '"device_sn":"[^"]*' | awk -F '"' '{print $4}')
|
||||
mac_address=$(cat /usr/data/creality/userdata/config/system_config.json | grep -o '"device_mac":"[^"]*' | awk -F '"' '{print $4}' | sed 's/../&:/g; s/:$//')
|
||||
top_line
|
||||
|
@ -46,11 +67,10 @@ function system_menu_ui() {
|
|||
system_line " Device SN" "$device_sn"
|
||||
system_line " IP Address" "$(check_connection)"
|
||||
system_line "MAC Address" "$mac_address"
|
||||
system_line " CPU Usage" "$load"
|
||||
system_line " RAM Usage" "$(($memfree/1024)) MB / $(($memtotal/1024)) MB ($pourcent% available)"
|
||||
system_line " Disk Usage" "$diskused"
|
||||
system_line " Uptime" "$upDays days $upHours hours $upMins minutes"
|
||||
system_line " Processes" "$process running process"
|
||||
system_line "System Load" "$load"
|
||||
system_line " Uptime" "$formatted_uptime"
|
||||
hr
|
||||
inner_line
|
||||
hr
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue