Académique Documents
Professionnel Documents
Culture Documents
1.
# File name : cpumem.sh
###########################################################################
# script for capturing CPU and Memory usuage over a period. 24 hours. #
# File Name: cpumem.sh By: Raj.D. #
# can be run throguh cron or script with nohup . #
# Files required: 1. cpumem.sh 2. cpumem.syn #
###########################################################################
cd /home/cpumem
touch cpumem.log
echo "--------------------------------------------------------------------------
--------" >> cpumem.log
echo " Date: Time: (%)CPU Used: (%)Memory Used: " >> c
pumem.log
echo "--------------------------------------------------------------------------
--------" >> cpumem.log
cd /home/cpumem
/opt/perf/bin/glance -adviser_only -j 15 -iterations 5760 -syntax /home/cpumem/
cpumem.syn >> cpumem.log
echo " " >> cpumem.log
echo "--------------------------------------------------------------------------
--------" >> cpumem.log
echo "Monitoring of CPU and Memory done at `date` . " >> cpumem.log
echo "UPTIME= `uptime ` " >> cpumem.log
echo "--------------------------------------------------------------------------
--------" >> cpumem.log
3.
4.
hour=`date +'%H'`
min=`date +'%M'`
uptime=`uptime`
load=`echo $uptime | cut -f2 -dl |cut -f2 -d: | cut -f1 -d, |awk '{print $1}'`
mem=`swapinfo -tm |grep ^memory | awk '{print $4/1024}'`
echo "$load-$hour:$min" >> cpu_utilization.txt
echo "$mem-$hour:$min" >> memory_utz.txt
You'll have free memory in GB but with CPU load i have never come accross it dis
playing in %.
Only values you can get in % format are system utilization (%SYS), user utiliza
tion (%USR),
system idle (%IDLE)
fi
5.
mpsched -c <CPU-NUMBER> /usr/bin/cat /dev/urandom > /dev/null &
6.
UNIX95=1 /usr/bin/ps -e -o pcpu,args | /bin/sort -u -r | sed -e 's/\.[0-9][0-9]/
&\%/g' |sed -n 2,6p | head -1