aboutsummaryrefslogtreecommitdiffstats
path: root/bin/get_mem
blob: 21cf04aaedb63b0d41be3bf5e0f3d39af928341b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#!/usr/bin/env bash
set -euo pipefail
IFS=$'\n\t'

mem_output=""

if [ "$(uname)" == "Darwin" ]; then
  mem_output=$(ps -A -o %mem | awk '{s+=$1} END {print s}')
else
  mem_output="$(free -m| grep "Mem:"| awk '{printf $3 "/" $2 " ("} {printf ("%1.3f", $3/$2)} {printf ")"}')"
fi

echo "$mem_output%"

exit 0