ping multiple gateways

Currently at my workplace, our hosts have multiple connections to different gateways. I am trying to find a way to see whether I can easily ping 4-5 gateways by either running an ad-hoc command or through a playbook to help me verify that after each host deployment, connection to those gateways are successful. Has anybody ever done this before?

If I’m understanding it correctly, you are looking for a way to validate if your gateways are pingable. I usually do it using a Excel Ping script where i mention the gateway IPs and hit execute to test if they are reachable. Link to the script. http://wintelgeeks.com/2016/02/11/script-to-ping-multiple-servers-using-excel/

The following req. /bin/ping -- don't forget to limit the ping count.

$ cat ping-list.yml
# Simple ad hoc gateway ping. Prefer proper monitoring.

This is do-able as I just wrote a module for my current employer that does just this. The module needs to be cleaned up but I’ll see if they are willing to opensource it. ← could be a while… The module works by grabbing each interface’s IP and CIDR Mask. I then process the routing table to get a list of gateways I should be able to hit per interface. I then run the ping command to all the gateways recording the success or failure. For interfaces that don’t have any routes, I created a second test where it generates the first two host IPs in the network and it pings them. If one of those return successful the module considers it as a pass. All pings and data are collected and processed before a call to module.fail is called so I can include all of the test results in the output. This took about 2 days to write and another half day testing across several distros to give you an idea if you wanted to attempt yourself.

-Chris