def network_parents(request): """ List of hosts that are network parents """ c = {} c['messages'] = [] authuser = request.GET.get('contact_name', None) livestatus = utils.livestatus(request) fields = "name childs state scheduled_downtime_depth address last_check last_state_change acknowledged downtimes services services_with_info".split() hosts = utils.get_hosts(request, 'Filter: childs !=', fields=fields, **request.GET) host_dict = {} map(lambda x: host_dict.__setitem__(x['name'], x), hosts) c['hosts'] = [] for i in hosts: if i['childs']: c['hosts'].append(i) ok = 0 crit = 0 i['child_hosts'] = [] for x in i['childs']: i['child_hosts'].append(host_dict[x]) if host_dict[x]['state'] == 0: ok += 1 else: crit += 1 total = float(len(i['childs'])) i['health'] = float(ok) / total * 100.0 i['percent_ok'] = ok / total * 100 i['percent_crit'] = crit / total * 100 return render_to_response('status_parents.html', c, context_instance=RequestContext(request))
def network_parents(request): """ List of hosts that are network parents """ c = {} c['messages'] = [] hosts = utils.get_hosts(request, **request.GET) host_dict = {} map(lambda x: host_dict.__setitem__(x['name'], x), hosts) c['hosts'] = [] for i in hosts: if i['childs']: c['hosts'].append(i) ok = 0 crit = 0 i['child_hosts'] = [] for x in i['childs']: i['child_hosts'].append(host_dict[x]) if host_dict[x]['state'] == 0: ok += 1 else: crit += 1 total = float(len(i['childs'])) i['health'] = float(ok) / total * 100.0 i['percent_ok'] = ok / total * 100 i['percent_crit'] = crit / total * 100 return render_to_response('status_parents.html', c, context_instance=RequestContext(request))
def hosts(request): c = {} c['messages'] = [] c['errors'] = [] c['hosts'] = utils.get_hosts(request, **request.GET) c['host_name'] = request.GET.get('detail', None) return render_to_response('status_host.html', c, context_instance=RequestContext(request))
def dashboard(request): # Get statistics c = adagios.status.utils.get_statistics(request) c['messages'] = [] c['errors'] = [] c['host_problems'] = utils.get_hosts(request, unhandled=True, **request.GET) # Service problems c['service_problems'] = utils.get_services(request, unhandled=True, **request.GET) # Sort problems by state and last_check as secondary sort field c['service_problems'].sort( reverse=True, cmp=lambda a, b: cmp(a['last_check'], b['last_check'])) c['service_problems'].sort(reverse=True, cmp=lambda a, b: cmp(a['state'], b['state'])) return render_to_response('status_dashboard.html', c, context_instance=RequestContext(request))
def network_parents(request): """ List of hosts that are network parents """ c = {} c['messages'] = [] hosts = utils.get_hosts(request, **request.GET) host_dict = {} list(map(lambda x: host_dict.__setitem__(x['name'], x), hosts)) c['hosts'] = [] for i in hosts: if i['childs']: c['hosts'].append(i) ok = 0 crit = 0 i['child_hosts'] = [] for x in i['childs']: i['child_hosts'].append(host_dict[x]) if host_dict[x]['state'] == 0: ok += 1 else: crit += 1 total = float(len(i['childs'])) i['health'] = float(ok) / total * 100.0 i['percent_ok'] = ok / total * 100 i['percent_crit'] = crit / total * 100 return render_to_response('status_parents.html', c, context_instance=RequestContext(request))
def status_host(request): c = {} c['messages'] = [] c['errors'] = [] c['hosts'] = utils.get_hosts(request, **request.GET) c['host_name'] = request.GET.get('detail', None) return render_to_response('status_host.html', c, context_instance=RequestContext(request))
def problems(request): c = {} c['messages'] = [] c['errors'] = [] search_filter = request.GET.copy() if 'state__isnot' not in search_filter and 'state' not in search_filter: search_filter['state__isnot'] = '0' c['hosts'] = utils.get_hosts(request, **search_filter) c['services'] = utils.get_services(request, **search_filter) return render_to_response('status_problems.html', c, context_instance=RequestContext(request))
def dashboard(request): # Get statistics c = adagios.status.utils.get_statistics(request) c['messages'] = [] c['errors'] = [] all_down_hosts = utils.get_hosts(request, state__isnot='0', **request.GET) hostnames_that_are_down = map(lambda x: x.get('name'), all_down_hosts) # Discover network outages, # Remove acknowledgements and also all hosts where all parent hosts are # down c['host_problems'] = [] # Unhandled host problems c['network_problems'] = [] # Network outages for i in all_down_hosts: if i.get('acknowledged') != 0: continue if i.get('scheduled_downtime_depth') != 0: continue # Do nothing if parent of this host is also down for parent in i.get('parents'): if parent in hostnames_that_are_down: parent_is_down = True break else: parent_is_down = False if parent_is_down == True: continue # If host has network childs, put them in the network outages box if i.get('childs') == []: c['host_problems'].append(i) else: c['network_problems'].append(i) # c['hosts'] = c['network_problems'] + c['host_problems'] # Service problems c['service_problems'] = utils.get_services(request, state__isnot="0", acknowledged="0", scheduled_downtime_depth="0", host_state="0", **request.GET) # Sort problems by state and last_check as secondary sort field c['service_problems'].sort( reverse=True, cmp=lambda a, b: cmp(a['last_check'], b['last_check'])) c['service_problems'].sort(reverse=True, cmp=lambda a, b: cmp(a['state'], b['state'])) return render_to_response('status_dashboard.html', c, context_instance=RequestContext(request))
def dashboard(request): # Get statistics c = adagios.status.utils.get_statistics(request) c['messages'] = [] c['errors'] = [] all_down_hosts = utils.get_hosts(request, state__isnot='0', **request.GET) hostnames_that_are_down = map(lambda x: x.get('name'), all_down_hosts) # Discover network outages, # Remove acknowledgements and also all hosts where all parent hosts are # down c['host_problems'] = [] # Unhandled host problems c['network_problems'] = [] # Network outages for i in all_down_hosts: if i.get('acknowledged') != 0: continue if i.get('scheduled_downtime_depth') != 0: continue # Do nothing if parent of this host is also down for parent in i.get('parents'): if parent in hostnames_that_are_down: parent_is_down = True break else: parent_is_down = False if parent_is_down == True: continue # If host has network childs, put them in the network outages box if i.get('childs') == []: c['host_problems'].append(i) else: c['network_problems'].append(i) # c['hosts'] = c['network_problems'] + c['host_problems'] # Service problems c['service_problems'] = utils.get_services(request, state__isnot="0", acknowledged="0", scheduled_downtime_depth="0", host_state="0", **request.GET ) # Sort problems by state and last_check as secondary sort field c['service_problems'].sort( reverse=True, cmp=lambda a, b: cmp(a['last_check'], b['last_check'])) c['service_problems'].sort( reverse=True, cmp=lambda a, b: cmp(a['state'], b['state'])) return render_to_response('status_dashboard.html', c, context_instance=RequestContext(request))
def dashboard(request): # Get statistics c = adagios.status.utils.get_statistics(request) c['messages'] = [] c['errors'] = [] c['host_problems'] = utils.get_hosts(request, state='1', unhandled='', **request.GET) # Service problems c['service_problems'] = utils.get_services(request, host_state="0", unhandled='', **request.GET) # Sort problems by state and last_check as secondary sort field c['service_problems'].sort( reverse=True, cmp=lambda a, b: cmp(a['last_check'], b['last_check'])) c['service_problems'].sort( reverse=True, cmp=lambda a, b: cmp(a['state'], b['state'])) return render_to_response('status_dashboard.html', c, context_instance=RequestContext(request))