This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to Get processes list from Remote Machine

 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

Actually I need to know the running processes on remote server.

I must clear one thing that we don't have any access right problems for that server. We can access that server from my local machine.

Now what I want to do is designing of a graphical application in which User can have view to all processes running on that server machine, and according to the user right he/she can cancel/kill the process.

I have done some work besides of Swing designing for getting the list of processes of Local Machines. Here it is as follows.

[B][/B]

Now could anyone let me know, How to get the remote running(live) processes if we know the IP of that machine.

For this we can let suppose the IP of machine is XYZ.ABC.DEF.RDE.

Thanks in advance for replies.

[ March 14, 2007: Message edited by: Ankur Sharma ]
[ March 14, 2007: Message edited by: Ankur Sharma ]
 
Joe Ess
Bartender
Posts: 9280
10
Linux Mac OS X Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ankur Sharma:

Now could anyone let me know, How to get the remote running(live) processes if we know the IP of that machine.


Short of writing some service to run on the remote machine and provide you with a list, it cannot be done.
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Joe Ess:


Short of writing some service to run on the remote machine and provide you with a list, it cannot be done.


Thanks Joe for prompt reply.

Cann't you suggest me a short and sweet way to get run this sort of application.

I have already eloborated my application, I want to show the user to show those selected running application. And then user may start it either from remote or from local machine.

I have idea of using JSP's and Servlets.

Would it be a right solution, if I write the main logic into servlets and then try to access it and then start/end those application from JSP's by some flag process.

Do suggest me if you guys have any other better idea for this application.
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That would be fine, yes. A servlet could use Runtime.exec("tasklist") to get the list of processes and then display them in a form that let the user select processes to kill. When the form was submitted, the servlet (or another one, of course) receiving the form could then use Runtime.exec() to execute whatever Windows program you can run to kill a process (I'm assuming there is one.)
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Would it be a right solution, if I write the main logic into servlets and then try to access it and then start/end those application from JSP's by some flag process.

Do suggest me if you guys have any other better idea for this application.

Is this a Windows only solution? If so why are you using Java at all? You can administer remote services with the tools Microsoft already supply.
 
Shaan Shar
Ranch Hand
Posts: 1249
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Paul Sturrock:

Is this a Windows only solution? If so why are you using Java at all? You can administer remote services with the tools Microsoft already supply.


No Paul,

This is not basically used for windows environment. It would be used for Unix machine.

One more concern when I used the same program to run on Unix Machine with command ps -ef|grep java. Which will list all the running java programs. It was not working.

Can anyone explain this command ps -ef|grep java.
 
Henry Wong
author
Marshal
Pie
Posts: 21123
78
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone explain this command ps -ef|grep java.


This is actually *two* commands. The "ps" command is providing the list of tasks. The output of that command is piped to the "grep" command which is getting rid of every line that doesn't have "java" in it.

If you want to get this to work, you may have to run a "sh" command, passing these two commands as parameters, as you need a shell to setup the pipes.

IMHO, I would recommend just using the "ps -ef" command. Once you get the output stream of the command, you can filter to what you need with Java. No need for another "sh", or the "grep" command.

Henry
 
Mr. C Lamont Gilbert
Ranch Hand
Posts: 1170
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is simple on linux. You just ssh into the remote machine, and execute your command there as if you are local. My Mandriva Linux and I assume every other Linux out there already does this. I can display, memory, file usage, cpu usage, network usage, all that good stuff for the local machine. To display it for a remote machine I first connect to it through ssh.

Perhaps you can do that. Its more secure and should abstract you from much of your code to have to know the data is coming remotely. and for the local machine you can 'ssh localhost' for consistency.


as Henry said "ps -ef|grep java" is two commands. Seperated by a 'pipe' which is represented by '|'. The data from ps -ef is piped into 'grep java'. This is the same technique that you would use to pipe your command through the ssh tunnel so it is executed remotely.

I dont know right off hand how to do it, and my computer here termprarily does not have ssh so I cant check it.
[ March 14, 2007: Message edited by: Mr. C Lamont Gilbert ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic