-
Notifications
You must be signed in to change notification settings - Fork 4
/
monitor.php
97 lines (76 loc) · 2.06 KB
/
monitor.php
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
<!doctype html>
<html>
<head>
<?php require_once("common-head.php"); ?>
<title>Plug n Play cluster</title>
</head>
<body>
<?php require_once("nav.php"); ?>
<div class="container">
<div class="row">
<div class="col-md-12 text-center">
<h2 style="font-weight:bold;">Cluster Monitor</h2><hr>
</div>
<div>
<div class="row">
<div class="col-md-6">
<p><strong>Worker Nodes</strong></p>
<table id = "fetched" class="table table-striped">
<tr>
<td><b>Worker ID</b></td>
<td><b>Worker IP</b></td>
<td><b>Last Ping</b></td>
<td><b>Status</b></td>
</tr>
</table>
</div>
<div class="col-md-6">
<p><strong>Tasks</strong></p>
<table id = "tasks" class="table table-striped">
<tr>
<td><b>Job ID</b></td>
<td><b>Task ID</b></td>
<td><b>Task File Name</b></td>
<td><b>Status</b></td>
<td><b>Worker Ip</b></td>
</tr>
</table>
</div>
</div>
</div>
<?php require_once("footer.php"); ?>
<script>
$(document).ready(function() {
// delete non-active workers from the cluster
// every 5 seconds
setInterval(function(){
// getting JSON - worker id, worker ip, last ping's time
$.getJSON("cron.php", function(data, status){
console.log(data);
// removing all rows except the table header
$("#fetched").find("tr:gt(0)").remove();
if(data != '')
// appending the recieved JSON to the table
$.each(data.workers, function(key, val) {
var tr=$('<tr></tr>');
$.each(val, function(k, v){
$('<td>'+v+'</td>').appendTo(tr);
});
tr.appendTo("#fetched");
});
$("#tasks").find("tr:gt(0)").remove();
if(data != '')
// appending the recieved JSON to the table
$.each(data.tasks, function(key, val) {
var tr=$('<tr></tr>');
$.each(val, function(k, v){
$('<td>'+v+'</td>').appendTo(tr);
});
tr.appendTo("#tasks");
});
});
},1000);
});
</script>
</body>
</html>