summaryrefslogtreecommitdiff
path: root/bin/st-mem
diff options
context:
space:
mode:
Diffstat (limited to 'bin/st-mem')
-rwxr-xr-xbin/st-mem18
1 files changed, 18 insertions, 0 deletions
diff --git a/bin/st-mem b/bin/st-mem
new file mode 100755
index 0000000..8e0a7df
--- /dev/null
+++ b/bin/st-mem
@@ -0,0 +1,18 @@
+#!/bin/sh
+MEMORY_USED=$(free -h | awk 'NR==2 {print $3}')
+
+# freebsd (and maybe better for linux too)
+#PAGES_WIRED=$(sysctl vm.stats.vm.v_wire_count | awk '{print $2}')
+#PAGES_ACTIVE=$(sysctl vm.stats.vm.v_active_count | awk '{print $2}')
+#PAGES_DIRTY=$(sysctl vm.stats.vm.v_laundry_count | awk '{print $2}')
+#TOTAL_PAGES=$(echo "scale=0; $PAGES_WIRED+$PAGES_ACTIVE+$PAGES_DIRTY" | bc)
+#
+#BYTES_USED=$(echo "scale=0; $TOTAL_PAGES*4096" | bc)
+#
+#if [ $BYTES_USED -ge 1073741824 ]; then
+# MEMORY_USED="$(echo "scale=1; $BYTES_USED/1024^3" | bc) GiB"
+#else
+# MEMORY_USED="$(echo "scale=1; $BYTES_USED/1024^2" | bc) MiB"
+#fi
+
+echo $MEMORY_USED