aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Spek <p.spek@tyil.nl>2023-05-21 12:24:18 +0200
committerPatrick Spek <p.spek@tyil.nl>2023-05-21 12:25:49 +0200
commit371287c03445bb24d1243a89325bb11f20d51de1 (patch)
treefcd2265d7056f8a4135c200150201c8fdbe1e60d
parent3a84a21b063739b5586b4455d96a1e79cff93ad8 (diff)
Add more information to sysinfo
-rw-r--r--lib/subcommands/sysinfo.bash29
1 files changed, 29 insertions, 0 deletions
diff --git a/lib/subcommands/sysinfo.bash b/lib/subcommands/sysinfo.bash
index 8aa237e..f9f81ba 100644
--- a/lib/subcommands/sysinfo.bash
+++ b/lib/subcommands/sysinfo.bash
@@ -5,6 +5,22 @@
# SPDX-License-Identifier: AGPL-3.0-or-later
subcommand() {
+ local load_1
+ local load_5
+ local load_15
+ local memory_total
+ local memory_free
+ local memory_used
+ local uptime
+
+ load_1="$(awk '{ print $1 }' < /proc/loadavg)"
+ load_5="$(awk '{ print $2 }' < /proc/loadavg)"
+ load_15="$(awk '{ print $3 }' < /proc/loadavg)"
+ memory_total="$(awk '/MemTotal/ { print $2 }' < /proc/meminfo)"
+ memory_free="$(awk '/MemFree/ { print $2 }' < /proc/meminfo)"
+ memory_used=$(( memory_total - memory_free ))
+ uptime="$(awk -F. '{ print $1 }' < /proc/uptime)"
+
printf "%-15s %s\n" "etcdir" "$BASHTARD_ETCDIR"
printf "%-15s %s\n" "libdir" "$BASHTARD_LIBDIR"
printf "%-15s %s\n" "sharedir" "$BASHTARD_SHAREDIR"
@@ -13,4 +29,17 @@ subcommand() {
do
printf "%-15s %s\n" "$key" "${BASHTARD_PLATFORM[$key]}"
done
+
+ printf "%-15s %dd %02dh %02dm %02ds\n" "uptime" \
+ "$(( uptime / 60 / 60 / 24 ))" \
+ "$(( uptime / 60 / 60 % 24 ))" \
+ "$(( uptime / 60 % 60 ))" \
+ "$(( uptime % 60 ))"
+ printf "%-15s %dGi / %dGi\n" "memory" \
+ "$(( memory_used / 1024 / 1024 ))" \
+ "$(( memory_total / 1024 / 1024 ))"
+ printf "%-15s %s %s %s\n" "load" \
+ "$load_1" \
+ "$load_5" \
+ "$load_15"
}