Sunday, December 4, 2011

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

Bookmark and Share

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.

Friday, September 30, 2011

CPU Info – Linux, Solaris, AIX, HP-UX

Bookmark and Share

Below are the CLIs to display CPU information on Linux, Solaris, AIX and HP-UX.

LINUX: 

# cat /proc/cpuinfo

SOLARIS:

# psrinfo –v

# prtdiag

or

# prtdiag | grep SUNW

# prtconf

AIX:

# lscfg -l proc*

and

# lsattr -El <proc_num_from_above_cli>

HP-UX:

# machinfo

High Availability Lens 3

Bookmark and Share

In previous high availability lens 2, we saw general formula to express availability in terms of uptime and downtime. And also in terms of MTBF and MTTR.

MTTR is mean time to repair ,i.e. average time required to repair a failure. If we look at the formula for availability in terms of MTBF and MTTR, we can observe that we can make very interesting conclusion. As MTTR tends to zero, availability tends to 1 ,i.e. 100%

And this is where clustering softwares come into picture by helping MTTR reduce by automation. It should be also noted that MTTR is affected by lot of complexities such as application dependencies, underlying hardware being used etc.

Tuesday, September 27, 2011

Firefox script timeout and workaround

Bookmark and Share

In Firefox scripts time out frequently while accessing web pages which large data. By large data, I mean that scripts/web pages taking long time to crunch data on client-side. e.g. plotting JavaScript based graphs with more than 20K data points. In this case, data has to be downloaded at client side and graphs will be plot. (This is just an example. We can process these points on sever-side and send chart image to client side.)

However, Firefox will timeout in such cases and possibly hang. In order to workaround this problem, we can set few DOM preferences available in Firefox. Below are the steps that I used to resolve similar kind of problem with Firefox.

1. Navigate to Firefox preferences by typing “about:config “ in address bar

2. Type in “dom” and look for “dom.max_chrome_script_run_time” and “dom.max_script_run_time” and set this values to more than 30(seconds by default) e.g. 60 or 120 seconds.

More info @ DOM Preferences

3. Restart Firefox.

This workaround has worked for me. Are there are any other workarounds that you know? then please post it in the comments below.

Sunday, August 7, 2011

Firefox sync settings are lost

Bookmark and Share

Firefox Sync Settings are Lost

One of the most used features of Firefox on my computer is Firefox sync (previously Mozilla Weave).

However, once Firefox is upgraded from 3.x to 4.x (and now to 5.x), Mozilla Firefox stops syncing when Firefox is closed. The issue is default Privacy settings that shipped with Firefox and clears all history when Firefox is closed. This looks like a bug in Mozilla Firefox.

As a workaround to this issue, on Windows navigate to Tools –> Options –> Privacy Tab –> History and there set dropdown for “Firefox will:” to “Remember History”. For Linux, just navigate to Edit –> Preferences and follow same steps as above. These settings worked for me.

Hope it helps!

 




Technology