A simple script for monitoring memory usage of process, as well as load avg. on Linux

Code below, outputting result with interval 2 seconds, and results can be handled by excel

#!/bin/sh

Interval=2

#Format: idle,runq-sz,ldavg-1,proc_VmSize,proc_VmRSS
echo "idle,runq-sz,ldavg-1,proc_VmSize,proc_VmRSS"
if [ ! -f /proc/$1/status ]; then
    echo "Please specify the correct pid of process as parameter!!!"
    exit
fi

while true; do
    CPU=`sar  -u -q $Interval 1 | grep -v Average | grep -v Linux | grep -v '^$' | \
        { read a && read b && read c && read d; echo "$b $d"; } | \
        awk '{print $9","$12","$14}'`
    MEM=`cat /proc/$1/status |grep -e VmSize -e VmRSS|awk {'print $2'}`
    VmSize=`echo $MEM | cut -d \  -f 1 | tr -d "\n"`
    VmRSS=`echo $MEM | cut -d \  -f 2 | tr -d "\n"`
    VMSize1=`expr $VmSize / 1024`
    VmRSS1=`expr $VmRSS / 1024`
    echo $CPU,$VMSize1,$VmRSS1
done