Main Content

Parallel Pinging, using Python Threads or Expect spawn lists

Archive - Originally posted on "The Horse's Mouth" - 2009-11-02 11:03:45 - Graham Ellis

Ping is a very useful command to use within scripts for checking the presence (or absence) of a live system on our network, or indeed on the Internet. However, there are subtle differences in the format of its report on different operating system flavors, so any code that you write that needs to analyse the results may need to be tuned when you re-host.

Here are some similar (but different!) ping responses, by way of example:



earth-wind-and-fire:~ grahamellis$ ping -q -c2 192.168.200.65
PING 192.168.200.65 (192.168.200.65): 56 data bytes

--- 192.168.200.65 ping statistics ---
2 packets transmitted, 0 packets received, 100% packet loss
earth-wind-and-fire:~ grahamellis$



-bash-3.2$ ping -q -c2 192.168.200.65
PING 192.168.200.65 (192.168.200.65) 56(84) bytes of data.

--- 192.168.200.65 ping statistics ---
2 packets transmitted, 0 received, 100% packet loss, time 999ms

-bash-3.2$



wellcouk@tornado:~/public_html$ ping -q -c2 192.168.200.65
PING 192.168.200.65 (192.168.200.65): 56 octets data

--- 192.168.200.65 ping statistics ---
2 packets transmitted, 0 packets received, 100% packet loss
wellcouk@tornado:~/public_html$



Many people find our Python scripts alive, kicking, fullrange and fullandfast useful - both as demonstrations of threading in Python and for live system checking but you do need to change the scripts if you use them to reflect the OS on which you're running!

The same need to tailor applies to Tcl / Expect scripts such as our basic expect example, our Tcl /expect parallel ping examples - we have them already modified for Caldera and Red Hat. Finally, ours Tk example for Linux may also need a little tailoring depending on your Linux flavor!