From 33824987fd7d8764288bcd1814ada49a16a68f15 Mon Sep 17 00:00:00 2001 From: David Runge Date: Mon, 23 Apr 2018 08:43:06 +0200 Subject: bin/get_mem: Make script support macOS (using ps). --- bin/get_mem | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'bin') diff --git a/bin/get_mem b/bin/get_mem index fc49561..21cf04a 100755 --- a/bin/get_mem +++ b/bin/get_mem @@ -4,8 +4,12 @@ IFS=$'\n\t' mem_output="" -mem_output="$(free -m| grep "Mem:"| awk '{printf $3 "/" $2 " ("} {printf ("%1.3f", $3/$2)} {printf ")"}')" +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 +echo "$mem_output%" +exit 0 -- cgit v1.2.3-54-g00ecf