def __call__(self, lang):
ret = """<h3>Icecream Cluster Monitoring</h4>
- <p>Cluster's CPU load: <span id="loadbar"></span> Job load: <span id="jobbar"></span> -
- Number of nodes: <span id="count">-</span></p>
+ <p>Cluster's CPU load: <span id="loadbar"></span> - Job load: <span id="jobbar"></span></p>
<table id="nodes">
<thead>
<tr>
</thead>
<tbody>
</tbody>
- </table>"""
+ </table>
+ <p> <br />Number of nodes: <span id="count">-</span></p>"""
return ret
$("#" + nodeid + "_speed").html(node.speed);
} else {
row = "<tr id=\\"" + nodeid + "\\" class=\\"node\\">";
- row += " <td id=\\"" + nodeid + "_hostname\\">" + node.hostname + "</td>";
+ row += " <td id=\\"" + nodeid + "_hostname\\"></td>";
row += " <td id=\\"" + nodeid + "_arch\\">" + node.arch + "</td>";
row += " <td><span id=\\"" + nodeid + "_loadbar\\"></span></td>";
row += " <td><span id=\\"" + nodeid + "_jobs\\"></span></td>";
$("#nodes").append(row);
}
$("#" + nodeid + "_loadbar").progressBar(node.load, {showText: false});
- $("#" + nodeid + "_jobs").progressBar(node.jobs.split("/")[0], { max: node.jobs.split("/")[1], textFormat: 'fraction'});
+ $("#" + nodeid + "_jobs").progressBar(node.jobcount.split("/")[0], { max: node.jobcount.split("/")[1], textFormat: 'fraction'});
+ if (node.installing == true) {
+ $("#" + nodeid + "_hostname").html(node.hostname + " *");
+ } else {
+ $("#" + nodeid + "_hostname").html(node.hostname);
+ }
});
$("#loadbar").progressBar(data.result.cluster.load);
- $("#jobbar").progressBar(data.result.cluster.jobs.split("/")[0], { max: data.result.cluster.jobs.split("/")[1], textFormat: 'fraction'});
+ $("#jobbar").progressBar(data.result.cluster.jobcount.split("/")[0], { max: data.result.cluster.jobcount.split("/")[1], textFormat: 'fraction'});
for (var nodeid in nodes) {
if (nodes[nodeid] == false) {
$("#" + nodeid).remove();
#!/usr/bin/python
+import os
import telnetlib
import simplejson as json
class Node(object):
- def __init__(self, hostname, address, arch, speed, jobs, load):
+ def __init__(self, hostname, address, arch, speed, jobcount, load, installing):
self.hostname = hostname
self.address = address
self.arch = arch
self.speed = speed
+ self.installing = installing
- (jobs_cur, jobs_max) = jobs.split("/")
+ (jobs_cur, jobs_max) = jobcount.split("/")
if jobs_cur > jobs_max:
jobs_cur = jobs_max
- self.jobs = "%s/%s" % (jobs_cur, jobs_max)
+ self.jobcount = "%s/%s" % (jobs_cur, jobs_max)
self.load = int(load) / 10 # in percent
+
+ self.jobs = []
def __str__(self):
return self.hostname
print " Address: %s" % self.address
print " Arch : %s" % self.arch
print " Speed : %s" % self.speed
- print " Jobs : %s" % self.jobs
+ print " Jobs : %s" % self.jobcount
print " Load : %s" % self.load
+class Job(object):
+ def __init__(self, id, status, submitter, compiler, file):
+ self.id = id
+ self.status = status
+ self.submitter = submitter
+ self.compiler = compiler
+ self.file = file
+
+
class Cluster(object):
def __init__(self, scheduler, port=8766):
self.scheduler = scheduler
return load
@property
- def jobs(self):
+ def jobcount(self):
jobs_cur = jobs_max = 0
for node in self.nodes:
- jobs_cur += int(node.jobs.split("/")[0])
- jobs_max += int(node.jobs.split("/")[1])
+ jobs_cur += int(node.jobcount.split("/")[0])
+ jobs_max += int(node.jobcount.split("/")[1])
return "%s/%s" % (jobs_cur, jobs_max)
@property
return self._nodes
ret = []
data = self.command("listcs")
+ node = None
for line in data:
- if line.startswith(" "): continue
- if not line.startswith(" "): continue
- (a, hostname, address, arch, speed, jobs, load) = line.split(" ")
- address = address.strip("()")
- arch = arch.strip("[]")
- speed = speed.split("=")[1]
- jobs = jobs.split("=")[1]
- load = load.split("=")[1]
- ret.append(Node(hostname, address, arch, speed, jobs, load))
+ if not line.startswith(" "):
+ continue # does not belong to the data
+
+ if line.startswith(" ") and node: # Job
+ (a, b, c, id, status, submitter, compiler, file) = line.split(" ")
+ submitter = submitter[4:]
+ compiler = compiler[3:]
+ file = os.path.basename(file)
+ job = Job(id, status, submitter, compiler, file)
+ node.jobs.append(job)
+
+ elif line.startswith(" "): # Node
+ installing = False
+ a = line.split(" ")
+ if len(a) > 7:
+ installing = True
+ line = " ".join(a[0:7])
+
+ (a, hostname, address, arch, speed, jobcount, load) = line.split(" ")
+ address = address.strip("()")
+ arch = arch.strip("[]")
+ speed = speed[6:]
+ jobcount = jobcount[5:]
+ load = load[5:]
+ node = Node(hostname, address, arch, speed, jobcount, load, installing)
+ ret.append(node)
+
self._nodes = ret
return ret
tmp = { "hostname" : node.hostname,
"address" : node.address,
"arch" : node.arch,
- "jobs" : node.jobs,
+ "jobcount" : node.jobcount,
"load" : node.load,
- "speed" : node.speed, }
+ "speed" : node.speed,
+ "installing" : node.installing,}
+ jobs = []
+ for job in node.jobs:
+ jobs.append({ "id" : job.id,
+ "status" : job.status,
+ "submitter" : job.submitter,
+ "compiler" : job.compiler,
+ "file" : job.file, })
+ tmp["jobs"] = jobs
nodes.append(tmp)
ret["nodes"] = nodes
- ret["cluster"] = { "load" : self.load,
- "jobs" : self.jobs, }
- #return json.dumps(ret)
+ ret["cluster"] = { "load" : self.load,
+ "jobcount" : self.jobcount, }
return ret