2019-09-12 22:15:42 +02:00
|
|
|
<!DOCTYPE html>
|
|
|
|
<html lang="en">
|
|
|
|
<head>
|
2019-10-19 01:55:54 +02:00
|
|
|
<title>Status</title>
|
2019-09-12 22:15:42 +02:00
|
|
|
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
|
2019-12-28 18:19:52 +01:00
|
|
|
<style>
|
2020-03-10 23:34:32 +01:00
|
|
|
#results div.container:first-child {
|
|
|
|
border-top-left-radius: 3px;
|
|
|
|
border-top-right-radius: 3px;
|
|
|
|
}
|
|
|
|
#results div.container:last-child {
|
|
|
|
border-bottom-left-radius: 3px;
|
|
|
|
border-bottom-right-radius: 3px;
|
|
|
|
border-bottom-width: 1px;
|
|
|
|
border-color: #dee2e6;
|
|
|
|
border-style: solid;
|
|
|
|
}
|
|
|
|
.status-ok {
|
2019-12-28 18:19:52 +01:00
|
|
|
display: inline-block;
|
2020-03-10 23:34:32 +01:00
|
|
|
width: 1%;
|
|
|
|
height: 20px;
|
|
|
|
margin-right: 4px;
|
|
|
|
background-color: #28a745;
|
2019-12-28 18:19:52 +01:00
|
|
|
}
|
|
|
|
</style>
|
2019-09-12 22:15:42 +02:00
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<div class="container my-3 bg-light rounded p-4 border shadow">
|
2019-09-17 02:29:06 +02:00
|
|
|
<div class="text-center mb-3">
|
2019-10-19 01:55:54 +02:00
|
|
|
<div class="display-4">Status</div>
|
2019-09-12 22:15:42 +02:00
|
|
|
</div>
|
2020-03-10 23:34:32 +01:00
|
|
|
<div id="results">
|
2019-09-17 02:29:06 +02:00
|
|
|
</div>
|
2019-09-12 22:15:42 +02:00
|
|
|
</div>
|
|
|
|
|
|
|
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
|
|
|
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
|
|
|
|
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
|
2019-09-15 01:25:59 +02:00
|
|
|
|
2019-09-12 22:15:42 +02:00
|
|
|
<script>
|
2020-03-10 23:34:32 +01:00
|
|
|
//const OK = "<div class='status-ok' title='__RESPONSE_TIME____CONDITIONS____ERRORS__'></div>"
|
2020-04-08 00:23:26 +02:00
|
|
|
const OK = "<span class='badge badge-success ml-1' style='width: 5%' title='__TIMESTAMP____RESPONSE_TIME____CONDITIONS____ERRORS__'>✓</span>";
|
2020-04-10 22:37:11 +02:00
|
|
|
const NOK = "<span class='badge badge-danger ml-1' style='width: 5%' title='__TIMESTAMP____RESPONSE_TIME____CONDITIONS____ERRORS__'>X</span>";
|
2019-09-12 22:15:42 +02:00
|
|
|
|
2019-12-28 18:19:52 +01:00
|
|
|
function generateServiceResultBox(serviceResult) {
|
|
|
|
let output = (serviceResult.success ? OK : NOK);
|
2020-04-08 00:23:26 +02:00
|
|
|
output = output.replace("__TIMESTAMP__", "Timestamp:\n" + prettifyTimestamp(serviceResult.timestamp));
|
|
|
|
output = output.replace("__RESPONSE_TIME__", "\n\nResponse time:\n" + parseInt(serviceResult.duration/1000000) + "ms");
|
2019-12-28 18:19:52 +01:00
|
|
|
let conditions = "";
|
|
|
|
for (let conditionResultIndex in serviceResult['condition-results']) {
|
|
|
|
let conditionResult = serviceResult['condition-results'][conditionResultIndex];
|
2020-04-15 01:20:00 +02:00
|
|
|
conditions += "\n" + (conditionResult.success ? "✓" : "X") + " ~ " + htmlEntities(conditionResult.condition);
|
2019-12-28 18:19:52 +01:00
|
|
|
}
|
|
|
|
output = output.replace("__CONDITIONS__", "\n\nConditions:" + conditions);
|
|
|
|
if (serviceResult['errors'].length > 0) {
|
|
|
|
let errors = "";
|
|
|
|
for (let errorIndex in serviceResult['errors']) {
|
2020-04-15 01:20:00 +02:00
|
|
|
errors += "\n- " + htmlEntities(serviceResult['errors'][errorIndex]);
|
2019-12-28 18:19:52 +01:00
|
|
|
}
|
|
|
|
output = output.replace("__ERRORS__", "\n\nErrors: " + errors);
|
|
|
|
} else {
|
|
|
|
output = output.replace("__ERRORS__", "");
|
|
|
|
}
|
|
|
|
return output;
|
|
|
|
}
|
|
|
|
|
2020-03-10 23:34:32 +01:00
|
|
|
function refreshResults() {
|
2019-09-12 22:15:42 +02:00
|
|
|
$.getJSON("/api/v1/results", function (data) {
|
2020-03-10 23:34:32 +01:00
|
|
|
let output = "";
|
2019-09-12 22:15:42 +02:00
|
|
|
for (let serviceName in data) {
|
2019-12-28 18:19:52 +01:00
|
|
|
let serviceStatusOverTime = "";
|
|
|
|
let hostname = data[serviceName][data[serviceName].length-1].hostname
|
|
|
|
let minResponseTime = null;
|
|
|
|
let maxResponseTime = null;
|
2019-09-12 22:15:42 +02:00
|
|
|
for (let key in data[serviceName]) {
|
2019-12-28 18:19:52 +01:00
|
|
|
let serviceResult = data[serviceName][key];
|
|
|
|
console.log(serviceResult);
|
|
|
|
serviceStatusOverTime = generateServiceResultBox(serviceResult) + serviceStatusOverTime;
|
|
|
|
const responseTime = parseInt(serviceResult.duration/1000000);
|
|
|
|
if (minResponseTime == null || minResponseTime > responseTime) {
|
|
|
|
minResponseTime = responseTime;
|
|
|
|
}
|
|
|
|
if (maxResponseTime == null || maxResponseTime < responseTime) {
|
|
|
|
maxResponseTime = responseTime;
|
|
|
|
}
|
2019-09-12 22:15:42 +02:00
|
|
|
}
|
2020-03-10 23:34:32 +01:00
|
|
|
output += ""
|
|
|
|
+ "<div class='container p-2 border-left border-right border-top border-black'>"
|
|
|
|
+ " <div class='row mb-2'>"
|
|
|
|
+ " <div class='col-8'>"
|
|
|
|
+ " <span class='font-weight-bold'>" + serviceName + "</span> <span class='text-secondary font-weight-lighter'>- " + hostname + "</span>"
|
|
|
|
+ " </div>"
|
|
|
|
+ " <div class='col-4 text-right'>"
|
|
|
|
+ " <span class='font-weight-lighter'>" + (minResponseTime === maxResponseTime ? minResponseTime : (minResponseTime + "-" + maxResponseTime)) + "ms</span>"
|
|
|
|
+ " </div>"
|
|
|
|
+ " </div>"
|
|
|
|
+ " <div class='row'>"
|
|
|
|
+ " <div class='col-12 d-flex flex-row-reverse'>"
|
|
|
|
+ " " + serviceStatusOverTime
|
|
|
|
+ " </div>"
|
|
|
|
+ " </div>"
|
|
|
|
+ "</div>";
|
2019-09-12 22:15:42 +02:00
|
|
|
}
|
2020-03-10 23:34:32 +01:00
|
|
|
$("#results").html(output);
|
2019-09-12 22:15:42 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-04-08 00:23:26 +02:00
|
|
|
function prettifyTimestamp(timestamp) {
|
|
|
|
let date = new Date(timestamp);
|
|
|
|
let YYYY = date.getFullYear();
|
|
|
|
let MM = ((date.getMonth()+1)<10?"0":"")+""+(date.getMonth()+1);
|
|
|
|
let DD = ((date.getDate())<10?"0":"")+""+(date.getDate());
|
|
|
|
let hh = ((date.getHours())<10?"0":"")+""+(date.getHours());
|
|
|
|
let mm = ((date.getMinutes())<10?"0":"")+""+(date.getMinutes());
|
|
|
|
let ss = ((date.getSeconds())<10?"0":"")+""+(date.getSeconds());
|
|
|
|
return YYYY+"-"+MM+"-"+DD+" "+hh+":"+mm+":"+ss;
|
|
|
|
}
|
|
|
|
|
2020-04-15 01:20:00 +02:00
|
|
|
function htmlEntities(s) {
|
|
|
|
return String(s)
|
|
|
|
.replace(/&/g, '&')
|
|
|
|
.replace(/</g, '<')
|
|
|
|
.replace(/>/g, '>')
|
|
|
|
.replace(/"/g, '"')
|
|
|
|
.replace(/'/g, ''');
|
|
|
|
}
|
|
|
|
|
2020-03-10 23:34:32 +01:00
|
|
|
refreshResults();
|
2019-09-12 22:15:42 +02:00
|
|
|
setInterval(function() {
|
2020-03-10 23:34:32 +01:00
|
|
|
refreshResults();
|
2019-12-28 18:19:52 +01:00
|
|
|
}, 10000);
|
2019-09-12 22:15:42 +02:00
|
|
|
</script>
|
|
|
|
</body>
|
2019-10-06 04:47:09 +02:00
|
|
|
</html>
|