Skip to content

Instantly share code, notes, and snippets.

@sandromello
Last active April 24, 2018 02:28
Show Gist options
  • Save sandromello/6914a0035cb1110ba74e2e51f6b3a6f1 to your computer and use it in GitHub Desktop.
Save sandromello/6914a0035cb1110ba74e2e51f6b3a6f1 to your computer and use it in GitHub Desktop.
Check liveness
#!/usr/bin/env python
# for ns in $(kubectl get ns |grep -i ctaf |awk {'print $1'}); do python -W ignore check_ingress.py host01 host02; done
import requests
import sys
def has_via(url):
r = requests.get(url, verify=False, timeout=1)
return r.headers.get('Via')
if __name__ == '__main__':
for addr in sys.argv[1:]:
try:
if has_via('https://'+addr):
print('ALIVE: https://' + addr)
else:
print('DEAD: https://' + addr)
except Exception:
print('TIMEOUT: https://' + addr)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment