Mailinglist Archive: yast-commit (883 mails)

< Previous Next >
[yast-commit] <rest-service> master : status module: enables selection of metrics
  • From: Bjoern Geuken <bgeuken@xxxxxxx>
  • Date: Tue, 7 Jul 2009 13:22:01 +0200
  • Message-id: <E1MO8l1-000856-PD@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit 768b13f3f3308c2f154b8abec5fcc0e5c2f1a395
Author: Bjoern Geuken <bgeuken@xxxxxxx>
Date: Tue Jul 7 13:22:01 2009 +0200

status module: enables selection of metrics
---
.../status/app/controllers/status_controller.rb | 2 +-
plugins/status/app/models/status.rb | 29 ++++++++++++++-----
2 files changed, 22 insertions(+), 9 deletions(-)

diff --git a/plugins/status/app/controllers/status_controller.rb
b/plugins/status/app/controllers/status_controller.rb
index c47ad9a..9293cbe 100644
--- a/plugins/status/app/controllers/status_controller.rb
+++ b/plugins/status/app/controllers/status_controller.rb
@@ -33,7 +33,7 @@ class StatusController < ApplicationController
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})
+ @status.collect_data("11:13,07/03/2009", "11:14,07/03/2009", %w{cpu
disk})

end
end
diff --git a/plugins/status/app/models/status.rb
b/plugins/status/app/models/status.rb
index fda9291..4769773 100644
--- a/plugins/status/app/models/status.rb
+++ b/plugins/status/app/models/status.rb
@@ -7,8 +7,6 @@ class Status < ActiveRecord::Base
@scr = Scr.instance
@health_status = nil
@data = Hash.new
- @cpu=""
- @memory=""
start_collectd
# @collectd_base_dir = "/var/lib/collectd/"
@datapath = set_datapath
@@ -70,15 +68,30 @@ class Status < ActiveRecord::Base
end

# creates several metrics for a defined period
- def collect_data(start=Time.now, stop=Time.now, data = %w{cpu memory disk})
+ def collect_data(start=Time.now, stop=Time.now, data = nil)
result = Hash.new
unless @timestamp.nil? # collectd not started
- @metrics.each_pair do |m, n|
- @metrics["#{m}"][:rrds].each do |rrdb|
- result["#{rrdb}".chomp(".rrd")] = fetch_metric("#{m}/#{rrdb}",
start, stop)
+ case data
+ when nil # all metrics
+ @metrics.each_pair do |m, n|
+ @metrics["#{m}"][:rrds].each do |rrdb|
+ result["#{rrdb}".chomp(".rrd")] = fetch_metric("#{m}/#{rrdb}",
start, stop)
+ end
+ @data["#{m}"] = result
+ result = Hash.new
+ end
+ else
+ data.each do |d|
+ @metrics.each_pair do |m, n|
+ if m.include?(d)
+ @metrics["#{m}"][:rrds].each do |rrdb|
+ result["#{rrdb}".chomp(".rrd")] = fetch_metric("#{m}/#{rrdb}",
start, stop)
+ end
+ @data["#{m}"] = result
+ result = Hash.new
+ end
+ end
end
- @data["#{m}"] = result
- result = Hash.new
end
end
return @data
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages