def testmonitor():
    endp_names = []
    for name in get_monitor_names():
        endp_names.append(name.endpoint)
    tests = get_tests_grouped()
    grouped = {}
    cols = {}
    for t in tests:
        if t.endpoint not in grouped:
            grouped[t.endpoint] = []
            cols[t.endpoint] = get_color(t.endpoint)
        if t.test_name not in grouped[t.endpoint]:
            grouped[t.endpoint].append(t.test_name)

    return render_template('dashboard/testmonitor.html',
                           link=config.link,
                           session=session,
                           curr=3,
                           tests=get_tests(),
                           endpoints=endp_names,
                           results=get_results(),
                           groups=grouped,
                           colors=cols,
                           res_current_version=get_res_current(config.version),
                           boxplot=get_boxplot(None))
Example #2
0
def get_boxplot_per_endpoint():
    """
    Creates a graph with the execution times per endpoint
    :return:
    """
    endpoints = [str(e.endpoint) for e in get_endpoints()]

    data = []
    for endpoint in endpoints:
        values = [c.execution_time for c in get_data_per_endpoint(endpoint)]
        if len(values) == 0:
            continue
        data.append(go.Box(
            x=values,
            name=endpoint,
            marker=dict(
                color=get_color(endpoint)
            )
        ))

    if len(data) == 0:
        return None

    layout = go.Layout(
        autosize=True,
        height=350 + 40 * len(endpoints),
        plot_bgcolor='rgba(249,249,249,1)',
        showlegend=False,
        title='Execution time for every endpoint',
        xaxis=dict(title='Execution time (ms)'),
        margin=go.Margin(
            l=200
        )
    )
    return plotly.offline.plot(go.Figure(data=data, layout=layout), output_type='div', show_link=False)
Example #3
0
def overview():
    colors = {}
    for result in get_times():
        colors[result.endpoint] = get_color(result.endpoint)
    return render_template('dashboard/measurement-overview.html', link=config.link, curr=2, times=get_times(),
                           colors=colors, access=get_last_accessed_times(), session=session, index=0,
                           is_admin=is_admin())
Example #4
0
def get_boxplot_per_version():
    """
    Creates a graph with the execution times per version
    :return:
    """
    versions = get_versions()

    if len(versions) == 0:
        return None

    data = []
    for v in versions:
        values = [c.execution_time for c in get_data_per_version(v.version)]
        data.append(go.Box(
            x=values,
            marker=dict(
                color=get_color(v.version)
            ),
            name="{0} {1}".format(v.version, v.startedUsingOn.strftime("%b %d %H:%M"))))

    layout = go.Layout(
        autosize=True,
        height=350 + 40 * len(versions),
        plot_bgcolor='rgba(249,249,249,1)',
        showlegend=False,
        title='Execution time for every version',
        xaxis=dict(title='Execution time (ms)'),
        yaxis=dict(autorange='reversed'),
        margin=go.Margin(
            l=200
        )
    )
    return plotly.offline.plot(go.Figure(data=data, layout=layout), output_type='div', show_link=False)
def get_time_per_user(end):
    users = [
        str(c.group_by)
        for c in get_endpoint_column_user_sorted(endpoint=end,
                                                 column=FunctionCall.group_by)
    ]
    form, selection = get_form(users)
    data = []
    for user in users:
        if selection == [] or user in selection:
            values = [
                str(c.execution_time) for c in get_all_measurement_per_column(
                    endpoint=end, column=FunctionCall.group_by, value=user)
            ]
            data.append(
                go.Box(x=values,
                       marker=dict(color=get_color(user)),
                       name='{0}  -'.format(user)))
    data.reverse()
    layout = go.Layout(autosize=True,
                       height=350 + 40 * len(data),
                       plot_bgcolor='rgba(249,249,249,1)',
                       showlegend=False,
                       title='Execution time for every user',
                       xaxis=dict(title='Execution time (ms)'),
                       yaxis=dict(title='User'))
    graph = plotly.offline.plot(go.Figure(data=data, layout=layout),
                                output_type='div',
                                show_link=False)
    return graph, form
