ref: refs/heads/master
commit f30ea09a6b8526258691feb6c6778e8219a727d9
Author: Bjoern Geuken
Date: Tue Jul 7 10:12:37 2009 +0200
status module: cleanup code
---
.../app/controllers/.status_controller.rb.swp | Bin 12288 -> 0 bytes
.../status/app/controllers/status_controller.rb | 27 ++++++-------------
plugins/status/app/models/.status.rb.swp | Bin 20480 -> 0 bytes
plugins/status/app/models/status.rb | 6 +++-
plugins/status/app/views/status/show.html.erb | 2 +-
5 files changed, 14 insertions(+), 21 deletions(-)
diff --git a/plugins/status/app/controllers/.status_controller.rb.swp b/plugins/status/app/controllers/.status_controller.rb.swp
deleted file mode 100644
index 25b72c7..0000000
Binary files a/plugins/status/app/controllers/.status_controller.rb.swp and /dev/null differ
diff --git a/plugins/status/app/controllers/status_controller.rb b/plugins/status/app/controllers/status_controller.rb
index 7c1c5e8..c47ad9a 100644
--- a/plugins/status/app/controllers/status_controller.rb
+++ b/plugins/status/app/controllers/status_controller.rb
@@ -9,6 +9,14 @@ class StatusController < ApplicationController
# POST /status
# POST /status.xml
def create
+ unless permission_check("org.opensuse.yast.system.status.read")
+ render ErrorResult.error(403, 1, "no permission") and return
+ else
+ @status = Status.new
+ @status.collect_data(params[:start], params[:stop])
+ #logger.debug "SHOW: #{@status.inspect}"
+
+ end
end
# GET /status
@@ -24,31 +32,14 @@ class StatusController < ApplicationController
render ErrorResult.error(403, 1, "no permission") and return
else
@status = Status.new
+# @status.collect_data(params[:start], params[:stop])
@status.collect_data("11:13,07/03/2009", "11:14,07/03/2009", %w{cpu memory disk})
- respond_to do |format|
- format.html { render :xml => @status.data.to_xml, :location => "none" } #return xml only
- format.xml { render :xml => @status.data.to_xml, :location => "none" }
- format.json { render :json => @status.data.to_xml, :location => "none" }
- end
end
end
# PUT /status/1
# PUT /status/1.xml
def update
- unless permission_check("org.opensuse.yast.system.status.read")
- render ErrorResult.error(403, 1, "no permission") and return
- else
- @status = Status.new
- @status.collect_data(params[:start], params[:stop], params[:data])
- #logger.debug "SHOW: #{@status.inspect}"
-
- respond_to do |format|
- format.html { render :xml => @status.data.to_xml, :location => "none" } #return xml only
- format.xml { render :xml => @status.data.to_xml, :location => "none" }
- format.json { render :json => @status.data.to_xml, :location => "none" }
- end
- end
end
end
diff --git a/plugins/status/app/models/.status.rb.swp b/plugins/status/app/models/.status.rb.swp
deleted file mode 100644
index 4c5c55c..0000000
Binary files a/plugins/status/app/models/.status.rb.swp and /dev/null differ
diff --git a/plugins/status/app/models/status.rb b/plugins/status/app/models/status.rb
index 4036884..c8d60b5 100644
--- a/plugins/status/app/models/status.rb
+++ b/plugins/status/app/models/status.rb
@@ -77,7 +77,7 @@ class Status < ActiveRecord::Base
# creates one metric for defined period
def fetch_metric(rrdfile, start=Time.now, stop=Time.now)#, heigth=nil, width=nil)
sum = 0.0
- counter = 1
+ counter = 0
result = Hash.new#Array.new
cmd = @scr.execute(["rrdtool", "fetch", "#{@datapath}/#{rrdfile}", "AVERAGE",\
"--start"," #{start}", "--end", " #{stop}"])
@@ -96,7 +96,9 @@ class Status < ActiveRecord::Base
end
end
end
- result[labels[collumn-1]] = sum/(counter-1) unless counter == 1
+ result[labels[collumn-1]] = sum/(counter) unless counter == 0
+ sum, counter = 0.0, 0
+ collumn += 1
end
end
end
diff --git a/plugins/status/app/views/status/show.html.erb b/plugins/status/app/views/status/show.html.erb
index 2cc15b8..e02050f 100644
--- a/plugins/status/app/views/status/show.html.erb
+++ b/plugins/status/app/views/status/show.html.erb
@@ -1,2 +1,2 @@
-<%= @status.to_xml( :root => "status", :dasherize => false ) -%>
+<%= @status.data.to_xml( :root => "status", :dasherize => false ) -%>
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org