Objective: check if a host is up-and-running on the network,
with a method that can be efficiently parallelized over many hosts.
Emphasis on a QUICK turnaround of the check.
Reason to emphasise speed: multiple checks (in the hundreds) need to be performed in rapid succession and return results reasonably quickly.
The current script uses a simple
ping command. The choice is not obligatory, on the contrary any suitable tool with equal or better reliability and speed may be used as replacement.
Something along these lines:
ping -c 1 -W 100 -q "$NETWORK_HOST" &> /dev/null
Obvious deficiency of this approach: responses are needed with a sub-second turn-around and this can wait up to a second, from experience.
Forget about speed of sequential execution, run many
ping commands in parallel using GNU
parallel and collate the results at the end. This has been experimented with but seems even worse in practice.
Intuition about a better solution
It seems like
ping may work just fine as a "polling health check", all it needs to be tweaked to do is to wait very little time and time-out in case of no response.
Assumption: the network is considered reliable and FAST, the hosts don't have either of the qualities necessarily.
How would you solve this? Which tool(s) would you use? Is this the right approach? Could you provide a code snippet?
- Environment: OS X + Ubuntu hosts
- Scripting shell: Bash
- Can install additional software if needed.
- Can compile/install new code for an application not in the repository and use that.