Operating System - HP-UX
1753599 Members
6381 Online
108796 Solutions
New Discussion

Re: CPU utilization measure script

 
Ajin_1
Valued Contributor

Cup utilization measure script

 

 

HI Experts

 

for Cup utilization measure  we are using the below scrip ,can anyone explain how it work? it im not able to understand this.

 

usr/bin/sar 1 | /usr/bin/grep -v 'usr' | /usr/bin/grep -v 'HP' | /usr/bin/tr -d '\n'| /usr/bin/awk 'NF==5 {total=$2+$3} END {print total}'

 

Thanks in advance .Appriciate your help

 

 

 P.S.This thread has been moved from HP-UX>System Administration to HP-UX >  langages- HP Forums Moderator

Thanks & Regards
Ajin.S
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
1 REPLY 1
Dennis Handly
Acclaimed Contributor

Re: CPU utilization measure script

(It would help if you got rid of those html codes and provided text.)

 

>sar 1 | grep -v -e 'usr' -e 'HP' | tr -d '\n'| awk 'NF==5 {total=$2+$3} END {print total}'

 

This takes a sample after 1 second.

Removes lines with usr or HP.  (Most likely the title/header lines.)

Deletes all newlines.  (I'm not sure why since awk can total up columns?)

If there are 5 fields, add field 2 and 3 (user and sys times) and print a total after reading all of the(1) lines.