|
|
@ -48,19 +48,39 @@ class_write= CONFIG['store']['class']['write']
|
|
|
|
factory = DataSourceFactory()
|
|
|
|
factory = DataSourceFactory()
|
|
|
|
# gReader = factory.instance(type=class_read,args=p)
|
|
|
|
# gReader = factory.instance(type=class_read,args=p)
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/1/get/apps')
|
|
|
|
@app.route('/1/get/nodes')
|
|
|
|
def get_apps():
|
|
|
|
def get_apps():
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
This function returns the labels of applications for every node registered
|
|
|
|
This function returns the labels of applications for every node registered
|
|
|
|
|
|
|
|
@param None
|
|
|
|
e.g: apps@zulu.org
|
|
|
|
e.g: apps@zulu.org
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
r = []
|
|
|
|
r = []
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
gReader = factory.instance(type=class_read,args=p)
|
|
|
|
|
|
|
|
r = gReader.view('summary/nodes',key=p['uid'])
|
|
|
|
|
|
|
|
except Exception,e:
|
|
|
|
|
|
|
|
print (e)
|
|
|
|
|
|
|
|
return json.dumps(r)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/1/get/apps')
|
|
|
|
|
|
|
|
def get_apps():
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
This function returns the applications for a given node
|
|
|
|
|
|
|
|
@param node identifier e.g: apps@zulu.org
|
|
|
|
|
|
|
|
"""
|
|
|
|
|
|
|
|
r = []
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
|
|
node_id = request.args.get('node')
|
|
|
|
gReader = factory.instance(type=class_read,args=p)
|
|
|
|
gReader = factory.instance(type=class_read,args=p)
|
|
|
|
r = gReader.view('summary/app_names',key=p['uid'])
|
|
|
|
r = gReader.view('summary/app_names',key=p['uid'])
|
|
|
|
|
|
|
|
r = r[node_id]
|
|
|
|
except Exception,e:
|
|
|
|
except Exception,e:
|
|
|
|
print (e)
|
|
|
|
print (e)
|
|
|
|
return json.dumps(r)
|
|
|
|
return json.dumps(r)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/1/get/summary/<id>')
|
|
|
|
@app.route('/1/get/summary/<id>')
|
|
|
|
def get_summary(id):
|
|
|
|
def get_summary(id):
|
|
|
|
"""
|
|
|
|
"""
|
|
|
@ -88,7 +108,7 @@ def get_usage_trend():
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
|
|
|
This function returns cpu/memory usage for the entire system being monitored. It will return the 24 most recent observations in the logs
|
|
|
|
This function returns cpu/memory usage for the entire system being monitored. It will return the 24 most recent observations in the logs
|
|
|
|
No parameters should be passed.
|
|
|
|
@param None
|
|
|
|
@return {memory_usage:[],cpu_usage:[],app_count:value,memory_available:[]}
|
|
|
|
@return {memory_usage:[],cpu_usage:[],app_count:value,memory_available:[]}
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
r = {}
|
|
|
|
r = {}
|
|
|
@ -104,37 +124,41 @@ def get_usage_trend():
|
|
|
|
def get_usage_detail():
|
|
|
|
def get_usage_detail():
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
This function returns detailed information about usage per application monitored. It will return the 24 most recent observations in the logs
|
|
|
|
This function returns detailed information about usage per application monitored. It will return the 24 most recent observations in the logs
|
|
|
|
No parameters should be passed
|
|
|
|
|
|
|
|
@return {app_1:{memory_usage:[],cpu_usage:[]},app_2:{memory_usage:[],cpu_usage:[]},...}
|
|
|
|
@param node node identifier e.g: apps@zulu.io
|
|
|
|
@TODO:
|
|
|
|
@return {node_x:{app_1:{memory_usage:[],cpu_usage:[]}},...}
|
|
|
|
- add node references because if the same application lives on other nodes the info will be overriden
|
|
|
|
|
|
|
|
- parameters to be passed will be the node information
|
|
|
|
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
r = {}
|
|
|
|
r = {}
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
|
|
|
|
id = request.args.get('node')
|
|
|
|
gReader = factory.instance(type=class_read,args=p)
|
|
|
|
gReader = factory.instance(type=class_read,args=p)
|
|
|
|
r = gReader.view('summary/app_resource_usage_details',key=p['uid'])
|
|
|
|
r = gReader.view('summary/app_resource_usage_details',key=p['uid'])
|
|
|
|
|
|
|
|
r = r[id]
|
|
|
|
except Exception,e:
|
|
|
|
except Exception,e:
|
|
|
|
print (e)
|
|
|
|
print (e)
|
|
|
|
return json.dumps(r)
|
|
|
|
return json.dumps(r)
|
|
|
|
@app.route('/1/app/status/<id>')
|
|
|
|
@app.route('/1/app/status')
|
|
|
|
def app_status(id) :
|
|
|
|
def app_status() :
|
|
|
|
"""
|
|
|
|
"""
|
|
|
|
This function aggregates the number of crashes/running/idle instances found in the past 24 log entries
|
|
|
|
This function aggregates the number of crashes/running/idle instances found in the past 24 log entries
|
|
|
|
@TODO: The back-end doesn't allow nodes to be specified
|
|
|
|
|
|
|
|
@param id node that contains an app
|
|
|
|
@param nid node identifier e.g: app@zulu.io
|
|
|
|
"""
|
|
|
|
@param aid application identifier e.g: kate, firefox, chrome ... specified in the configuraiton
|
|
|
|
r = []
|
|
|
|
"""
|
|
|
|
|
|
|
|
r = []
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
gReader = factory.instance(type=class_read,args=p)
|
|
|
|
nid = request.args.get('node') # Node identifier
|
|
|
|
r = gReader.view('summary/app_status_details',key=p['uid'])
|
|
|
|
aid = request.args.get('app') # application identifier
|
|
|
|
#
|
|
|
|
|
|
|
|
#@TODO: Once the back-end enables the nodes in which the application is running, uncomment the line below
|
|
|
|
gReader = factory.instance(type=class_read,args=p)
|
|
|
|
#
|
|
|
|
r = gReader.view('summary/app_status_details',key=p['uid'])
|
|
|
|
#r = r[id]
|
|
|
|
#
|
|
|
|
except Exception,e:
|
|
|
|
#@TODO: Once the back-end enables the nodes in which the application is running, uncomment the line below
|
|
|
|
print e
|
|
|
|
#
|
|
|
|
return r
|
|
|
|
r = r[nid][aid]
|
|
|
|
|
|
|
|
except Exception,e:
|
|
|
|
|
|
|
|
print e
|
|
|
|
|
|
|
|
return r
|
|
|
|
@app.route('/get/<id>')
|
|
|
|
@app.route('/get/<id>')
|
|
|
|
def procs(id):
|
|
|
|
def procs(id):
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|