[Solved] Getting the CPU utilization in a file periodically


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting [Solved] Getting the CPU utilization in a file periodically
# 1  
Old 07-04-2013
[Solved] Getting the CPU utilization in a file periodically

Hi,

I am trying to create a script that will run for every 5 mins to grep the CPU utilization. I have 6 instances running on a single unix server for which I have to export the individual utilizations periodically.
Can we fetch the utilization of 6 instances in separate files using top command? Or is there any other command that I should use?
I tried writing the below line of code

Code:
top -b -d1 -n1|grep "CPU" |grep -i "instance name"|head -c21|cut -d ' ' -f3|cut -d '%' -f1 >> file1.csv


top -b does not seem to work.

I am using #! /bin/sh
# 2  
Old 07-04-2013
What do you mean by "top -b does not seem to work"? What OS are you on? What happens when you invoke "top -b"? It should run until you kill it.
# 3  
Old 07-04-2013
depends which os you are using for top...

type

Code:
which top

send us the output.

top does not exist on aix if that is what you are using.
# 4  
Old 07-04-2013
Hello Techy1,

Could you please try following command in AIX it should work.


Code:
topas

Please press q to come out of it.


Thanks,
R. Singh
# 5  
Old 07-04-2013
Quote:
Originally Posted by RavinderSingh13
Hello Techy1,

Could you please try following command in AIX it should work.


Code:
topas

Please press q to come out of it.


Thanks,
R. Singh
lol i think that was directed to the OP not me. and were not sure of the OS the OP is using since topas is a aix utility.
# 6  
Old 07-05-2013
Hi,

The output to
Code:
which top

is :

Code:
 
$ which top
/usr/bin/top
 
$ top -b
top: illegal option -- b
Usage:  top [-u] [-w] [-q] [-P] [-dx] [-sx] [-p pset_id] [-n number] [-f filename]

Our OS is HP_UX.
# 7  
Old 07-05-2013
There is no batch mode in HP-UX... it offers you the possibility to output to a file using -f filename so
Code:
top -f mytop.out

would give you the output of 1 iteration and 16 process by default (-d1 -n16...)
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Red Hat

CPU Utilization and Memory Utilization of Services and Applications

Hi, i am new to linux/RHEL 6.0 and i have two questions. 1) How to get the CPU utilization and Memory Utilization of all Services running currently? 2) How to get the CPU utilization and Memory Utilization of all Applications running currently? Please help me to find the script. ... (2 Replies)
Discussion started by: nossam
2 Replies

2. UNIX for Advanced & Expert Users

[Solved] High CPU utilization

Hi, i am observing few processes taking high CPU and when i got some more detials about them it looks like this PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 9452 xmp 25 0 16736 1224 860 R 100.0 0.0 903:54.18 ffmpeg -i - 9777 xmp 25 0 16736 1224 ... (1 Reply)
Discussion started by: Siddheshk
1 Replies

3. UNIX for Advanced & Expert Users

CPU utilization

Hi, any commande on AIX 6.1 that shows me total CPU utilization ? I saw curt in documentation but there should be a trace file before. Thank you. (1 Reply)
Discussion started by: big123456
1 Replies

4. Shell Programming and Scripting

CPU Utilization

I know how to check the CPU utilization and memory space like: vmstat top free What i want ot check on my linux system is... how much CPU are available on my system and do i need to put extra CPU. Also need to check the hardware configuration and the space related to the same ... (3 Replies)
Discussion started by: j_panky
3 Replies

5. AIX

CPU Utilization

Hi All, Can some one help me in finding % CPU Utilization ? From VMSTAT command, How we can find % utilization ? Thanks (3 Replies)
Discussion started by: VBudatha
3 Replies

6. UNIX for Dummies Questions & Answers

how to get persistant cpu utilization values per process per cpu in linux (! top,ps)

hi, i want to know cpu utilizatiion per process per cpu..for single processor also if multicore in linux ..to use these values in shell script to kill processes exceeding cpu utilization.ps (pcpu) command does not give exact values..top does not give persistant values..psstat,vmstat..does njot... (3 Replies)
Discussion started by: pankajd
3 Replies

7. Shell Programming and Scripting

CPU Utilization

Hi to All, Would you please help me. I would like to know, In Unix How to know CPU utilization for every process. Thanks in Advance. Thanks, Divyang (3 Replies)
Discussion started by: div_Neev
3 Replies

8. Shell Programming and Scripting

CPU Utilization

Dear friends, I am doing a report daily for all most 30 more serves... i need to check out CPU utlization bu (top command, 100 - (ideal value)) and Memory utilization too could some one help me how can i get it directly, if scripts also no problem.. i will very thankful if some one... (3 Replies)
Discussion started by: bullz26
3 Replies

9. UNIX for Dummies Questions & Answers

CPU FILE SYSTEM UTILIZATION & %

Hi Everyone - I using unix (AIX Version 5.2). What command should I use to see the CPU utilization & how many bytes, %every file in the system is using to see if it needs to be reorganized/resized. Thanks a lot for your help! Ann. :eek: (1 Reply)
Discussion started by: Ann22
1 Replies

10. UNIX for Dummies Questions & Answers

CPU Utilization

What command do you use to verify if the CPU utilization. Example. If the CPU is at 98%? Thanks (4 Replies)
Discussion started by: kimosilk
4 Replies
Login or Register to Ask a Question