1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284
|
<!DOCTYPE html>
<html>
<head>
<title>{{ queue_name }} Charts</title>
<link type="text/css" rel="stylesheet" href="/stylesheets/main.css" />
<link type="text/css" rel="stylesheet" href="/stylesheets/charts.css" />
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load('visualization', '1.0', {'packages':['corechart']});
google.setOnLoadCallback(function () {
function secondsToString(seconds) {
var oneSecond = 1;
var oneMinute = 60;
var oneHour = oneMinute * 60;
var oneDay = oneHour * 24;
var oneYear = oneDay * 365.25;
var unitArray = [
[oneYear, "year"],
[oneDay, "day"],
[oneHour, "hour"],
[oneMinute, "minute"],
[oneSecond, "second"],
];
var result = "";
for (var i = 0; i < unitArray.length; i++) {
var unit = unitArray[i][0];
if (seconds >= unit) {
if (result !== "") {
result += " ";
}
var name = unitArray[i][1];
var number = Math.floor(seconds/unit);
result += number + " " + name + (number > 1 ? "s" : "");
seconds %= unit;
}
}
if (result === "") {
return "0 seconds";
}
return result;
}
var data, chart, options;
var timeString = new Date({{ timestamp }} * 1000).toString();
var timestampDiv = document.getElementById("timestamp");
timestampDiv.innerHTML = "Viewing from " + timeString;
options = {
legend: {position: "top"},
hAxis: {
title: "{{ time_unit_name|capfirst }} Ago",
direction: -1,
viewWindow: {
min: {{ seconds_ago_min }} / {{ time_unit }},
max: {{ seconds_ago_max }} / {{ time_unit }},
},
gridlines: {
count: 9,
},
},
vAxis: {
viewWindow: {min: 0 },
},
lineWidth: 3,
};
// CHART 1
options.colors = ["green", "red", "orange"];
data = new google.visualization.DataTable();
data.addColumn("number", "<time>");
data.addColumn("number", "Patches Completed");
data.addColumn({type: "string", role: "tooltip"});
data.addColumn("number", "Patches Waiting");
data.addColumn({type: "string", role: "tooltip"});
data.addColumn("number", "Bots (visible to server)");
data.addColumn({type: "string", role: "tooltip"});
data.addRows([
{% for queue_datum in queue_data %}
[
{{ queue_datum.seconds_ago }} / {{ time_unit }},
{{ queue_datum.patches_completed }},
"Patches Completed: " + {{ queue_datum.patches_completed }} + "\n" + secondsToString({{ queue_datum.seconds_ago }}) + " ago",
{{ queue_datum.patches_waiting }},
"Patches Waiting: " + {{ queue_datum.patches_waiting }} + "\n" + secondsToString({{ queue_datum.seconds_ago }}) + " ago",
{{ queue_datum.bots_seen }},
"Bots (visible to server): " + {{ queue_datum.bots_seen }} + "\n" + secondsToString({{ queue_datum.seconds_ago }}) + " ago",
],
{% endfor %}
]);
chart = new google.visualization.LineChart(document.getElementById('chart1'));
chart.draw(data, options);
// CHART 2
options.colors = ["blue", "purple"];
data = new google.visualization.DataTable();
data.addColumn("number", "<time>");
data.addColumn("number", "Status Updates");
data.addColumn({type: "string", role: "tooltip"});
data.addColumn("number", "Patch Retries");
data.addColumn({type: "string", role: "tooltip"});
data.addRows([
{% for queue_datum in queue_data %}
[
{{ queue_datum.seconds_ago }} / {{ time_unit }},
{{ queue_datum.status_update_count }},
"Status Updates: " + {{ queue_datum.status_update_count }} + "\n" + secondsToString({{ queue_datum.seconds_ago }}) + " ago",
{{ queue_datum.patch_retry_count }},
"Patch Retries: " + {{ queue_datum.patch_retry_count }} + "\n" + secondsToString({{ queue_datum.seconds_ago }}) + " ago",
],
{% endfor %}
]);
chart = new google.visualization.LineChart(document.getElementById('chart2'));
chart.draw(data, options);
// CHART 3
options.colors = ["brown"];
options.vAxis.title = "Minutes";
data = new google.visualization.DataTable();
data.addColumn("number", "<time>");
data.addColumn("number", "Patch Processing Times");
data.addColumn({type: "string", role: "tooltip"});
data.addColumn({type: "number", role: "interval"});
data.addColumn({type: "number", role: "interval"});
data.addRows([
{% for queue_datum in queue_data %}
[
{{ queue_datum.seconds_ago }} / {{ time_unit }},
{{ queue_datum.patch_processing_med }} / 60,
"Patch Processing Times\nMax: " + secondsToString({{ queue_datum.patch_processing_max }}) + "\nMedian: " + secondsToString({{ queue_datum.patch_processing_med }}) + "\nMin: " + secondsToString({{ queue_datum.patch_processing_min }}) + "\n" + secondsToString({{ queue_datum.seconds_ago }}) + " ago",
{{ queue_datum.patch_processing_min }} / 60,
{{ queue_datum.patch_processing_max }} / 60,
],
{% endfor %}
]);
chart = new google.visualization.LineChart(document.getElementById('chart3'));
chart.draw(data, options);
// CHART 4
options.colors = ["red"];
data = new google.visualization.DataTable();
data.addColumn("number", "<time>");
data.addColumn("number", "Patch Waiting Times");
data.addColumn({type: "string", role: "tooltip"});
data.addColumn({type: "number", role: "interval"});
data.addColumn({type: "number", role: "interval"});
data.addRows([
{% for queue_datum in queue_data %}
[
{{ queue_datum.seconds_ago }} / {{ time_unit }},
{{ queue_datum.patch_waiting_med }} / 60,
"Patch Waiting Times\nMax: " + secondsToString({{ queue_datum.patch_waiting_max }}) + "\nMedian: " + secondsToString({{ queue_datum.patch_waiting_med }}) + "\nMin: " + secondsToString({{ queue_datum.patch_waiting_min }}) + "\n" + secondsToString({{ queue_datum.seconds_ago }}) + " ago",
{{ queue_datum.patch_waiting_min }} / 60,
{{ queue_datum.patch_waiting_max }} / 60,
],
{% endfor %}
]);
chart = new google.visualization.LineChart(document.getElementById('chart4'));
chart.draw(data, options);
function postPatchLink (selection) {
if (selection.length > 0 && selection[0].row !== undefined) {
var attachmentIdArray = [{% for patch_datum in patch_data %}{{ patch_datum.attachment_id }}, {% endfor %}];
var attachmentId = attachmentIdArray[selection[0].row];
var aTag = document.getElementById("selectedPatch");
aTag.innerHTML = aTag.href = "//" + window.location.host + "/patch/" + attachmentId;
}
}
// CHART 5
options.colors = ["brown", "red"];
options.hAxis.title = "{{ time_unit_name|capfirst }} Ago";
options.hAxis.viewWindow.min = {{ seconds_ago_min }} / {{ time_unit }};
options.hAxis.viewWindow.max = {{ seconds_ago_max }} / {{ time_unit }};
delete options.lineWidth;
data = new google.visualization.DataTable();
data.addColumn("number", "<time>");
data.addColumn("number", "Process Duration");
data.addColumn({type: "string", role: "tooltip"});
data.addColumn("number", "Wait Duration");
data.addColumn({type: "string", role: "tooltip"});
data.addRows([
{% for patch_datum in patch_data %}
[
{{ patch_datum.seconds_ago }} / {{ time_unit }},
{{ patch_datum.process_duration }},
"Patch {{ patch_datum.attachment_id }}\n" + secondsToString({{ patch_datum.seconds_ago }}) + " ago",
{{ patch_datum.wait_duration }},
"Patch {{ patch_datum.attachment_id }}\n" + secondsToString({{ patch_datum.seconds_ago }}) + " ago",
],
{% endfor %}
]);
chart = new google.visualization.ScatterChart(document.getElementById('chart5'));
var chart5 = chart;
google.visualization.events.addListener(chart, "select", function () {postPatchLink(chart5.getSelection());});
chart.draw(data, options);
// CHART 6
options.colors = ["blue", "purple"];
delete options.vAxis.title;
data = new google.visualization.DataTable();
data.addColumn("number", "<time>");
data.addColumn("number", "Status Updates");
data.addColumn({type: "string", role: "tooltip"});
data.addColumn("number", "Retries");
data.addColumn({type: "string", role: "tooltip"});
data.addRows([
{% for patch_datum in patch_data %}
[
{{ patch_datum.seconds_ago }} / {{ time_unit }},
{{ patch_datum.status_update_count }},
"Patch {{ patch_datum.attachment_id }}\n" + secondsToString({{ patch_datum.seconds_ago }}) + " ago",
{{ patch_datum.retry_count }},
"Patch {{ patch_datum.attachment_id }}\n" + secondsToString({{ patch_datum.seconds_ago }}) + " ago",
],
{% endfor %}
]);
chart = new google.visualization.ScatterChart(document.getElementById('chart6'));
var chart6 = chart;
google.visualization.events.addListener(chart, "select", function () {postPatchLink(chart6.getSelection());});
chart.draw(data, options);
});
function setURLParameter (parameterName, newValue) {
var split;
split = window.location.href.split("?");
var url, parameterArray;
url = split[0];
if (split.length > 1) {
parameterArray = split[1].split("&");
} else {
parameterArray = [];
}
var setParameter = false;
for (var i = 0; i < parameterArray.length; i++) {
var currentParameterName = decodeURIComponent(parameterArray[i].split("=")[0]);
if (currentParameterName === parameterName) {
parameterArray[i] = encodeURIComponent(parameterName) + "=" + encodeURIComponent(newValue);
setParameter = true;
break;
}
}
if (!setParameter) {
parameterArray.push(encodeURIComponent(parameterName) + "=" + encodeURIComponent(newValue));
}console.log(parameterArray);
window.location.href = url + "?" + parameterArray.join("&");
}
</script>
</head>
<body>
<div class="choices">
{% for single_queue_name in all_queue_names %}
{% if single_queue_name == queue_name %}
{{ queue_name }}
{% else %}
{{ single_queue_name|force_escape|queue_charts_link:single_queue_name|safe }}
{% endif %}
{% if not forloop.last %} | {% endif %}
{% endfor %}
</div>
<h1>{{ queue_name }} Charts</h1>
<div>[{{ queue_name|force_escape|queue_status_link:"status"|safe }}]</div>
<div id="timestamp"></div>
<div class="choices">Viewing range:
{% for view_range_choice in view_range_choices %}
{% if view_range_choice.view_range == view_range %}
{{ view_range_choice.name }}
{% else %}
<a href="javascript:setURLParameter('view_range', {{ view_range_choice.view_range }})">{{ view_range_choice.name }}</a>
{% endif %}
{% if not forloop.last %} | {% endif %}
{% endfor %}
</div>
<div class="chart" id="chart1"></div>
<div class="chart" id="chart2"></div>
<div class="chart" id="chart3"></div>
<div class="chart" id="chart4"></div>
<div class="chart" id="chart5"></div>
<div class="chart" id="chart6"></div>
Selected patch: <a id="selectedPatch">(None)</div>
</body>
</html>
|