Friday, June 29, 2012

Linux Resource Utilization Check

The script below will provide rough resource utilization numbers. The script checks memory and CPU utilization. The only parameter to this script is the sleep time between the consecutive checks.

#!/bin/sh

if [ $# -lt 1 ]
then
  waitinterval=1
else
  waitinterval=$1
fi

i=0

while [[ $i -lt 10000 ]]
do

 free -m
 mpstat

 sleep ${waitinterval}
 i=$((i+1))
done