summaryrefslogtreecommitdiffstats
path: root/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'index.js')
-rw-r--r--index.js26
1 files changed, 23 insertions, 3 deletions
diff --git a/index.js b/index.js
index 18efac7..f2f9210 100644
--- a/index.js
+++ b/index.js
@@ -20,16 +20,36 @@ statuscake
.username(username)
.key(password);
+var currentStatus = {};
+
app.get("/", function(req, res) {
res.render("index.html");
});
+app.get("/status", function(req, res) {
+ res.json(currentStatus);
+});
+
app.listen(3000, function() {
console.log("radiodiodi status display listening on port 3000.");
});
-function allTests(err, data) {
- console.log(data);
+
+function get_status(err, data) {
+ currentStatus = [];
+ for (var i = 0; i < data.length; i++) {
+ var is_up = data[i].Status == 'Up';
+
+ var system = {}
+ system.name = data[i].WebsiteName;
+ system.status = is_up;
+ system.uptime = data[i].Uptime;
+ currentStatus.push(system);
+ }
+
+ console.log(currentStatus);
}
-statuscake.tests(allTests);
+setInterval(function() {
+ statuscake.tests(get_status);
+}, 5000);