diff options
| author | pants <niklasjo2004@gmail.com> | 2026-09-21 14:17:03 -0700 |
|---|---|---|
| committer | pants <niklasjo2004@gmail.com> | 2026-09-21 14:17:03 -0700 |
| commit | 7b21727285e50b0b050c4ddd70d07542229c5366 (patch) | |
| tree | 5d369153c5df5b41f3750d25479a68f20169c8ff /bin/st-mem | |
init
Diffstat (limited to 'bin/st-mem')
| -rwxr-xr-x | bin/st-mem | 18 |
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 |
