How to get cpu/memory usage from command line output
If you are looking to capture the total utilized CPU and Memory for all process, you could use this command that is native to Macs:

ps -A -o %cpu,%mem | awk '{ cpu += $1; mem += $2} END {print cpu , mem}'