This is a simple module that can be used to check the ping reachability of the device. Script using this module can be used independently or as part of a larger application. Before we start using it, install it using the command “pip install pythonping”.
pip install pythonping
Below is our first program using pythonping module. It is a simple program that sends ICMP probes to the target machine.
from pythonping import ping
ping('1.1.1.1')
Output
Process finished with exit code 0
The program ran without any errors, but we could not see the output. That is because the program runs in silent mode. If we want to see the output of the ICMP probes sent and received, use verbose and set it to True.
from pythonping import ping
ping('1.1.1.1', verbose=True)
Output
Reply from 1.1.1.1, 29 bytes in 67.98ms
Reply from 1.1.1.1, 29 bytes in 104.35ms
Reply from 1.1.1.1, 29 bytes in 110.87ms
Reply from 1.1.1.1, 29 bytes in 108.5ms
Process finished with exit code 0