Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

169
Visualizações
How to read the processes running on another machine with java

I have a list of IPs in a json file . My java application should do the following.

  1. Read IPs from the JSON file. [this has been taken care of]
  2. Should check if the machines mentioned in the JSON file are up and running.
  3. If the machine is up, my application should read the processes that are running in that computer.

Other information:

  1. My java application would run on a Linux OS
  2. The machines mentioned in the JSON file are also on Linux
  3. My application is a standalone java application.

Can you please suggest the options I have to perform this task?

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

One option is to install/enable SSH Servers in the remote machines, then

  1. Read IPs from JSON
  2. do something like a ping to each IP to check if its up. In java, you could use something like InetAddress#isReachable() for this.
  3. connect to the IP using SSH and issue linux commands like ps etc to get the list of running processes in the machine. In java you could use any of the available SSH libraries. Eg: jsch

You can even skip the step 2 and straight away try the SSH connection, and determine if host is up that way.. but pinging will be more reliable (but make sure no firewall settings block the remote machines from responding to pings).

Update

Instead of InetAddress#isReachable(), you can use Runtimes's exec command to run a native ping command. check this

over 4 years ago · Santiago Trujillo Relatório

0

You could try to use Zabbix or some light weight analog with JMX

over 4 years ago · Santiago Trujillo Relatório

0

  1. For parsing json there are pretty much different json formatters. As like gson, Jackson, boon.
  2. On your computer ping command may not exist. So, more accurate way to check availability is to use ()

    InetAddress address = InetAddress.getByName("127.0.0.1");
    boolean reachable = address.isReachable(10000);
    

    But there might be issues. So, if you doesn't fear platform dependency, you can use UNIX ping command as follow:

    Process p1 = java.lang.Runtime.getRuntime().exec("ping -c 1 www.google.com");
    int returnVal = p1.waitFor();
    boolean reachable = (returnVal==0);
    
  3. For 3rd step you could use JSch

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda