shell scriptでメモリ使用率

#!/bin/bash

YMD=`date +"%Y/%m/%d %p %I:%M:%S"`

MEM_LOG="memory.log"

MEM_USED=`free | grep Mem | awk '{print($2-$3)/$2*100}'`
SWAP_USED=`free | grep Swap | awk '{print($3)/$2*100}'`

echo "$HOSTNAME memory is $MEM_USED %, date is $YMD" >> MEM_LOG
echo "$HOSTNAME swap is $SWAP_USED %, date is $YMD" >> MEM_LOG

vagrant memory is 86.4592 %, date is 2023/10/21 PM 07:25:24
vagrant swap is 4.532 %, date is 2023/10/21 PM 07:25:24