Can change to this then DeaD_EyE code work on Windows to,if someone try to run there.
privileged = os.getlogin() == 0A test of
async_ping
in icmplib and run in schedule way with use of schedule. from icmplib import async_ping import schedule import time import asyncio async def is_alive(address): host = await async_ping(address, count=4, interval=0.2) if host.is_alive: print(f'{host.address} is up!') print(host.packets_received) print(host.packet_loss) else: print(f'{host.address} is down!') # Do something here def check_run(): return asyncio.run(is_alive('python-forum.io')) schedule.every(10).seconds.do(check_run) while True: schedule.run_pending() time.sleep(1)
Output:λ python ping_sc.py
104.21.27.41 is up!
4
0.0
104.21.27.41 is up!
4
0.0
104.21.27.41 is up!
4
0.0
104.21.27.41 is up!
4
0.0