Question

I'm working on a project similar to what we call system monitor in Linux. I'm using opensuse 11.4 gnome. I was wondering if there's any command (Except ps) that lists all currently running applications on the system. I'm developing it for multi-core environment.

For example I'm browsing the web with Firefox and lets say Google Chrome simultaneously, plus I'm editing text in a text file. In this scenario, when I open my project, I want the list of all applications currently running [in my scenario, the names gEdit, Google Chrome and Firefox(but not the process these three apps generated) must be displayed as a list]

The output I want is the same as what we get in the Applications tab when we use task manager in Windows.

If anyone has a solution, please let me know it'll be highly apprecieted. I'm using netbeans to implement the project. Thanks!!!

Was it helpful?

Solution

Have you tried pstree yet? well this shows you a tree of the processes that are running on the system.

htop is what I usually use for multicore enviornment cause it shows resource utilization and you can see where your processes are pinned by adding columns. htop is more userfriendly than top and has more options. when you run it just hit 't' and it will sort the processes by their parents.

I don't know any other tools, but your other option is to go through /proc and write your own script to extract the information you need.

I hope it helps.

EDIT: I forgot to mention that processes are being forked in linux, so there is a parent process which starts a couple of other processes/threads. From your question, it seems that you are trying to find the parent process for each running process, my answers are based on that assumption.

OTHER TIPS

I don't think there is a easy way of getting this done. In Linux an application may create several processes on startup - for example let's take postfix:

localhost:~ # ps -ef|grep postfix
 root      3708     1  0 Apr24 ?        00:00:35 /usr/lib/postfix/master
 postfix   3748  3708  0 Apr24 ?        00:00:01 qmgr -l -t fifo -u
 postfix   3749  3708  0 Apr24 ?        00:00:00 pickup -l -t fifo -u -c
 postfix  13504  3708  0 16:05 ?        00:00:00 cleanup -z -t unix -u -c
 postfix  15458  3708  0 17:45 ?        00:00:00 cleanup -z -t unix -u -c
 postfix  19907  3708  0 19:25 ?        00:00:00 cleanup -z -t unix -u -c

the processes "master", "qmgr", "pickup" and "cleanup" all belong to the application postfix. You can see that those processes each belong to one parent process "master" by looking at the third column which tells you the parent process who has startet this process. In my example all processes have been startet by process with id 3708. Another example is the Apache Webserver, which creates several httpd processes on startup - here the process names are all the same only the count varies depending on the configuration.

To come back to the problem you would like to solve: From my point of view there are two ways you could try:

  1. Build up a database which contains associations of processes names to applications and use this to create your list of applications by using ps.
  2. You restrict your application to list only applications which display a graphical user interface. This list should be easily build by using some X11 functions or the likes...

hope this helps...

Check out top (linux command)

And this article will help you a lot. http://www.cyberciti.biz/tips/top-linux-monitoring-tools.html

You may want to start from xlsclients.

It probably does not have all the functionality you need, but then Linux has no well-defined notion of application.

The next thing you might find useful is xprop (look for _NET_WM_PID) but this is not guaranteed to work for all programs.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top