Example #1
0
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))
Example #2
0
def services(request):
    """ This view handles list of services  """
    c = {}
    c['messages'] = []
    c['errors'] = []
    fields = ['host_name', 'description', 'plugin_output', 'last_check', 'host_state', 'state', 'last_state_change', 'acknowledged', 'downtimes', 'host_downtimes', 'comments_with_info']
    c['services'] = utils.get_services(request,fields=fields,**request.GET)
    return render_to_response('status_services.html', c, context_instance = RequestContext(request))
Example #3
0
def services(request):
    """ This view handles list of services  """
    c = {}
    c['messages'] = []
    c['errors'] = []
    fields = ['host_name', 'description', 'plugin_output', 'last_check', 'host_state', 'state', 'last_state_change', 'acknowledged', 'downtimes', 'host_downtimes', 'comments_with_info']
    c['services'] = utils.get_services(request, fields=fields, **request.GET)
    return render_to_response('status_services.html', c, context_instance=RequestContext(request))
Example #4
0
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))
Example #5
0
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))
Example #6
0
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))
Example #7
0
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))
Example #8
0
def perfdata(request):
    """ Display a list of perfdata
    """
    c = {}
    c['messages'] = []
    c['errors'] = []
    fields = "host_name description perf_data state host_state scheduled_downtime_depth host_scheduled_downtime_depth host_acknowledged acknowledged downtimes host_downtimes".split()
    perfdata = utils.get_services(request, fields=fields, **request.GET)
    for i in perfdata:
        metrics = pynag.Utils.PerfData(i['perf_data']).metrics
        metrics = filter(lambda x: x.is_valid(), metrics)
        i['metrics'] = metrics

    c['perfdata'] = perfdata
    return render_to_response('status_perfdata.html', c, context_instance=RequestContext(request))
Example #9
0
def perfdata(request):
    """ Display a list of perfdata
    """
    c = {}
    c['messages'] = []
    c['errors'] = []
    fields = "host_name description perf_data state host_state scheduled_downtime_depth host_scheduled_downtime_depth host_acknowledged acknowledged downtimes host_downtimes".split()
    perfdata = utils.get_services(None, fields=fields, **request.GET)
    for i in perfdata:
        metrics = pynag.Utils.PerfData(i['perf_data']).metrics
        metrics = filter(lambda x: x.is_valid(), metrics)
        i['metrics'] = metrics

    c['perfdata'] = perfdata
    return render_to_response('status_perfdata.html', c, context_instance=RequestContext(request))
Example #10
0
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))