status handling backend and front-end refactoring

master
Steve L. Nyemba 8 years ago
parent 447b0c07df
commit b0b54c81ed

@ -31,16 +31,18 @@ monitor.processes.init = function(x){
monitor.processes.render = function(label,data) { monitor.processes.render = function(label,data) {
var status = {"idle":'<i class="fa fa-ellipsis-h" title="IDLE"></i>',"running":'<i class="fa fa-check" title="RUNNING"></i>',"crash":'<i class="fa fa-times" title="CRASHED"></i>'} var status = {"idle":'<i class="fa fa-ellipsis-h" title="IDLE"></i>',"running":'<i class="fa fa-check" title="RUNNING"></i>',"crash":'<i class="fa fa-times" title="CRASHED"></i>'}
data = jx.utils.patterns.visitor(data,function(row){ data = jx.utils.patterns.visitor(data,function(row){
var m = row.memory_usage >0 console.log(row)
var c = row.cpu_usage > 0 row.status = status[row.status]
var r = row.memory_available > 0 // var m = row.memory_usage >0
if ( r && c && m) { // var c = row.cpu_usage > 0
row.status = status['running'] // var r = row.memory_available > 0
}else if (r && (!m || !c) ){ // if ( r && c && m) {
row.status = status['idle'] // row.status = status['running']
}else if (!r){ // }else if (r && (!m || !c) ){
row.status = status['crash'] // row.status = status['idle']
} // }else if (!r){
// row.status = status['crash']
// }
return row return row
}) })

@ -154,8 +154,21 @@ class DetailProcess(Analysis):
row = [float(value) for value in row if value.strip() != '' and name not in value ] +[re.sub('\$|^','',name)] row = [float(value) for value in row if value.strip() != '' and name not in value ] +[re.sub('\$|^','',name)]
r.append(row) r.append(row)
return r return r
def status(self,row):
x = row['memory_usage']
y = row['cpu_usage']
z = row['memory_available']
if z :
if y :
return "running"
return "idle"
else:
return "crash"
def format(self,row): def format(self,row):
return {"memory_usage":row[0],"cpu_usage":row[1],"memory_available":row[2]/1000,"label":row[3]} r= {"memory_usage":row[0],"cpu_usage":row[1],"memory_available":row[2]/1000,"label":row[3]}
status = self.status(r)
r['status'] = status
return r
def composite(self): def composite(self):
#value = self.evaluate(self.name) #value = self.evaluate(self.name)
#row= {"memory_usage":value[0],"cpu_usage":value[1]} #row= {"memory_usage":value[0],"cpu_usage":value[1]}

Loading…
Cancel
Save