|
|
|
@ -28,16 +28,24 @@ class analytics :
|
|
|
|
|
key = self.cache['key']
|
|
|
|
|
r = self.handler.view('clients/latest_logs',key=key)
|
|
|
|
|
id = self.get('name')
|
|
|
|
|
if id in r :
|
|
|
|
|
nodes = r[id].keys()
|
|
|
|
|
self.set('nodes',nodes)
|
|
|
|
|
logs = {}
|
|
|
|
|
for name in nodes :
|
|
|
|
|
logs[name] = r[id][name]['log']
|
|
|
|
|
|
|
|
|
|
self.set('logs',logs)
|
|
|
|
|
self.set('summary',self.summary(r[id]))
|
|
|
|
|
self.format(self.summary(r[id]))
|
|
|
|
|
logs = r[id]
|
|
|
|
|
nodes = logs.keys()
|
|
|
|
|
self.set('nodes',nodes)
|
|
|
|
|
self.set('logs',logs)
|
|
|
|
|
self.set('summary',self.summary(logs))
|
|
|
|
|
self.format(logs)
|
|
|
|
|
|
|
|
|
|
# if id in r :
|
|
|
|
|
# nodes = r[id].keys()
|
|
|
|
|
# print nodes
|
|
|
|
|
# self.set('nodes',nodes)
|
|
|
|
|
# logs = {}
|
|
|
|
|
# for name in nodes :
|
|
|
|
|
# logs[name] = r[id][name]['log']
|
|
|
|
|
|
|
|
|
|
# self.set('logs',logs)
|
|
|
|
|
# self.set('summary',self.summary(r[id]))
|
|
|
|
|
# self.format(self.summary(r[id]))
|
|
|
|
|
|
|
|
|
|
def summary(self,logs) :
|
|
|
|
|
raise Exception("needs to be implemented")
|
|
|
|
@ -78,38 +86,76 @@ class apps(analytics) :
|
|
|
|
|
grid['fields'] = [{"name":"name","title":"Process","headercss":"small"},{"name":"cpu","title":"CPU Usage","headercss":"small","type":"number"},{"name":"mem","title":"RAM Usage","headercss":"small","type":"number"},{"name":"status","title":"Status","headercss":"small","align":"center"}]
|
|
|
|
|
self.set('grid',grid)
|
|
|
|
|
|
|
|
|
|
def summary(self,logs):
|
|
|
|
|
def summary(self,data):
|
|
|
|
|
"""
|
|
|
|
|
The
|
|
|
|
|
Status count and load assessment
|
|
|
|
|
This function will organize the summary of the logs per node
|
|
|
|
|
In terms of {crash,idle,running} counts
|
|
|
|
|
"""
|
|
|
|
|
# logs = pd.DataFrame(self.get('logs'))
|
|
|
|
|
r = []
|
|
|
|
|
for id in logs :
|
|
|
|
|
row = pd.DataFrame(logs[id]['log'])
|
|
|
|
|
|
|
|
|
|
crash = np.sum(row.status == 'X')
|
|
|
|
|
idle = np.sum(row.status == 'S') + np.sum(row.status == 'S+')
|
|
|
|
|
cpu = row.cpu.sum()
|
|
|
|
|
mem = row.mem.sum() #{"sum":row.mem.sum(),"mean":row.mem.mean(),"sd":np.sqrt(row.mem.var())}
|
|
|
|
|
running = row.shape[0] - crash - idle
|
|
|
|
|
|
|
|
|
|
r.append({"node":id,"date":logs[id]['date']['long'],"running":running,"idle":idle,"crash":crash,"mem":mem,"cpu":cpu})
|
|
|
|
|
for node in data :
|
|
|
|
|
logs = data[node]['logs']
|
|
|
|
|
date = data[node]['date']['long']
|
|
|
|
|
df = pd.DataFrame(logs)
|
|
|
|
|
df = df[df.name.str.contains('other',na=False)==False]
|
|
|
|
|
crash = df.status.str.contains('X').sum()
|
|
|
|
|
idle = df.status.str.contains('S').sum()
|
|
|
|
|
running = df.shape[0] - crash - idle
|
|
|
|
|
r.append({"date":date,"node":node,"running":running,"idle":idle,"crash":crash})
|
|
|
|
|
return r
|
|
|
|
|
|
|
|
|
|
# logs = pd.DataFrame(self.get('logs'))
|
|
|
|
|
# r = []
|
|
|
|
|
# for id in logs :
|
|
|
|
|
# row = pd.DataFrame(logs[id]['log'])
|
|
|
|
|
|
|
|
|
|
# crash = np.sum(row.status == 'X')
|
|
|
|
|
# idle = np.sum(row.status == 'S') + np.sum(row.status == 'S+')
|
|
|
|
|
# cpu = row.cpu.sum()
|
|
|
|
|
# mem = row.mem.sum() #{"sum":row.mem.sum(),"mean":row.mem.mean(),"sd":np.sqrt(row.mem.var())}
|
|
|
|
|
# running = row.shape[0] - crash - idle
|
|
|
|
|
|
|
|
|
|
# r.append({"node":id,"date":logs[id]['date']['long'],"running":running,"idle":idle,"crash":crash,"mem":mem,"cpu":cpu})
|
|
|
|
|
# return r
|
|
|
|
|
# self.set("summary",)
|
|
|
|
|
def format(self,slogs) :
|
|
|
|
|
def format(self,data) :
|
|
|
|
|
"""
|
|
|
|
|
This function adds other somewhat important statistics :
|
|
|
|
|
- resources used for the node
|
|
|
|
|
|
|
|
|
|
r = []
|
|
|
|
|
"""
|
|
|
|
|
r = []
|
|
|
|
|
q = []
|
|
|
|
|
for row in slogs :
|
|
|
|
|
|
|
|
|
|
r.append( {"x":[row['crash'],row['idle'],row['running']],"labels":['Crash','Idle','Running'],"title":"","date":row['date']})
|
|
|
|
|
# q.append({"x":[[row['cpu'],row['mem']]],"labels":["CPU","RAM"],"title":"Resources","date":row['date'],"title":row['node'],"series":[ 'CPU','RAM' ]})
|
|
|
|
|
|
|
|
|
|
q.append({"x":[[row['cpu'],0],[0,row['mem']]],"labels":["",""],"date":row['date'],"title":"","series":[ 'CPU','RAM' ],"ylabel":"% Resource Used"})
|
|
|
|
|
|
|
|
|
|
self.set('status',r)
|
|
|
|
|
self.set('resource',q)
|
|
|
|
|
labels = ['Other','Monitored']
|
|
|
|
|
title = ""
|
|
|
|
|
series = ['CPU','RAM']
|
|
|
|
|
ylabel = " Resource Used"
|
|
|
|
|
for node in data :
|
|
|
|
|
df = pd.DataFrame(data[node]['logs'])
|
|
|
|
|
N = df.shape[0] - 1
|
|
|
|
|
other_df = pd.DataFrame(df[df.name.str.contains('other',na=False)])
|
|
|
|
|
watch_df = pd.DataFrame(df[df.name.str.contains('other',na=False)==False])
|
|
|
|
|
X = [[other_df.cpu.sum(),other_df.mem.sum()],[watch_df.cpu.sum(),watch_df.mem.sum()]]
|
|
|
|
|
date= data[node]['date']['long']
|
|
|
|
|
q.append({"node":node, "x":X,"labels":labels, "title":title,"series":series,"ylabel":ylabel})
|
|
|
|
|
crash = watch_df.status.str.contains('X').sum()
|
|
|
|
|
idle = watch_df.status.str.contains('S').sum()
|
|
|
|
|
running = N - crash - idle
|
|
|
|
|
r.append( {"x":[crash,idle,running],"labels":['Crash','Idle','Running'],"title":"","date":date})
|
|
|
|
|
|
|
|
|
|
self.set("resource",q)
|
|
|
|
|
self.set("status",r)
|
|
|
|
|
|
|
|
|
|
# r = []
|
|
|
|
|
# q = []
|
|
|
|
|
# for row in slogs :
|
|
|
|
|
|
|
|
|
|
# r.append( {"x":[row['crash'],row['idle'],row['running']],"labels":['Crash','Idle','Running'],"title":"","date":row['date']})
|
|
|
|
|
# # q.append({"x":[[row['cpu'],row['mem']]],"labels":["CPU","RAM"],"title":"Resources","date":row['date'],"title":row['node'],"series":[ 'CPU','RAM' ]})
|
|
|
|
|
|
|
|
|
|
# q.append({"x":[[row['cpu'],0],[0,row['mem']]],"labels":["",""],"date":row['date'],"title":"","series":[ 'CPU','RAM' ],"ylabel":"% Resource Used"})
|
|
|
|
|
|
|
|
|
|
# self.set('status',r)
|
|
|
|
|
# self.set('resource',q)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class folders(analytics):
|
|
|
|
@ -126,7 +172,7 @@ class folders(analytics):
|
|
|
|
|
grid['fields'] = [{"name":"name","name":"Process"},{"name":"size","title":"Size (MB)"},{"name":"mem","title":"RAM Usage"}]
|
|
|
|
|
self.set('grid',grid)
|
|
|
|
|
|
|
|
|
|
def summary(self,logs):
|
|
|
|
|
def summary(self,data):
|
|
|
|
|
r = []
|
|
|
|
|
features = self.handler.view('clients/features',key=self.get('key'))
|
|
|
|
|
|
|
|
|
@ -140,14 +186,22 @@ class folders(analytics):
|
|
|
|
|
else:
|
|
|
|
|
max_size = 0
|
|
|
|
|
self.set('max_size',max_size)
|
|
|
|
|
for id in logs :
|
|
|
|
|
|
|
|
|
|
row = pd.DataFrame(logs[id]['log'])
|
|
|
|
|
size = row.size_in_kb.mean() * .001
|
|
|
|
|
N = row.shape[0]
|
|
|
|
|
age = np.round(row.age_in_days.mean(),2)
|
|
|
|
|
files=row.files.mean()
|
|
|
|
|
r.append({"node":id,"size":size,"max_size":max_size,"age":age,"folders":N,"files":files})
|
|
|
|
|
for node in data :
|
|
|
|
|
df = pd.DataFrame(data[node]['logs'])
|
|
|
|
|
N = df.shape[0]
|
|
|
|
|
print ' --- ',df.size_in_kb.values
|
|
|
|
|
df = pd.DataFrame(df.mean()[['size_in_kb','files','age_in_days']]).T
|
|
|
|
|
|
|
|
|
|
r.append({"node":node,"folders":N, "max_size":max_size,"size":np.round(df.size_in_kb.values[0]*.000001,2),"age":df.age_in_days.values[0].round(2),"files":df.files.values[0].round(2)})
|
|
|
|
|
return r
|
|
|
|
|
# for id in logs :
|
|
|
|
|
|
|
|
|
|
# row = pd.DataFrame(logs[id]['log'])
|
|
|
|
|
# size = row.size_in_kb.mean() * .001
|
|
|
|
|
# N = row.shape[0]
|
|
|
|
|
# age = np.round(row.age_in_days.mean(),2)
|
|
|
|
|
# files=row.files.mean()
|
|
|
|
|
# r.append({"node":id,"size":size,"max_size":max_size,"age":age,"folders":N,"files":files})
|
|
|
|
|
return r
|
|
|
|
|
class protocol(analytics):
|
|
|
|
|
pass
|
|
|
|
|