mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-23 22:50:09 +03:00
Feature #650: Updated the server side for single resource monitor requests.
This commit is contained in:
parent
14bddae026
commit
9ce774a392
@ -223,7 +223,6 @@ class SunstoneServer
|
||||
# The VM host and its VNC port
|
||||
host = resource['HISTORY/HOSTNAME']
|
||||
vnc_port = resource['TEMPLATE/GRAPHICS/PORT']
|
||||
|
||||
# The noVNC proxy_port
|
||||
proxy_port = config[:vnc_proxy_base_port].to_i + vnc_port.to_i
|
||||
|
||||
@ -266,7 +265,7 @@ class SunstoneServer
|
||||
#
|
||||
############################################################################
|
||||
|
||||
def get_log(resource,id,config,request)
|
||||
def get_log(resource,id,config,monitor_res,history_length)
|
||||
log_file_prefix = case resource
|
||||
when "vm","VM"
|
||||
config[:host_log_file]
|
||||
@ -274,11 +273,11 @@ class SunstoneServer
|
||||
config[:vm_log_file]
|
||||
end
|
||||
|
||||
log_file = "#{log_file_prefix}_#{id}.csv"
|
||||
if !log_file_prefix or log_file_prefix.empty?
|
||||
log_file_prefix = "/srv/cloud/one-dummy/logs/"+resource
|
||||
end
|
||||
|
||||
request_json = parse_json(request,"monitor")
|
||||
history_length = request_json[:history_length]
|
||||
element = request_json[:element]
|
||||
log_file = "#{log_file_prefix}_#{id}.csv"
|
||||
|
||||
first_line = `head -1 #{log_file}`
|
||||
|
||||
@ -291,10 +290,9 @@ class SunstoneServer
|
||||
fields = first_line.split(',')
|
||||
|
||||
poll_time_pos = fields.index("time")
|
||||
resource_pos = fields.index(element)
|
||||
resource_pos = fields.index(monitor_res)
|
||||
id_pos = fields.index("id")
|
||||
|
||||
|
||||
graph = []
|
||||
tail = `tail -#{history_length} #{log_file}`
|
||||
|
||||
@ -302,7 +300,7 @@ class SunstoneServer
|
||||
line_arr = line.delete('"').split(',')
|
||||
if (line_arr[id_pos].to_i == id.to_i)
|
||||
then
|
||||
graph << [ line_arr[poll_time_pos], line_arr[resource_pos] ]
|
||||
graph << [ line_arr[poll_time_pos].to_i*1000, line_arr[resource_pos].to_i ]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -166,7 +166,7 @@ get '/:resource/monitor' do
|
||||
end
|
||||
|
||||
get '/:resource/:id/monitor' do
|
||||
get_log(params[:resource],params[:id],settings.config,request.body.read)
|
||||
@SunstoneServer.get_log(params[:resource],params[:id],settings.config,params['monitor_res'],params['history_length'])
|
||||
end
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user