LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Get Thread count , Used memory for a particular Process (https://www.linuxquestions.org/questions/programming-9/get-thread-count-used-memory-for-a-particular-process-707340/)

haseit 02-25-2009 01:28 AM

Get Thread count , Used memory for a particular Process
 
Hello All,

I've several question related to the Process information gathering in Linux which use the "ps" functionality.

My problem is

1. How to get the Tread count for particular process name(or the command such as gedit,skype,eclipse)

eg: ps -elm|grep $pid|grep -v grep |wc -l

in this example it use the PID what i actually want is to get the thread count using the process name

2. How to get the memory size in MB for a given process name or PID using greap functionality such as in the above example.

3. How to search a process is exist or not using the given process name or PID using greap as above example.

4. How to find the main module which need to run the process name or PID using greap.

Please help me on this matter ......

Thank you in Advance
Hasantha

chakka.lokesh 02-25-2009 02:24 AM

what about your effort? what you tried?

haseit 02-25-2009 11:11 PM

Hello Chakka,

I know the 1st one is quite ok but i'm struggling with other 2,3,4,5 problems i mention. if you know please help me on this in advance... Thanks

Hasantha

chakka.lokesh 02-25-2009 11:14 PM

for second question, check if top is helpful to you....

chakka.lokesh 02-25-2009 11:25 PM

Quote:

Originally Posted by haseit (Post 3456531)
3. How to search a process is exist or not using the given process name or PID using greap as above example.

ps aux | grep <PID>

Note: this will print the process details if it is existing along with the command we used which is grep.

like the following:

[lokesh@computer ~]$ ps aux | grep 2338
lokesh 2338 0.1 0.3 4840 1524 pts/0 Ss 11:00 0:00 bash
lokesh 2371 0.0 0.1 4044 668 pts/0 R+ 11:01 0:00 grep 2338

if the process with id 2338 is not existing the the result will be like this.

[lokesh@computer ~]$ ps aux | grep 2338
lokesh 2371 0.0 0.1 4044 668 pts/0 R+ 11:01 0:00 grep 2338

Don't get confused.

chakka.lokesh 02-25-2009 11:28 PM

Quote:

Originally Posted by haseit (Post 3456531)
4. How to find the main module which need to run the process name or PID using greap.

I didn't understand this question. can you please reframe this so that I will be able to try to give answer.

haseit 02-26-2009 01:50 AM

Hello Chakka,

Thank you for the quick respond. really appreciate your effort.

for the 2nd Question i actually need to get the process memory size in MB look the below example m looking for

[lokesh@computer ~]$ ps aux | grep PID ...... something
20 MB ... or the size of the process

for the 4th Question what i want is to get the CMD for a particular process
EG: ps -ef .... something ..
usr/lib/libstdc++.so.6

(what i really need to get only the CMD)

so if i use that CMD value and execute i need to get a fresh application for that.

Thanks in advance again
Hasantha

chakka.lokesh 02-26-2009 05:10 AM

for your second question, i didn't found anywhere ps is giving direct memory details.


with respect to your fourth, what is this CMD? Do you mean command? If it is have a look at the last column of the ps aux command.


All times are GMT -5. The time now is 01:22 AM.