]> git.ipfire.org Git - people/shoehn/ipfire.org.git/blame - www/pages/cluster/__init__.py
Fixed font-size of Wiki link on start page.
[people/shoehn/ipfire.org.git] / www / pages / cluster / __init__.py
CommitLineData
efe0c55b
MT
1#!/usr/bin/python
2
3import web
dba657a8
MT
4import web.elements
5from web.javascript import Javascript
efe0c55b
MT
6
7class Content(web.Content):
dba657a8
MT
8 def __init__(self):
9 web.Content.__init__(self)
efe0c55b
MT
10
11 def __call__(self, lang):
dba657a8 12 ret = """<h3>Icecream Cluster Monitoring</h4>
a68b9561 13 <p>Cluster's CPU load: <span id="loadbar"></span> Job load: <span id="jobbar"></span> -
3d0128fa 14 Number of nodes: <span id="count">-</span></p>
dba657a8
MT
15 <table id="nodes">
16 <thead>
17 <tr>
18 <th>Name</th>
19 <th>Arch</th>
20 <th>Load</th>
21 <th>Jobs</th>
22 <th>Speed</th>
23 </tr>
24 </thead>
25 <tbody>
26 </tbody>
27 </table>"""
efe0c55b 28
dba657a8
MT
29 return ret
30
31page = web.Page()
32page.content = Content()
33page.sidebar = web.elements.Sidebar()
34
35page.javascript = Javascript(jquery=1)
36page.javascript.jquery_plugin("progressbar")
37page.javascript.write("""<script type="text/javascript">
efe0c55b 38 nodes = new Array();
3d0128fa 39 id = 0;
efe0c55b
MT
40
41 update = function() {
3d0128fa 42 $.getJSON("/rpc.py", { method: "cluster_get_info", id : id++ },
efe0c55b 43 function(data) {
ce0f70d2 44 var count = 0;
3d0128fa
MT
45
46 if (data.error != "null") return;
47
48 $.each(data.result.nodes, function(i, node) {
ce0f70d2
MT
49 var nodeid = node.hostname.replace(/\./g, "");
50 count++;
efe0c55b
MT
51
52 nodes[nodeid] = true;
53
54 if ($("#" + nodeid).length) {
ce0f70d2 55 $("#" + nodeid + "_speed").html(node.speed);
efe0c55b
MT
56 } else {
57 row = "<tr id=\\"" + nodeid + "\\" class=\\"node\\">";
58 row += " <td id=\\"" + nodeid + "_hostname\\">" + node.hostname + "</td>";
59 row += " <td id=\\"" + nodeid + "_arch\\">" + node.arch + "</td>";
60 row += " <td><span id=\\"" + nodeid + "_loadbar\\"></span></td>";
ce0f70d2
MT
61 row += " <td><span id=\\"" + nodeid + "_jobs\\"></span></td>";
62 row += " <td id=\\"" + nodeid + "_speed\\">" + node.speed + "</td>";
efe0c55b
MT
63 row += "</tr>";
64 $("#nodes").append(row);
65 }
66 $("#" + nodeid + "_loadbar").progressBar(node.load, {showText: false});
ce0f70d2 67 $("#" + nodeid + "_jobs").progressBar(node.jobs.split("/")[0], { max: node.jobs.split("/")[1], textFormat: 'fraction'});
efe0c55b 68 });
3d0128fa
MT
69
70 $("#loadbar").progressBar(data.result.cluster.load);
71 $("#jobbar").progressBar(data.result.cluster.jobs.split("/")[0], { max: data.result.cluster.jobs.split("/")[1], textFormat: 'fraction'});
efe0c55b
MT
72 for (var nodeid in nodes) {
73 if (nodes[nodeid] == false) {
74 $("#" + nodeid).remove();
75 nodes.pop(nodeid);
76 } else {
77 nodes[nodeid] = false;
78 }
79 }
ce0f70d2 80 $("#count").html(count);
efe0c55b
MT
81 });
82 }
83
84 $(document).ready(function(){
85 // Init loadbar
86 $("#loadbar").progressBar();
87
88 update();
ce0f70d2 89 setInterval("update()", 2000);
efe0c55b 90 })
dba657a8 91 </script>""")