I have a list of IPs in a json file . My java application should do the following.
Other information:
Can you please suggest the options I have to perform this task?
One option is to install/enable SSH Servers in the remote machines, then
ping to each IP to check if its up.
In java, you could use something like InetAddress#isReachable() for this.ps etc to get the list of running processes in the machine. In java you could use any of the available SSH libraries. Eg: jschYou 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).
Instead of InetAddress#isReachable(), you can use Runtimes's exec command to run a native ping command. check this
You could try to use Zabbix or some light weight analog with JMX
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);
For 3rd step you could use JSch