def get_time_per_version(end, versions):
    data = []
    for v in versions:
        values = [
            str(c.execution_time) for c in get_all_measurement_per_column(
                endpoint=end, column=FunctionCall.version, value=v.version)
        ]

        data.append(
            go.Box(x=values,
                   marker=dict(color=get_color(end)),
                   name="{0} {1}".format(
                       v.version, v.startedUsingOn.strftime("%b %d %H:%M"))))

    layout = go.Layout(autosize=True,
                       height=350 + 40 * len(versions),
                       plot_bgcolor='rgba(249,249,249,1)',
                       showlegend=False,
                       title='Execution time for every version',
                       xaxis=dict(title='Execution time (ms)'),
                       yaxis=dict(title='Version', autorange='reversed'),
                       margin=go.Margin(l=200))
    return plotly.offline.plot(go.Figure(data=data, layout=layout),
                               output_type='div',
                               show_link=False)
def get_hits_per_hour(end):
    data = get_line_results(end)

    # Find the last date which contains data
    max_time = max([d.newTime for d in data])
    max_date = datetime.datetime.strptime(max_time, '%Y-%m-%d %H:%M:%S')
    max_date += datetime.timedelta(minutes=30)

    graph = [
        go.Bar(x=[d.newTime for d in data],
               y=[d.count for d in data],
               marker=dict(color=get_color(end)))
    ]

    layout = go.Layout(
        autosize=True,
        height=600,
        title='Number of hits per hour',
        plot_bgcolor='rgba(249,249,249,1)',
        showlegend=False,
        xaxis=go.XAxis(title='Date',
                       range=[max_date - datetime.timedelta(days=2),
                              max_date]),
        yaxis=go.YAxis(title='Hits'))
    return plotly.offline.plot(go.Figure(data=graph, layout=layout),
                               output_type='div',
                               show_link=False)
def get_time_per_version_per_ip(end, versions):
    ip_data = {}
    data = [t.execution_time for t in get_all_measurement(end)]
    # compute the average for determining the default size
    average = math.sqrt(sum(data) / len(data)) / 1250
    for d in [str(c.ip) for c in get_endpoint_column(end, FunctionCall.ip)]:
        ip_data[d] = {}
        for v in versions:
            ip_data[d][v.version] = 0

    form, selection = get_form(ip_data)

    # fill the rows with data
    for d in get_endpoint_results(end, FunctionCall.ip):
        ip_data[str(d.ip)][d.version] = d.average

    db_data = [str(c.ip) for c in get_endpoint_column(end, FunctionCall.ip)]
    trace = []
    for d in db_data:  # iterate through all (unique) ip addresses
        if selection == [] or d in selection:
            data = []
            for version in versions:
                data.append(ip_data[d][version.version])

            hover_text = []
            for i in range(len(data)):
                hover_text.append('Version: ' + versions[i].version +
                                  '<br>Time: ' + formatter(data[i]))

            trace.append(
                go.Scatter(x=[
                    "{0}<br>{1}".format(
                        v.version, v.startedUsingOn.strftime("%b %d %H:%M"))
                    for v in versions
                ],
                           hovertext=hover_text,
                           y=[d] * len(versions),
                           name=d,
                           mode='markers',
                           marker=dict(color=[get_color(d)] * len(versions),
                                       size=[math.sqrt(d) for d in data],
                                       sizeref=average,
                                       sizemode='area')))

    layout = go.Layout(
        autosize=True,
        height=350 + 40 * len(trace),
        plot_bgcolor='rgba(249,249,249,1)',
        showlegend=False,
        title='Average execution time for every IP-address per version',
        xaxis=dict(title='Versions', type='category'),
        yaxis=dict(type='category', title='IP-addresses',
                   autorange='reversed'),
        margin=go.Margin(l=200, b=200))

    return plotly.offline.plot(go.Figure(data=trace, layout=layout),
                               output_type='div',
                               show_link=False), form
