2020-06-04 05:44:17 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
get_percent()
|
|
|
|
{
|
|
|
|
case $(uname -s) in
|
|
|
|
Linux)
|
|
|
|
percent=$(free -m | awk 'NR==2{printf "%.1f%%\n", $3*100/$2}')
|
|
|
|
echo $percent
|
|
|
|
;;
|
|
|
|
|
|
|
|
Darwin)
|
2020-06-04 06:33:47 +02:00
|
|
|
percent=$(ps -A -o %mem | awk '{mem += $1} END {print mem}')
|
|
|
|
echo $percent
|
2020-06-04 05:44:17 +02:00
|
|
|
;;
|
|
|
|
|
|
|
|
CYGWIN*|MINGW32*|MSYS*|MINGW*)
|
|
|
|
# TODO - windows compatability
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
}
|
|
|
|
|
|
|
|
main()
|
|
|
|
{
|
|
|
|
ram_percent=$(get_percent)
|
|
|
|
echo "RAM $ram_percent"
|
|
|
|
sleep 10
|
|
|
|
}
|
2020-06-04 06:33:47 +02:00
|
|
|
|
2020-06-04 05:44:17 +02:00
|
|
|
#run main driver
|
|
|
|
main
|