Last active
April 24, 2018 02:28
-
-
Save sandromello/6914a0035cb1110ba74e2e51f6b3a6f1 to your computer and use it in GitHub Desktop.
Check liveness
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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