8 Replies - 3322 Views - Last Post: 04 July 2012 - 01:53 PM Rate Topic: -----

#1 saravanataee  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 29-June 12

java program to monitor the status of a program in linux!

Posted 29 June 2012 - 06:25 AM

Hi,
I am sorry for my previous post and my intent is not to get a code from the members, rather i dint know how to begin with on this particular problem. I just need to know what should be done like the steps to follow to arrive at the solution. Now i m blank, do not know starting or ending.

So, please tell me the way to acheive the task.! Please help me! not with the code, just with the logic!!
Is This A Good Question/Topic? 0
  • +

Replies To: java program to monitor the status of a program in linux!

#2 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7575
  • View blog
  • Posts: 12,725
  • Joined: 19-March 11

Re: java program to monitor the status of a program in linux!

Posted 29 June 2012 - 06:36 AM

Please explain, as precisely as you can, what it is you want your program to do.
Describing the problem clearly is the most important step in solving it or in getting help solving it.
Was This Post Helpful? 0
  • +
  • -

#3 saravanataee  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 29-June 12

Re: java program to monitor the status of a program in linux!

Posted 29 June 2012 - 06:58 AM

Hi,
Thanks,

I want to write a java program which can monitor the status of any running program or application in linux. And also be able to stop and start the service of that specific proram.!

A java program to control and manage another program in linux system.!

Any idea!!
Was This Post Helpful? 0
  • +
  • -

#4 jon.kiparsky  Icon User is offline

  • Pancakes!
  • member icon


Reputation: 7575
  • View blog
  • Posts: 12,725
  • Joined: 19-March 11

Re: java program to monitor the status of a program in linux!

Posted 29 June 2012 - 07:38 AM

That doesn't really expand on what you said before, I'm afraid. What is it you want to monitor?

Whatever it is, it's likely that the tools for monitoring it already exist in the command line or in the /proc directory, so you'd really just be writing a front-end GUI to query existing services. Is that what you're looking for?
Was This Post Helpful? 0
  • +
  • -

#5 saravanataee  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 29-June 12

Re: java program to monitor the status of a program in linux!

Posted 29 June 2012 - 07:45 AM

Hi,
For example,
in linux i have a netbean application running. I want to monitor its status and i should be able to start and stop it. This must be done using java program. !
Can you tell me how to acheive this. with the help of tools or may be without?? both way..! just a way to acheive!! please!
Was This Post Helpful? 0
  • +
  • -

#6 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2656
  • View blog
  • Posts: 11,197
  • Joined: 20-September 08

Re: java program to monitor the status of a program in linux!

Posted 29 June 2012 - 08:10 AM

Take a look at jsvc or Tanukisoft service wrapper (to monitor a program you need a daemon essentially)
Was This Post Helpful? 1
  • +
  • -

#7 saravanataee  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 10
  • Joined: 29-June 12

Re: java program to monitor the status of a program in linux!

Posted 03 July 2012 - 09:58 PM

Hi,
This is the continuation of my previous thread. I am sorry, i did not mean to ask code rather a logic on how to approach it. I have the idea of using java exec() method to execute a ssh to connect to a remote host. But i still have no idea how to write logic for starting and stopping an application.

Here is the code i wrote of exec

import java.util.*;
import java.io.*;
// class StreamGobbler omitted for brevity
public class ExcuteImp
{
    public static void main(String args[])
    {
        if (args.length < 1)
        {
            System.out.println("USAGE: java ExecuteImp \"cmd\"");
            System.exit(1);
        }
        
        try
        {
            String cmd = args[0];
            Runtime rt = Runtime.getRuntime();
            Process proc = rt.exec(cmd);
            
            // any error message?
            StreamGobbler errorGobbler = new 
                StreamGobbler(proc.getErrorStream(), "ERR");            
            
            // any output?
            StreamGobbler outputGobbler = new 
                StreamGobbler(proc.getInputStream(), "OUT");
                
            // kick them off
            errorGobbler.start();
            outputGobbler.start();
                                    
            // any error???
            int exitVal = proc.waitFor();
            System.out.println("ExitValue: " + exitVal);
        } catch (Throwable t)
          {
            t.printStackTrace();
          }
    }
}


This post has been edited by macosxnerd101: 03 July 2012 - 11:44 PM
Reason for edit:: Code tags are not XML. Please [code] Post your code between these tags [/code].

Was This Post Helpful? 0
  • +
  • -

#8 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 2656
  • View blog
  • Posts: 11,197
  • Joined: 20-September 08

Re: java program to monitor the status of a program in linux!

Posted 04 July 2012 - 03:00 AM

I'm posting here since your later question is currently locked. You probably need to start with the following (read referenced link too)

http://technojeeves..../52-runtimeexec
Was This Post Helpful? 1
  • +
  • -

#9 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10396
  • View blog
  • Posts: 38,463
  • Joined: 27-December 08

Re: java program to monitor the status of a program in linux!

Posted 04 July 2012 - 01:53 PM

Duplicate threads merged. Please STOP opening duplicate threads.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1