Mailinglist Archive: yast-commit (883 mails)

< Previous Next >
[yast-commit] <rest-service> master : status module: fixed call of fetch_metric() with empty parameter, eg.""
  • From: Bjoern Geuken <bgeuken@xxxxxxx>
  • Date: Wed, 8 Jul 2009 09:20:27 +0200
  • Message-id: <E1MORSR-0001nA-DY@xxxxxxxxxxxxxxxx>
ref: refs/heads/master
commit e5cdee7e7bc6705e4b7ecdf421599d6865264702
Author: Bjoern Geuken <bgeuken@xxxxxxx>
Date: Wed Jul 8 09:20:27 2009 +0200

status module: fixed call of fetch_metric() with empty parameter, eg.""
---
plugins/status/app/models/status.rb | 20 +++++++++++++++-----
1 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/plugins/status/app/models/status.rb
b/plugins/status/app/models/status.rb
index c91762a..d8c7dfd 100644
--- a/plugins/status/app/models/status.rb
+++ b/plugins/status/app/models/status.rb
@@ -70,7 +70,7 @@ class Status < ActiveRecord::Base
# creates several metrics for a defined period
def collect_data(start=Time.now, stop=Time.now, data = %w{cpu memory disk})
result = Hash.new
- unless @timestamp.nil? # collectd not start
+ unless @timestamp.nil? # collectd not started
case data
when nil, "all", "All" # all metrics
@metrics.each_pair do |m, n|
@@ -98,13 +98,23 @@ class Status < ActiveRecord::Base
end

# creates one metric for defined period
- def fetch_metric(rrdfile, start=Time.now, stop=Time.now)
+ def fetch_metric(rrdfile, start=nil, stop=nil)
result = Hash.new
- cmd = IO.popen("rrdtool fetch #{@datapath}/#{rrdfile} AVERAGE "\
- "--start #{start} --end #{stop}")
+ if start.blank?
+ start = "--start #{Time.now.strftime("%H:%M,%m/%d/%Y")}"
+ else
+ start = "--start #{start}"
+ end
+ if stop.blank?
+ stop = "--end #{Time.now.strftime("%H:%M,%m/%d/%Y")}"
+ else
+ stop = "--end #{stop}"
+ end
+ cmd = IO.popen("rrdtool fetch #{@datapath}/#{rrdfile} AVERAGE #{start}
#{stop}")
+
output = cmd.read
cmd.close
- return nil if output.nil?
+ return nil if output.blank?

labels=""
output = output.gsub(",", ".") # translates eg. 1,234e+07 to 1.234e+07
--
To unsubscribe, e-mail: yast-commit+unsubscribe@xxxxxxxxxxxx
For additional commands, e-mail: yast-commit+help@xxxxxxxxxxxx

< Previous Next >
This Thread
  • No further messages