Example #9
0
def get_stacked_bar():
    data = get_reqs_endpoint_day()

    if len(data) == 0:
        return None

    labels = []
    endpoints = []
    # find labels and endpoints
    for d in data:
        if d.newTime not in labels:
            labels.append(d.newTime)
        if d.endpoint not in endpoints:
            endpoints.append(d.endpoint)
    labels.sort(reverse=True)

    # create dictionary. graph_data is in the form of: graph_data[label][endpoint]
    graph_data = {}
    for label in labels:
        graph_data[label] = {}
        for endpoint in endpoints:
            graph_data[label][endpoint] = 0

    # put data in dictionary
    for d in data:
        graph_data[d.newTime][d.endpoint] = d.cnt

    # create graph
    trace = []
    for endpoint in endpoints:

        lst = []
        for label in labels:
            lst.append(graph_data[label][endpoint])

        trace.append(go.Bar(
            y=labels,
            x=lst,
            name=endpoint,
            orientation='h',
            marker=dict(
                color=get_color(endpoint)
            )
        ))

    layout = go.Layout(
        barmode='stack',
        autosize=True,
        height=350 + 40 * len(labels),
        plot_bgcolor='rgba(249,249,249,1)',
        showlegend=True,
        title='Number of requests per endpoint per day',
        xaxis=dict(title='Number of requests'),
        yaxis=dict(autorange='reversed')
    )

    return plotly.offline.plot(go.Figure(data=trace, layout=layout), output_type='div', show_link=False)
Example #10
0
def rules():
    form = MonitorDashboard()
    values = {}
    all_rules = user_app.url_map.iter_rules()

    if request.method == 'POST' and form.validate():
        # Remove the monitor endpoints from the database
        reset_monitor_endpoints()

        for rule in user_app.url_map.iter_rules():
            # Remove existing wrappers
            original = getattr(user_app.view_functions[rule.endpoint],
                               'original', None)
            if original:
                user_app.view_functions[rule.endpoint] = original

        # request.form only contains checkboxes that are checked
        for data in request.form:
            if data.startswith('checkbox-'):
                endpoint = data.rsplit('-', 1)[1]
                update_monitor_rule(endpoint, value=True)
                rule = get_monitor_rule(endpoint)
                # Add wrappers to the existing functions
                user_app.view_functions[rule.endpoint] = track_performance(
                    user_app.view_functions[rule.endpoint], rule.endpoint)

    # store the result from the database in values (used for rendering)
    for rule in user_app.url_map.iter_rules():
        values[rule.endpoint] = get_monitor_rule(rule.endpoint).monitor

    la = get_last_accessed_times()

    # filter dashboard rules
    all_rules = [
        r for r in all_rules if not r.rule.startswith('/' + config.link)
        and not r.rule.startswith('/static-' + config.link)
    ]
    colors = {}
    for rule in all_rules:
        colors[rule.endpoint] = get_color(rule.endpoint)

    return render_template('dashboard/rules.html',
                           link=config.link,
                           curr=1,
                           rules=all_rules,
                           access=la,
                           form=form,
                           session=session,
                           values=values,
                           colors=colors)
Example #11
0
def page_boxplot_per_endpoint():
    colors = {}
    for result in get_times():
        colors[result.endpoint] = get_color(result.endpoint)
    return render_template('dashboard/measurement.html', link=config.link, curr=2, session=session, index=4,
                           graph=get_boxplot_per_endpoint())
Example #12
0
def page_number_of_requests_per_endpoint():
    colors = {}
    for result in get_times():
        colors[result.endpoint] = get_color(result.endpoint)
    return render_template('dashboard/measurement.html', link=config.link, curr=2, session=session, index=2,
                           graph=get_stacked_bar())
Example #13
0
def heatmap():
    colors = {}
    for result in get_times():
        colors[result.endpoint] = get_color(result.endpoint)
    return render_template('dashboard/measurement.html', link=config.link, curr=2, session=session, index=1,
                           graph=get_heatmap(end=None))