Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 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. service = stdout.decode('utf-8') # set the string to the ASCII output, if there is any
  9.  
  10. if isOpen(server, httpport) and urllib3.PoolManager().request('GET', url).status == 200:
  11. if not service: # service is down
  12. subprocess.call(route_add, shell=True)
  13. else:
  14. if service: # service is up
  15. subprocess.call(route_del, shell=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement