示例#1
0
def get_pingdom_results():
    all_results = []
    pingdom_results = {}
    for account in pingdom_keys:
        result_json = json.loads(get_data('pingdom_'+account)) # Load all the pingdom keys as json and store them in the all_results list
        all_results.append(result_json['checks'])
    pingdom_results['pingdom_up'] = 0
    pingdom_results['pingdom_down'] = 0
    pingdom_results['pingdom_paused'] = 0
    pingdom_results['total_pingdom_accounts'] = int(get_data('total_pingdom_accounts'))
    pingdom_results['failed_pingdom'] = int(get_data('failed_pingdom'))
    pingdom_results['working_pingdom'] = pingdom_results['total_pingdom_accounts']-pingdom_results['failed_pingdom']
    pingdom_results['working_percentage'] = int(float(pingdom_results['working_pingdom'])/float(pingdom_results['total_pingdom_accounts'])*100)
    pingdom_results['checks'] = chain_results(all_results) # Chain all the results together to be returned for the warboard
    pingdom_results['total_checks'] = len(pingdom_results['checks'])
    for check in pingdom_results['checks']: # Categorize all the checks as up/down etc
        if check['type'] == 'httpcustom':
            check['type'] = 'custom'
        if check['status'] == 'up':
            pingdom_results['pingdom_up'] +=1
        elif check['status'] == 'down':
            pingdom_results['pingdom_down'] +=1
        elif check['status'] == 'paused':
            pingdom_results['pingdom_paused'] +=1
        elif check['status'] == 'unknown':
            check['status'] = 'paused'
            check['lastresponsetime'] = 0
    pingdom_results['down_percent'] = math.ceil(100*float(pingdom_results['pingdom_down'])/float(pingdom_results['total_checks']))
    pingdom_results['paused_percent'] = math.ceil(100*float(pingdom_results['pingdom_paused'])/float(pingdom_results['total_checks']))
    pingdom_results['up_percent'] = 100-pingdom_results['down_percent']-pingdom_results['paused_percent']
    return(pingdom_results)
示例#2
0
def get_pingdom_results():
    all_results = []
    pingdom_results = {}
    for account in pingdom_keys:
        result_json = json.loads(get_data('pingdom_'+account)) # Load all the pingdom keys as json and store them in the all_results list
        all_results.append(result_json['checks'])
    pingdom_results['pingdom_up'] = 0
    pingdom_results['pingdom_down'] = 0
    pingdom_results['pingdom_paused'] = 0
    pingdom_results['total_pingdom_accounts'] = int(get_data('total_pingdom_accounts'))
    pingdom_results['failed_pingdom'] = int(get_data('failed_pingdom'))
    pingdom_results['working_pingdom'] = pingdom_results['total_pingdom_accounts']-pingdom_results['failed_pingdom']
    pingdom_results['working_percentage'] = int(float(pingdom_results['working_pingdom'])/float(pingdom_results['total_pingdom_accounts'])*100)
    pingdom_results['checks'] = chain_results(all_results) # Chain all the results together to be returned for the warboard
    pingdom_results['total_checks'] = len(pingdom_results['checks'])
    for check in pingdom_results['checks']: # Categorize all the checks as up/down etc
        check['name'] = check['name'][:40] # Limit pingdom server names to 40 characters to not break the warboard layout
        if check['type'] == 'httpcustom':
            check['type'] = 'custom'
        if check['status'] == 'up':
            pingdom_results['pingdom_up'] +=1
        elif check['status'] == 'down':
            pingdom_results['pingdom_down'] +=1
        elif check['status'] == 'paused':
            pingdom_results['pingdom_paused'] +=1
            if not 'lastresponsetime' in check:
                check['lastresponsetime'] = 0
        elif check['status'] == 'unknown':
            check['status'] = 'paused'
            check['lastresponsetime'] = 0
    pingdom_results['down_percent'] = math.ceil(100*float(pingdom_results['pingdom_down'])/float(pingdom_results['total_checks']))
    pingdom_results['paused_percent'] = math.ceil(100*float(pingdom_results['pingdom_paused'])/float(pingdom_results['total_checks']))
    pingdom_results['up_percent'] = 100-pingdom_results['down_percent']-pingdom_results['paused_percent']
    return(pingdom_results)
示例#3
0
def get_newrelic_results():
    all_results = []
    newrelic_results = {}
    for account in newrelic_keys:
        result_json = json.loads(get_data('newrelic_'+account)) # Pull the NR data from redis load it as json and append to a list
        all_results.append(result_json['servers'])
    newrelic_results['total_newrelic_accounts'] = int(get_data('total_newrelic_accounts'))
    newrelic_results['failed_newrelic'] = int(get_data('failed_newrelic'))
    newrelic_results['working_newrelic'] = newrelic_results['total_newrelic_accounts']-newrelic_results['failed_newrelic']
    newrelic_results['working_percentage'] = int(float(newrelic_results['working_newrelic'])/float(newrelic_results['total_newrelic_accounts'])*100)
    newrelic_results['checks'] = chain_results(all_results) # Store all the nr results as 1 chained list
    newrelic_results['total_checks'] = len(newrelic_results['checks'])
    newrelic_results['green'] = 0
    newrelic_results['red'] = 0
    newrelic_results['orange'] = 0
    newrelic_results['blue'] = 0
    for check in newrelic_results['checks']: # Categorize all the checks as up/down and use the highest metric for each item as the thing we order by
        check['name'] = check['name'][:30] # Limit newrelic server names to 30 characters to not break the warboard layout
        if check['reporting'] == True:
            check['orderby'] = max(check['summary']['cpu'], check['summary']['memory'], check['summary']['fullest_disk'], check['summary']['disk_io'])
            if check['health_status'] == 'green':
                newrelic_results['green'] +=1
            elif check['health_status'] == 'orange':
                newrelic_results['orange'] +=1
            elif check['health_status'] == 'red':
                newrelic_results['red'] +=1
        elif check['reporting'] == False:
            check['orderby'] = 0
            check['health_status'] = 'blue'
            newrelic_results['blue'] +=1
    newrelic_results['red_percent'] = math.ceil(100*float(newrelic_results['red'])/float(newrelic_results['total_checks']))
    newrelic_results['green_percent'] = math.ceil(100*float(newrelic_results['green'])/float(newrelic_results['total_checks']))
    newrelic_results['orange_percent'] = math.ceil(100*float(newrelic_results['orange'])/float(newrelic_results['total_checks']))
    newrelic_results['blue_percent'] = 100-newrelic_results['red_percent']-newrelic_results['green_percent']-newrelic_results['orange_percent']
    if newrelic_results['blue_percent'] < 0:
        newrelic_results['green_percent'] = newrelic_results['green_percent']-abs(newrelic_results['blue_percent'])
    return(newrelic_results)