From d4d5b9ad340873765b5ad969598669c9330350d6 Mon Sep 17 00:00:00 2001 From: Patrick Spek Date: Sun, 21 May 2023 22:28:53 +0200 Subject: Make the load a more uniform format --- lib/subcommands/sysinfo.bash | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/subcommands/sysinfo.bash b/lib/subcommands/sysinfo.bash index 2f44844..d54ca98 100644 --- a/lib/subcommands/sysinfo.bash +++ b/lib/subcommands/sysinfo.bash @@ -39,6 +39,7 @@ subcommand() { ;; esac + # For any value that isn't set, just default to 0 to avoid all sorts of errors [[ -z "$load_1" ]] && load_1=0 [[ -z "$load_5" ]] && load_1=0 [[ -z "$load_15" ]] && load_1=0 @@ -50,22 +51,25 @@ subcommand() { [[ -z "$storage_used" ]] && load_1=0 [[ -z "$uptime" ]] && load_1=0 + # Print the values that can be set by package maintainers printf "%-15s %s\n" "etcdir" "$BASHTARD_ETCDIR" printf "%-15s %s\n" "libdir" "$BASHTARD_LIBDIR" printf "%-15s %s\n" "sharedir" "$BASHTARD_SHAREDIR" + # Print all the discovered platform information for key in "${!BASHTARD_PLATFORM[@]}" do printf "%-15s %s\n" "$key" "${BASHTARD_PLATFORM[$key]}" done + # Print fun little extras printf "%-15s %dGi / %dGi\n" "memory" \ "$(( memory_used / 1024 / 1024 ))" \ "$(( memory_total / 1024 / 1024 ))" printf "%-15s %dGb / %dGb\n" "storage" \ "$(( storage_used / 1024 / 1024 ))" \ "$(( storage_total / 1024 / 1024 ))" - printf "%-15s %s %s %s\n" "load" \ + printf "%-15s %0.2f %0.2f %0.2f\n" "load" \ "$load_1" \ "$load_5" \ "$load_15" -- cgit v1.1