Last active
August 29, 2015 14:06
-
-
Save lavagetto/002a07f94228ec77eb36 to your computer and use it in GitHub Desktop.
Check pybal and scap for inconsistencies
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
import requests | |
class bcolors: | |
OKGREEN = '\033[92m' | |
WARNING = '\033[93m' | |
FAIL = '\033[91m' | |
ENDC = '\033[0m' | |
# I use github as it is in general more stable than gitblit | |
dsh_groups = 'https://raw.githubusercontent.com/wikimedia/operations-puppet/production/files/dsh/group/mediawiki-installation' | |
pybal_base = 'https://noc.wikimedia.org/pybal/eqiad/' | |
r = requests.get(dsh_groups) | |
dsh_servers = [ l for l in r.text.split("\n") if l] | |
print("we have {} servers in the scap list".format(len(dsh_servers))) | |
for pool in ["apaches", "api", "hhvm_appservers", "rendering"]: | |
r = requests.get(pybal_base + pool) | |
for line in r.text.split("\n"): | |
try: | |
struct = eval(line) | |
except: | |
continue | |
if type(struct) != dict: | |
continue | |
hostname = struct['host'].split('.')[0] | |
if hostname not in dsh_servers: | |
if struct['enabled']: | |
print( | |
"{}Host {} is in pybal pool '{}', but NOT in the scap list!!{}".format( | |
bcolors.FAIL, hostname, pool, bcolors.ENDC | |
) | |
) | |
else: | |
print( | |
"{}Host {} is deactivated in pybal pool '{}' and NOT in the scap list!{}".format( | |
bcolors.WARNING, hostname, pool, bcolors.ENDC | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment