• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to Get processes list from Remote Machine

 
Ranch Hand
Posts: 1252
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1252
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.)
 
Bartender
Posts: 10336
Hibernate Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1252
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 1170
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Don't count your weasels before they've popped. And now for a mulberry bush related tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic