]>
git.ipfire.org Git - people/shoehn/ipfire.org.git/blob - www/pages/cluster.py
5 from web
.javascript
import Javascript
7 class Content(web
.Content
):
9 web
.Content
.__init
__(self
)
11 def __call__(self
, lang
):
12 ret
= """<h3>Icecream Cluster Monitoring</h3>
13 <p>Cluster's CPU load: <span id="loadbar"></span> - Job load: <span id="jobbar"></span></p>
17 <th class="hostname">Name</th>
18 <th class="arch">Arch</th>
19 <th class="load">Load</th>
20 <th class="jobs">Jobs</th>
21 <th class="speed">Speed</th>
27 <p> <br />Number of nodes: <span id="count">-</span></p>"""
32 page
.content
= Content()
33 page
.sidebar
= web
.elements
.DevelopmentSidebar()
35 page
.javascript
= Javascript(jquery
=1)
36 page
.javascript
.jquery_plugin("progressbar")
37 page
.javascript
.write("""<script type="text/javascript">
43 $.getJSON("/rpc.py", { method: "cluster_get_info", id : id++ },
45 // If we are already busy then exit
46 if (busy == true) return;
50 if (data.error != "null") return;
54 $.each(data.result.nodes, function(i, node) {
55 var nodeid = node.hostname.replace(/\./g, "");
60 if ($("#" + nodeid).length) {
61 $("#" + nodeid + "_speed").html(node.speed);
63 row = "<tr id=\\"" + nodeid + "\\" class=\\"node\\">";
64 row += " <td id=\\"" + nodeid + "_hostname\\"></td>";
65 row += " <td id=\\"" + nodeid + "_arch\\">" + node.arch + "</td>";
66 row += " <td><span id=\\"" + nodeid + "_loadbar\\"></span></td>";
67 row += " <td><span id=\\"" + nodeid + "_jobs\\"></span></td>";
68 row += " <td id=\\"" + nodeid + "_speed\\">" + node.speed + "</td>";
70 $("#nodes").append(row);
72 $("#" + nodeid + "_loadbar").progressBar(node.load, {showText: false});
73 $("#" + nodeid + "_jobs").progressBar(node.jobcount.split("/")[0], { max: node.jobcount.split("/")[1], textFormat: 'fraction'});
74 if (node.installing == true) {
75 $("#" + nodeid + "_hostname").html(node.hostname + " *");
77 $("#" + nodeid + "_hostname").html(node.hostname);
81 $("#loadbar").progressBar(data.result.cluster.load);
82 $("#jobbar").progressBar(data.result.cluster.jobcount.split("/")[0], { max: data.result.cluster.jobcount.split("/")[1], textFormat: 'fraction'});
83 for (var nodeid in nodes) {
84 if (nodes[nodeid] == false) {
85 $("#" + nodeid).remove();
88 nodes[nodeid] = false;
91 $("#count").html(count);
96 $(document).ready(function(){
98 $("#loadbar").progressBar();
101 setInterval("update()", 2000);