Win a copy of Escape Velocity: Better Metrics for Agile Teams this week in the Agile and Other Processes forum!
  • 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
  • Liutauras Vilda
  • Tim Cooke
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Frank Carver
  • Junilu Lacar
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Frits Walraven
  • fred rosenberger

How to check services,through java program

 
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my previous post,I posted a query reg how to monitor sofwares.
Since that topic is closed,Iam putting my question in a clear way.

If I use the command services.msc,I knew the services installed in my system.

My exact requirement is,I need to write a java program which connects to the remote machine and checks what all services and processes are running in that machine.

Pls provide me the inputs to Proceed.

Thanks a lot in advance,
Vidhya
 
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
I am quessing, since you mention services.msc, we are talking about Windows here. The only way to do what you want is by calling native code. There are third party tools to manage remote services but I think (someone may correct me) the only tool supplied with Windows is RDP. If your target machines are running terminal services you may be able to connect and query the registry and task manager. But before you even attempt to do this through Java, you'll need to find out if it is event possible, so I'd start to look at the documentation.


(By the way, your previous topic is not closed, it has been moved, since it was not an advanced question. )
 
Vid Srini
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Paul for your reply and info !!!
 
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I could suggest a naive solution.

The Windows command net start lists the set of started services in WIndows. If you create a bat file in the server machine that calls this command, then you can use it with a java.lang.ProcessBuilder to get its output.

The bat file listservices.bat would say:



And I could use it this way:



You may need to improve the algorithm to remove blank lines and messages displayed in the command line.

Once this is working you could create a very simple Java socket that returns this information.

You could also use another Windows commands, like tasklist which lists all the programs currenly running.

Could that be helpful?
[ December 12, 2006: Message edited by: Edwin Dalorzo ]
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How about remote mornitoring of services using JMX.
[ December 12, 2006: Message edited by: Rahul Bhattacharjee ]
 
Paul Sturrock
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

Originally posted by Rahul Bhattacharjee:
How about remote mornitoring of services using JMX.

[ December 12, 2006: Message edited by: Rahul Bhattacharjee ]



Not sure I follow how adding JMX helps - perhaps I missunderstand, but will JMX not just give you a route to manage whatever software you write to monitor the Windows services? i.e. its just a layer on top of whatever solution you write for this probelm, it doesn't fix the problem itself.

Edwin Dalorzo's solution may well work. And simple is often the best. I'm not sure though how you would get the batchfile to run remotely. As far as I am aware you can only do that sort of thing with a WSF (and that presumes all remote machines are XP or higher).
[ December 12, 2006: Message edited by: Paul Sturrock ]
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My apologies, I misunderstood the question.
I though of remote mornitoring of the services(may be beans), so i suggested for something like JMX.
 
Vid Srini
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot for your valuable idea Edwin.Your solution works out for my problem.
 
permaculture is giving a gift to your future self. After reading this tiny ad:
The trailboss has a kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic