Skip to content

Commit

Permalink
mce: add bar chart sorting MCEs by status code
Browse files Browse the repository at this point in the history
Knowing what issues are most common is a useful statistic.

Signed-off-by: California Sullivan <[email protected]>
  • Loading branch information
clsulliv authored and alexjch committed Jul 12, 2019
1 parent 5fc1e49 commit 4167e27
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 4 deletions.
47 changes: 47 additions & 0 deletions telemetryui/telemetryui/static/js/mce.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,55 @@
rootObj.newChart(ctx, "bar", data, options);
}

function renderMCEStatus(ctx, labels, values){

var data = {
labels: labels,
datasets:[
{
label: "MCE counts by status",
data: values
}
]
};

var options = {
legend: { display: false },
title: {
display: true,
text: "MCE reports by status",
fontSize: 18
},
scales: {
yAxes: [{
scaleLabel: {
display: true,
labelString: "MCE count",
fontSize: 15,
fontStyle: "italic"
},
ticks: {
beginAtZero: true
}
}],
xAxes: [{
scaleLabel: {
display: true,
labelString: "Last 32 bits of status code",
fontSize: 15,
fontStyle: "italic"
},
barThickness: 15
}]
}
};

rootObj.newChart(ctx, "bar", data, options);
}

rootObj.renderMCEClass = renderMCEClass;
rootObj.renderMCEReports = renderMCEReports;
rootObj.renderMCEStatus = renderMCEStatus;
rootObj.parseMCEChartData = parseMCEChartData;
rootObj.renderOneChart = renderOneChart;
});
14 changes: 11 additions & 3 deletions telemetryui/telemetryui/templates/mce.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,13 @@ <h2>Top MCE</h2>
</table>
</div>
<div class="col-md-6" style="min-height: 500px;">
<canvas id="pie-classification" width="450" height="450"></canvas>
<canvas id="bar-reports-by-status" width="450" height="450"></canvas>
</div>
<div class="col-md-6" style="min-height: 500px;">
<canvas id="bar-reports" width="450" height="450"></canvas>
<canvas id="bar-reports-by-build" width="450" height="450"></canvas>
</div>
<div class="col-md-6" style="min-height: 500px;">
<canvas id="pie-classification" width="450" height="450"></canvas>
</div>

</div>
Expand Down Expand Up @@ -136,10 +139,15 @@ <h2>Top MCE</h2>
[{% for s in charts[0].record_stats %} "{{ s[1] }}", {% endfor %}]);
telemetryUI.renderMCEReports(
document.getElementById("bar-reports").getContext("2d"),
document.getElementById("bar-reports-by-build").getContext("2d"),
[{% for s in charts[1].record_stats %} "{{ s[0] }}", {% endfor %}],
[{% for s in charts[1].record_stats %} "{{ s[1] }}", {% endfor %}]);
telemetryUI.renderMCEStatus(
document.getElementById("bar-reports-by-status").getContext("2d"),
[{% for s in charts[2].record_stats %} "{{ s[0] }}", {% endfor %}],
[{% for s in charts[2].record_stats %} "{{ s[1] }}", {% endfor %}]);
var fullmce = {{ fullmce|safe }};
for (clas in fullmce){
telemetryUI.renderOneChart(document.getElementById("fullmce-chart-"+clas).getContext("2d"), telemetryUI.parseMCEChartData(clas, fullmce[clas]));
Expand Down
11 changes: 10 additions & 1 deletion telemetryui/telemetryui/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@ def mce():
maxcnt = 0
by_machine_id = {}
by_builds = {}
by_mce_status = {}
week_rec_map = {}
class_rec_map = {}
for record in records:
Expand All @@ -483,6 +484,13 @@ def mce():
by_machine_id[record.machine_id]["recordscnt"] += 1
by_builds.setdefault(record.build, 0)
by_builds[record.build] += 1
status_match = re.search('STATUS.*([A-Fa-f0-9]{8}) MCGSTATUS', record.payload)
if status_match:
status = status_match.group(1)
if status in by_mce_status:
by_mce_status[status] += 1
else:
by_mce_status[status] = 1
for machine_id in list(by_machine_id.keys()):
builds_cnt = by_machine_id[machine_id]["builds"]
maxcnt = max(list(builds_cnt.values()) + [maxcnt])
Expand All @@ -493,7 +501,8 @@ def mce():
})
top10.sort(key=lambda x: x["recordscnt"], reverse=True)
charts = [{'column': 'classification', 'record_stats': class_rec_map.items(), 'type': 'pie', 'width': 6},
{'column': 'build', 'record_stats': sorted(by_builds.items(), key=lambda x: x[0]), 'type': 'column', 'width': 6}]
{'column': 'build', 'record_stats': sorted(by_builds.items(), key=lambda x: x[0]), 'type': 'column', 'width': 6},
{'column': 'status', 'record_stats': sorted(by_mce_status.items(), key=lambda x: x[0]), 'type': 'column', 'width': 6}]
return render_template('mce.html', charts=charts, top10=top10, builds=sorted(by_builds.keys()), maxcnt=maxcnt, fullmce=week_rec_map)


Expand Down

0 comments on commit 4167e27

Please sign in to comment.