How to calculate Memory and CPU Usage on AIX


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting How to calculate Memory and CPU Usage on AIX
# 1  
Old 07-31-2007
How to calculate Memory and CPU Usage on AIX

I have written a script that will calculate CPU usage and Memory usage of a particular process on AIX Unix. I know the PID and I am using the command --

# for CPU Usage
MSG_CPU_USG=`ps uax | grep ${PID} | awk {'print $3'}`

#for Memory Usage
MSG_MEM_USG=`ps uax | grep ${PID} | awk {'print $4'}`

This unfortunately does show 0 always even with heavy load to the process.
The process spawns threads.
Is the command correct to use?
Can you please help me?

Thanks in advance,
Asutosh
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Get the memory and cpu usage

what is the best way to get the memory and cpu usage of a process on any system? this is relatively simple. however, i'm looking for a unified method that would work on linux, sunos, hpux, aix. ps -ef | egrep myprocess | awk '{print $4}' ---> there could be several instances of 'myprocess'... (3 Replies)
Discussion started by: SkySmart
3 Replies

2. Linux

How to calculate total CPU usage from SAR report?

Hi, I want to calculate the total cpu usage from the sar report. Say for example, Linux 2.6.24-21-generic (blade10) 09/10/2012 04:54:36 PM CPU %user %nice %system %iowait %steal %idle 04:54:37 PM all 0.00 0.00 0.00 0.00 ... (1 Reply)
Discussion started by: rohitmd
1 Replies

3. AIX

How to monitor the IBM AIX server for I/O usage,memory usage,CPU usage,network..?

How to monitor the IBM AIX server for I/O usage, memory usage, CPU usage, network usage, storage usage? (3 Replies)
Discussion started by: laknar
3 Replies

4. Solaris

current CPU usage, memory usage, disk I/O oid(snmp)

Hi, I want to monitor the current cpu usage, monitor usage , disk I/o and network utlization for solaris using SNMP. I want the oids for above tasks. can you please tell me that Thank you (2 Replies)
Discussion started by: S_venkatesh
2 Replies

5. HP-UX

how can I find cpu usage memory usage swap usage and logical volume usage

how can I find cpu usage memory usage swap usage and I want to know CPU usage above X% and contiue Y times and memory usage above X % and contiue Y times my final destination is monitor process logical volume usage above X % and number of Logical voluage above can I not to... (3 Replies)
Discussion started by: alert0919
3 Replies

6. UNIX for Dummies Questions & Answers

cpu, memory and virtual memory usage

Hi All, Does anyone know what the best commands in the UNIX command line are for obtaining this info: current CPU usage memory usage virtual memory usage preferably with date and time parameters too? thanks ocelot (4 Replies)
Discussion started by: ocelot
4 Replies

7. AIX

Which tools can show the AIX CPU, Memory and I/O usage?

If somebody knows there are some tools can show how many CPU, memory useage on AIX and can automatically send email? Such as when setup if CPU is used over 80%, send alert by email automatically. Maybe BMC has this tool? (6 Replies)
Discussion started by: rainbow_bean
6 Replies

8. UNIX for Dummies Questions & Answers

recording cpu and memory usage

Is there a way for me to record cpu and memory usage over time without buying and installing new software? I know I can use top to see the current state, but can I record that data somehow? (2 Replies)
Discussion started by: cshih31
2 Replies

9. Programming

CPU usage and memory usage

Please tell me solaris functions/api for getting following information 1- Function that tells how much memory used by current process 2- Function that tells how much memory used by all running processes 3- Function that tells how much CPU is used by current process 4- Function that tells how... (1 Reply)
Discussion started by: mansoorulhaq
1 Replies

10. Programming

Monitor CPU usage and Memory Usage

how can i monitor usages of CPU, Memory, Hard disk etc. under SUN Solaries through a c program or java program i want to store that data into database so i can show it graphically thanks in advance (2 Replies)
Discussion started by: Gajanad Bihani
2 Replies
Login or Register to Ask a Question
TASKSET(1)							   User Commands							TASKSET(1)

NAME
taskset - retrieve or set a process's CPU affinity SYNOPSIS
taskset [options] mask command [arg]... taskset [options] -p [mask] pid DESCRIPTION
taskset is used to set or retrieve the CPU affinity of a running process given its PID or to launch a new COMMAND with a given CPU affin- ity. CPU affinity is a scheduler property that "bonds" a process to a given set of CPUs on the system. The Linux scheduler will honor the given CPU affinity and the process will not run on any other CPUs. Note that the Linux scheduler also supports natural CPU affinity: the scheduler attempts to keep processes on the same CPU as long as practical for performance reasons. Therefore, forcing a specific CPU affinity is useful only in certain applications. The CPU affinity is represented as a bitmask, with the lowest order bit corresponding to the first logical CPU and the highest order bit corresponding to the last logical CPU. Not all CPUs may exist on a given system but a mask may specify more CPUs than are present. A retrieved mask will reflect only the bits that correspond to CPUs physically on the system. If an invalid mask is given (i.e., one that corresponds to no valid CPUs on the current system) an error is returned. The masks are typically given in hexadecimal. For example, 0x00000001 is processor #0 0x00000003 is processors #0 and #1 0xFFFFFFFF is all processors (#0 through #31). When taskset returns, it is guaranteed that the given program has been scheduled to a legal CPU. OPTIONS
-a, --all-tasks Set or retrieve the CPU affinity of all the tasks (threads) for a given PID. -p, --pid Operate on an existing PID and do not launch a new task. -c, --cpu-list Specify a numerical list of processors instead of a bitmask. The numbers are separated by commas and may include ranges. For exam- ple: 0,5,7,9-11. -h, --help Display usage information and exit. -V, --version Display version information and exit. USAGE
The default behavior is to run a new command with a given affinity mask: taskset mask command [arguments] You can also retrieve the CPU affinity of an existing task: taskset -p pid Or set it: taskset -p mask pid PERMISSIONS
A user must possess CAP_SYS_NICE to change the CPU affinity of a process. Any user can retrieve the affinity mask. AUTHOR
Written by Robert M. Love. COPYRIGHT
Copyright (C) 2004 Robert M. Love This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICU- LAR PURPOSE. SEE ALSO
chrt(1), nice(1), renice(1), sched_setaffinity(2), sched_getaffinity(2) See sched_setscheduler(2) for a description of the Linux scheduling scheme. AVAILABILITY
The taskset command is part of the util-linux package and is available from ftp://ftp.kernel.org/pub/linux/utils/util-linux/. util-linux April 2003 TASKSET(1)