Ping 1000 network devices
import ping3
devices = [ "192.168.1.1", "192.168.1.2", ... "192.168.1.1000" ] for device in devices: response_time = ping3.ping(device) if response_time is not None: print(f"{device} is reachable (response time: {response_time} ms)") else: print(f"{device} is unreachable") In this example, we create a list of 1000 IP addresses representing the devices we want to ping. We then loop through each device and use the `ping` function from the `ping3` library to send an ICMP echo request to each device.If the device responds, the `ping` function will return the response time in milliseconds. We print a message indicating that the device is reachable and display the response time. If the device does not respond, the `ping` function will return `None`, and we print a message indicating that the device is unreachable.
Note that you need to install the `ping3` library before running this code. You can install it using `pip` by running `pip install ping3`.
Comments
Post a Comment