- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - HP-UX
- >
- Re: Getting Average Minimum and Maximum CPU utiliz...
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-22-2005 11:57 PM
тАО08-22-2005 11:57 PM
I'm attempting to get the % CPU utilization of a running application in terms of its maximum, minimum and average percentages.
I was using "top" to get the %CPU for an application. However, the value keeps changing very quickly and it becomes difficult to get the values over a period of time to calculate the avarage, min or max values.
In using vmstat,may I know what is the unit measurement of averaged CPU? Also, what is the way of capturing the CPU utilization within a time period?
Would greatly appreciate it if anyone could help me out by showing me the proper usage of of these tools
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2005 12:07 AM
тАО08-23-2005 12:07 AM
SolutionYou can use sar to capture the CPU usage data over a long time.
vmstat for Virtual Memory statistics.
iostat for io statistics.
###########################################
#!/usr/bin/ksh
touch sar_cpu.txt ; touch vmstat.txt ; touch iostat.txt
i=0
while [ $i -le 60 ]
do
sar -u 5 12 >>sar_cpu.txt # 5 second interval .
vmstat 5 12 >> vmstat.txt
iostat 5 12 >> iostat.txt
echo "-----------------------"
i=`expr $i + 1`
done
echo " SAR data collected for 1 hr complete "
echo " CPU Data stored in the file sar_cpu.txt "
echo "Vmstat Data stored in the file vmstat.txt "
echo "iostat Data stored in the file iostat.txt "
echo "------------------------------------"
###########################################
cheers,
Raj.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2005 12:09 AM
тАО08-23-2005 12:09 AM
Re: Getting Average Minimum and Maximum CPU utilization of a process
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2005 12:26 AM
тАО08-23-2005 12:26 AM
Re: Getting Average Minimum and Maximum CPU utilization of a process
You can use glance utility to capture periodically.
# glance -f
Using outputfile you can generate CPU report.
Cheers,
Rajesh
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО08-23-2005 12:39 AM
тАО08-23-2005 12:39 AM
Re: Getting Average Minimum and Maximum CPU utilization of a process
I am just go through the script. This will help you to get a consolidated system statistics. If you can configure a mail alias in the server the same statistics can me mailed to your email ID automatically on daily basis.
#script for putting glance output to file - every hour.
#Exporting the required paths
export path=/syam/glance
export file=`date "+glance%d%m%y.txt"`
export data=`date "+/syam/glance/glance%d%m%y.txt"`
/usr/bin/echo "Reading at `date` \n" >> /syam/glance/$file
#Checking if the file exists and date matches file.
if ["$data" == "/syam/glance/$file"] 2>/dev/null
then
/opt/perf/bin/glance -adviser_only -iterations 2 -j2 -syntax /syam/glance/glance.syntax >> /syam/glance/$file
exit 0
else
/opt/perf/bin/glance -adviser_only -iterations 2 -j2 -syntax /syam/glance/glance.syntax >> /syam/glance/$file
exit 0
fi
============================================================================================================================
#Script for calculating min & max value from log files
s1=`ls -ltr /syam/glance/*.txt|tail -2|head -1|awk '{print $NF}'`
#Actual Script starts here
#Calculating min/max/avg values for CPU
echo "Report for DATASVR Server\n" > /syam/glance/DATASVR-stat
Mincpu=`strings $s1|grep -v "0.0"|grep "CPU UTIL"|awk '{print $NF}'|awk 'NR==1 {m=$1} $1<=m {m=$1} END {print m}'`
echo "Min CPU Util - $Mincpu %" >> /syam/glance/DATASVR-stat
Maxcpu=`strings $s1|grep -v "0.0"|grep "CPU UTIL"|awk '{print $NF}'|awk 'NR==1 {m=$1} $1>=m {m=$1} END {print m}'`
echo "Max CPU Util - $Maxcpu %" >> /syam/glance/DATASVR-stat
avgcpu=`strings $s1|grep -v "0.0"|grep "CPU UTIL"|awk '{s+=$NF} END {print s/NR}'`
echo "Avg CPU Util - $avgcpu %" >> /syam/glance/DATASVR-stat
echo "\n" >> /syam/glance/DATASVR-stat
#Calculating min/max/avg values for MEMORY
Minmem=`strings $s1|grep -v "0.0"|grep "MEM UTIL"|awk '{print $NF}'|awk 'NR==1 {m=$1} $1<=m {m=$1} END {print m}'`
echo "Min MEMORY Util - $Minmem %" >> /syam/glance/DATASVR-stat
Maxmem=`strings $s1|grep -v "0.0"|grep "MEM UTIL"|awk '{print $NF}'|awk 'NR==1 {m=$1} $1>=m {m=$1} END {print m}'`
echo "Max MEMORY Util - $Maxmem %" >> /syam/glance/DATASVR-stat
avgmem=`strings $s1|grep -v "0.0"|grep "MEM UTIL"|awk '{s+=$NF} END {print s/NR}'`
echo "Avg MEMORY Util - $avgmem %" >> /syam/glance/DATASVR-stat
echo "\n" >> /syam/glance/DATASVR-stat
#Calculating min/max/avg values for DISK
Mindisk=`strings $s1|grep -v "0.0"|grep "DISK PEAK UTIL"|awk '{print $NF}'|awk 'NR==1 {m=$1} $1<=m {m=$1} END {print m}'`
echo "Min DISK Util - $Mindisk %" >> /syam/glance/DATASVR-stat
Maxdisk=`strings $s1|grep -v "0.0"|grep "DISK PEAK UTIL"|awk '{print $NF}'|awk 'NR==1 {m=$1} $1>=m {m=$1} END {print m}'`
echo "Max DISK Util - $Maxdisk %" >> /syam/glance/DATASVR-stat
avgdisk=`strings $s1|grep -v "0.0"|grep "DISK PEAK UTIL"|awk '{s+=$NF} END {print s/NR}'`
echo "Avg DISK Util - $avgdisk %" >> /syam/glance/DATASVR-stat
echo "\n" >> /syam/glance/DATASVR-stat
#Consolidating the reports to final report file-"final-stat"
strings /syam/glance/DATASVR-stat >> /syam/glance/final-stat
echo "\n" >> /syam/glance/final-stat
======================================================================================================================
#Mailing the report.
mailx -s "Daily Uptime Report DATASVR" MAIL_ALIAS < "/syam/glance/final-stat"
#Putting file in /tmp - In case if you need it again
cp /syam/glance/final-stat /tmp/.
#Sleeping for 20 sec. - waiting to send the mail
sleep 20
#Resetting the file to zero bytes again
> /syam/glance/final-stat
======================================================================================================================================
CRONTAB ENTRIES FOR DATA COLLECTION
======================================
# Running anil1 to collect glance output every hour
0,30 * * * * ksh /syam/glance/anil1
# Calculating daily min/max values from glance file
15 00 * * * ksh /syam/glance/stat
=================================================================================================================================
Regards,
Syam