diff options
author | Patrick Spek <p.spek@tyil.nl> | 2023-05-21 22:28:53 +0200 |
---|---|---|
committer | Patrick Spek <p.spek@tyil.nl> | 2023-05-21 22:28:53 +0200 |
commit | d4d5b9ad340873765b5ad969598669c9330350d6 (patch) | |
tree | 827f67937cc5e45b3252c9518a30f60af71524a6 /lib | |
parent | c4ae7e5b74b94a7f57fe36031642ae4960163205 (diff) |
Make the load a more uniform format
Diffstat (limited to 'lib')
-rw-r--r-- | lib/subcommands/sysinfo.bash | 6 |
1 files changed, 5 insertions, 1 deletions
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" |