Process monitoring on Unix/Linux/Solaris/HP-UX/AIX

Posted on December 28, 2011. Filed under: OS's, Technology |

It’s often a requirement to monitor Unix processes in the field of performance monitoring. However, there is a catch. Different flavors of Unix have different process monitoring tools such as `top`. Of course `top` is not available on all platforms. Similarly HP-UX has something called ‘glance’. This is again very platform specific.

The only CLI that is supported for process monitoring across different flavors of Unix is ‘ps’. However, one of the most two parameters that we are interested in process monitoring is its SIZE and CPU usages. Both of these parameters can be retrieved using ‘ps’ CLI.

To obtain size of a process, we generally use PS parameters ‘vsz’. It’s the size of process in virtual memory. To obtain CPU usages of a process, we generally use PS parameter `cpu` which gives absolute CPU usage of a process. On some Unices, PS provides parameter called ‘pcpu’ which provides percentage of CPU usage by a process. There are still limitations of this approach as described above. Few of the unices do not provide ‘pcpu’ parameter and instead provide ‘cpu’ parameter e.g HP-UX.

However, it’s still better to rely on single UNIX provided `ps` CLI that can be used inside a any shell or Perl script. In order to use `ps` CLI we should be relying on UNIX95 Unix standard as defined in the Single UNIX Specification.

e.g. Following CLI prints “our_process” usages on HP-UX with columns viz. process name, its virtual memory size and its absolute CPU usages on single line. It is just a matter of changing cpu to pcpu and application of few filters on some of the Unix platforms as per our requirements. But it does work.

# export UNIX95=1; ps –eo args,vsz,cpu | grep “our_process”

It just a matter of directing output of above CLI to a file post application of filters

# cntr=1;while test $cntr;do export UNIX95=1; ps -eo args,vsz,sz,cpu |egrep -v “our_process” | awk ‘{print $1″\t”$2\”\t”$4}’ ;done >> /tmp/our_process.txt &

Above while loop keep on dumping process virtual memory size and CPU usages of our_process in /tmp/our_process.txt file. Since output is in tabbed format, this output file can be easily opened in Microsoft Excel and graphs can be plotted.

Do you use any other methodology to monitor processes on Unix machines? If yes then do let everyone know in comments below.

Advertisements

Make a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

One Response to “Process monitoring on Unix/Linux/Solaris/HP-UX/AIX”

RSS Feed for Fiber Optic Network Comments RSS Feed

This is really attention-grabbing, You’re an excessively professional blogger. I’ve joined your rss feed and look ahead to in quest of extra of your wonderful post. Additionally, I have shared your web site in my social networks


Where's The Comment Form?

Liked it here?
Why not try sites on the blogroll...

%d bloggers like this: