I'm looking for somthing like top is to CPU usage. Is there a command line argument for top that does this? Currently, my memory is so full that even 'man top' fails with out of memory :)
In Solaris the command you would need is:
prstat -a -s size
This will list all processes in order of descending process image size. Note that the latter is based on memory committed to the process by the OS, not its resident physical memory usage.
There are supposedly versions of "top" available for Solaris, but these are not part of the standard installation.
It can be achieved in multiple ways, My favourite one is:
The PS way:
[arif@arif ~]$ ps -eo pid,cmd,%cpu,%mem --sort=-%mem
-e: to select all process
-o: to apply to the output format
%mem: Output format in exact order. Here,
pmemcan be used instead of
- But sadly (don't know why) it doesn't work on some machine (Oracle Linux) and some older machine. You can use the following similar alternatives.
[arif@arif ~]$ ps aux --sort '-%mem' --cols 120 | head
--cols 100: to specify column width of the output as sometimes
cmdgets very long. This is not necessary if you don't want curtailed commands with arguments.
aux: to see every process on the system using BSD syntax
[arif@arif ~]$ ps -eo pid,cmd,%cpu,%mem --sort -rss
-rss: resident set size, the non-swapped physical memory that a task has used
[arif@arif ~]$ ps aux --sort -rss --cols 120
The top way:
[arif@arif ~]$ top -b -o +%MEM
-b: to use
-o: to override sort fieldname followed by a fieldname
And you can always use
tail to control the output.
Globally: It's always recommended to use a log analyser tool for logging history logs such as Splunk, ELK etc. So that using query language you can easily get the PIDs and its usage by CPU & memory.
AT SERVER/OS LEVEL: From inside top you can try the following:
Press SHIFT+M ---> This will give you a process which takes more memory in descending order.
You might also try:
$ ps -eo pid,ppid,cmd,%mem,%cpu --sort=-%mem | head -10
This will give the top 10 processes by memory usage. Also you can use vmstat utility to find the RAM usage at same time not for history.