Dear Friends
You can use this script to view CPU usage, Memory Usage , Disk Usage.
This may be helpful during some performance testing or load testing.
Let me know, if you face any issue in executing this script.
[sanpoc@pwebspherebox:/jboss/poc]$ cat systemperformancecheck.sh
#! /bin/bash
echo "" >> /jboss/scripts/log/system_usage.out
echo "" >> /jboss/scripts/log/system_usage.out
echo `hostname` >> /jboss/scripts/log/system_usage.out
echo "" >> /jboss/scripts/log/system_usage.out
echo "" >> /jboss/scripts/log/system_usage.out
echo `date` >> /jboss/scripts/log/system_usage.out
echo "" >> /jboss/scripts/log/system_usage.out
echo "" >> /jboss/scripts/log/system_usage.out
printf "Date\t\tMemory\t\tDisk\t\tCPU\n" >> /jboss/scripts/log/system_usage.out
end=$((SECONDS+86400))
while [ $SECONDS -lt $end ]; do
MEMORY=$(free -m | awk 'NR==2{printf "%.2f%%\t\t", $3*100/$2 }')
DISK=$(df -h | awk '$NF=="/"{printf "%s\t\t", $5}')
CPU=$(top -bn1 | grep load | awk '{printf "%.2f%%\t\t\n", $(NF-2)}')
DATE=$(date "+%H:%M: ")
echo "$DATE$MEMORY$DISK$CPU" >> /jboss/scripts/log/system_usage.out
sleep 300
done
This Script will print output like :
No comments:
Post a Comment