Esempio n. 1
0
def legacy_monitor(request, instrument):
    """
        For legacy instruments, show contents of old status page
        @param instrument: instrument name
    """
    instrument_id = get_object_or_404(Instrument, name=instrument.lower())
    update_url = reverse('dasmon:get_update', args=[instrument])
    legacy_update_url = reverse('dasmon:get_legacy_data', args=[instrument])
    breadcrumbs = view_util.get_monitor_breadcrumbs(instrument_id)
    kvp = legacy_status.get_ops_status(instrument_id)
    template_values = {'instrument': instrument.upper(),
                       'breadcrumbs':breadcrumbs,
                       'update_url': update_url,
                       'legacy_update_url': legacy_update_url,
                       'key_value_pairs':kvp}
    if len(kvp) == 0:
        inst_url = legacy_status.get_legacy_url(instrument_id)
        template_values['user_alert'] = ["Could not connect to <a href='%s'>%s</a>" % (inst_url, inst_url)]
    for group in kvp:
        for item in group['data']:
            if item['key'] in ['Proposal', 'Detector_Rate', 'Run', 'Status']:
                template_values[item['key']] = item['value']
    template_values = report.view_util.fill_template_values(request, **template_values)
    template_values = users.view_util.fill_template_values(request, **template_values)
    template_values = view_util.fill_template_values(request, **template_values)

    # Add most recent reduced data
    last_run = template_values['last_run']
    plot_dict = report.view_util.get_plot_template_dict(last_run, instrument=instrument, run_id=last_run.run_number)
    template_values.update(plot_dict)

    return render(request, 'dasmon/legacy_monitor.html', template_values)
Esempio n. 2
0
def live_monitor(request, instrument):
    """
        Display the list of current DASMON status
        @param instrument: instrument name
    """
    instrument_id = get_object_or_404(Instrument, name=instrument.lower())

    # Update URL
    update_url = reverse('dasmon:get_update', args=[instrument])
    pv_url = reverse('pvmon:get_update', args=[instrument])

    breadcrumbs = view_util.get_monitor_breadcrumbs(instrument_id)
    template_values = {'instrument': instrument.upper(),
                       'breadcrumbs':breadcrumbs,
                       'update_url': update_url,
                       'pv_url': pv_url,
                       'key_value_pairs': view_util.get_cached_variables(instrument_id, monitored_only=True),
                      }
    template_values = report.view_util.fill_template_values(request, **template_values)
    template_values = users.view_util.fill_template_values(request, **template_values)
    template_values = view_util.fill_template_values(request, **template_values)

    template_values['signals_url'] = reverse('dasmon:get_signal_table', args=[instrument])

    return render(request, 'dasmon/live_monitor.html', template_values)
Esempio n. 3
0
def live_runs(request, instrument):
    """
        Display the list of latest runs
        @param instrument: instrument name
    """
    # Get instrument
    instrument_id = get_object_or_404(Instrument, name=instrument.lower())

    # Update URL
    update_url = reverse('dasmon:get_update', args=[instrument])

    timeframe = 12
    if 'days' in request.GET:
        try:
            timeframe = int(request.GET['days']) * 24
        except:
            # If we can't cast to an integer, use default
            pass
    run_list, first_run, last_run = view_util.get_live_runs(instrument_id=instrument_id,
                                                            timeframe=timeframe)

    breadcrumbs = view_util.get_monitor_breadcrumbs(instrument_id)
    template_values = {'instrument':instrument.upper(),
                       'breadcrumbs':breadcrumbs,
                       'update_url':update_url,
                       'run_list':run_list,
                       'first_run_id':first_run,
                       'last_run_id': last_run
                      }
    template_values = report.view_util.fill_template_values(request, **template_values)
    template_values = users.view_util.fill_template_values(request, **template_values)
    template_values = view_util.fill_template_values(request, **template_values)

    return render(request, 'dasmon/live_runs.html', template_values)
Esempio n. 4
0
def diagnostics(request, instrument):
    """
        Diagnose the health of an instrument
        @param instrument: instrument name
    """
    # Get instrument
    instrument_id = get_object_or_404(Instrument, name=instrument.lower())

    # Workflow Manager
    wf_diag = view_util.workflow_diagnostics()
    # Post-processing
    red_diag = view_util.postprocessing_diagnostics()

    breadcrumbs = view_util.get_monitor_breadcrumbs(instrument_id, 'diagnostics')
    template_values = {'instrument':instrument.upper(),
                       'breadcrumbs':breadcrumbs,
                      }
    template_values = report.view_util.fill_template_values(request, **template_values)
    template_values = users.view_util.fill_template_values(request, **template_values)
    template_values = view_util.fill_template_values(request, **template_values)

    actions = []
    if ActiveInstrument.objects.is_adara(instrument_id):
        # DASMON
        dasmon_diag = view_util.dasmon_diagnostics(instrument_id)
        template_values['dasmon_diagnostics'] = dasmon_diag
        # PVStreamer
        if ActiveInstrument.objects.has_pvstreamer(instrument_id):
            template_values['pv_diagnostics'] = view_util.pvstreamer_diagnostics(instrument_id)
        # PVSD
        if ActiveInstrument.objects.has_pvsd(instrument_id):
            template_values['pvsd_diagnostics'] = view_util.pvstreamer_diagnostics(instrument_id, process='pvsd')
        # Actions messages
        if dasmon_diag['dasmon_listener_warning'] \
            and wf_diag['dasmon_listener_warning']:
            actions.append("Multiple heartbeat message failures: ask Linux Support to restart dasmon_listener before proceeding")

    template_values['wf_diagnostics'] = wf_diag
    template_values['post_diagnostics'] = red_diag
    template_values['action_messages'] = actions

    notices = []
    for item in SiteNotification.objects.filter(is_active=True):
        notices.append(item.message)
    if len(notices) > 0:
        template_values['user_alert'] = notices

    return render(request, 'dasmon/diagnostics.html', template_values)
Esempio n. 5
0
def live_runs(request, instrument):
    """
        Display the list of latest runs
        @param instrument: instrument name
    """
    # Get instrument
    instrument_id = get_object_or_404(Instrument, name=instrument.lower())

    # Update URL
    update_url = reverse('dasmon:get_update', args=[instrument])

    timeframe = 12
    if 'days' in request.GET:
        try:
            timeframe = int(request.GET['days']) * 24
        except:
            # If we can't cast to an integer, use default
            pass
    # The format query string allows us to return json
    json_format = request.GET.get('format', 'html') == 'json'
    run_list, first_run, last_run = view_util.get_live_runs(instrument_id=instrument_id,
                                                            timeframe=timeframe,
                                                            as_html=not json_format)

    if json_format:
        data_info = dict(runs=run_list, instrument=instrument.upper())
        data_info = view_util.fill_template_values(request, **data_info)

        response = HttpResponse(json.dumps(data_info), content_type="application/json")
        response['Connection'] = 'close'
        response['Content-Length'] = len(response.content)
        return response

    breadcrumbs = view_util.get_monitor_breadcrumbs(instrument_id)
    template_values = {'instrument':instrument.upper(),
                       'breadcrumbs':breadcrumbs,
                       'update_url':update_url,
                       'run_list':run_list,
                       'first_run_id':first_run,
                       'last_run_id': last_run
                      }
    template_values = report.view_util.fill_template_values(request, **template_values)
    template_values = users.view_util.fill_template_values(request, **template_values)
    template_values = view_util.fill_template_values(request, **template_values)

    return render(request, 'dasmon/live_runs.html', template_values)