ref: refs/heads/master
commit f39e53bb37a447c88671f4d2e00d552adf44ac69
Author: Ladislav Slezak
Date: Thu Nov 5 13:26:52 2009 +0100
use backticks instead of IO.popen and set LC_ALL=C
---
plugins/status/app/models/metric.rb | 11 ++---------
plugins/status/lib/status.rb | 6 +-----
2 files changed, 3 insertions(+), 14 deletions(-)
diff --git a/plugins/status/app/models/metric.rb b/plugins/status/app/models/metric.rb
index 1ee4056..f3e0919 100644
--- a/plugins/status/app/models/metric.rb
+++ b/plugins/status/app/models/metric.rb
@@ -253,13 +253,8 @@ class Metric
stop = opts.has_key?(:stop) ? opts[:stop] : Time.now
start = opts.has_key?(:start) ? opts[:start] : stop - 300
- cmdline = "rrdtool fetch #{file} AVERAGE --start #{start.to_i} --end #{stop.to_i}"
- Rails.logger.debug "running #{cmdline}"
- cmd = IO.popen(cmdline)
- output = cmd.read
- cmd.close
-
- raise output if $?.exitstatus != 0
+ output = `/bin/sh -c "LC_ALL=C rrdtool fetch #{file} AVERAGE --start #{start.to_i} --end #{stop.to_i}"`
+ raise output unless $?.exitstatus.zero?
output
end
@@ -271,8 +266,6 @@ class Metric
raise "Error running collectd rrdtool" if output =~ /ERROR/ or output.nil?
- output = output.gsub(",", ".") # translates eg. 1,234e+07 to 1.234e+07
-
line_count = 0
result["starttime"] = 9.9e+99
diff --git a/plugins/status/lib/status.rb b/plugins/status/lib/status.rb
index 81507f2..d50cd6b 100644
--- a/plugins/status/lib/status.rb
+++ b/plugins/status/lib/status.rb
@@ -171,10 +171,7 @@ class Status
# fetch last 5 minutes
start = stop - 300 if start.nil?
- cmd = IO.popen("rrdtool fetch #{file} AVERAGE --start #{start.strftime("%H:%M,%m/%d/%Y")} --end #{stop.strftime("%H:%M,%m/%d/%Y")}")
- output = cmd.read
- cmd.close
- output
+ `/bin/sh -c "LC_ALL=C rrdtool fetch #{file} AVERAGE --start #{start.strftime("%H:%M,%m/%d/%Y")} --end #{stop.strftime("%H:%M,%m/%d/%Y")}"`
end
# creates one metric for defined period
@@ -189,7 +186,6 @@ class Status
raise "Error running collectd rrdtool" if output =~ /ERROR/ or output.nil?
labels=""
- output = output.gsub(",", ".") # translates eg. 1,234e+07 to 1.234e+07
lines = output.split "\n"
# set label names
--
To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org
For additional commands, e-mail: yast-commit+help@opensuse.org