Skip to content

Instantly share code, notes, and snippets.

@0xcrypto
Last active October 10, 2019 06:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 0xcrypto/154c0252fa6f702dea06df58547cf602 to your computer and use it in GitHub Desktop.
Save 0xcrypto/154c0252fa6f702dea06df58547cf602 to your computer and use it in GitHub Desktop.
def ping(ip):
# database change value of ip to processing here
if(not os.system("ping %s" % ip)):
# database change value of ip to up here
return True
# database change value of ip to down here
return False
def somewhere_in_the_code():
...
list_of_threads = []
for ip in ip_list:
list_of_threads.append(
threading.Thread(target=ping, args=(ip,))
)
while(True):
for threads in list_of_threads:
threads.start()
threads.join()
time.sleep(2)
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment