Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. while(not time.sleep(hc_interval)):
  2.  
  3. #
  4. # Set the stdout/stderr variables; we'll need the stdout one for the loop
  5. # to make sure the route is or isn't being sent
  6. result = subprocess.Popen(route_check, shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
  7. stdout,stderr = result.communicate()
  8.  
  9. if isOpen(server, httpport) and urllib3.PoolManager().request('GET', url).status == 200:
  10. if not stdout.decode('utf-8'): # service is down
  11. subprocess.call(route_add, shell=True)
  12. else:
  13. if stdout.decode('utf-8'): # service is up
  14. subprocess.call(route_del, shell=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement