From bc3f69c3d04c1d425f95fb644c3700b291243d6d Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Wed, 6 Jul 2011 19:01:02 +0200 Subject: [PATCH] feature #696: use configuration file for window size and db uri --- src/acct/etc/acctd.conf | 16 +++++++++++----- src/acct/watch_helper.rb | 18 +++++++++++++++--- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/src/acct/etc/acctd.conf b/src/acct/etc/acctd.conf index 1eb11c4a58..c1c968a084 100644 --- a/src/acct/etc/acctd.conf +++ b/src/acct/etc/acctd.conf @@ -14,14 +14,20 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -# Duration of each daemon loop in seconds -:STEP: 1 +# Database URI +:DB: sqlite:///tmp/test_one_acct.db + +# Duration of each daemon loop in seconds +:STEP: 2 # Number of daemon loops until an accounting watch :ACCOUNTING_STEPS: 1 -# Number of daemon loops until a monitiroing watch -:MONITORING_STEPS: 1 +# Number of daemon loops until a VM monitoring watch +:VM_MONITORING_STEPS: 1 + +# Number of daemon loops until a Hosts monitoring watch +:HOST_MONITORING_STEPS: 1 # Number of records to preserve -:WINDOW_SIZE: 5 +:WINDOW_SIZE: 10 diff --git a/src/acct/watch_helper.rb b/src/acct/watch_helper.rb index a04e7301fc..ef0e5bca5d 100644 --- a/src/acct/watch_helper.rb +++ b/src/acct/watch_helper.rb @@ -1,5 +1,17 @@ module WatchHelper - DB = Sequel.connect('sqlite:///tmp/test_one_acct.db') + require 'yaml' + + ONE_LOCATION=ENV["ONE_LOCATION"] + + if !ONE_LOCATION + ACCTD_CONF="/etc/one/acctd.conf" + else + ACCTD_CONF=ONE_LOCATION+"/etc/acctd.conf" + end + + CONF = YAML.load_file(ACCTD_CONF) + + DB = Sequel.connect(CONF[:DB]) VM_SAMPLE = { :cpu => { @@ -275,7 +287,7 @@ module WatchHelper private def control_regs(sample) - if self.samples.count > 4 + if self.samples.count > CONF[:WINDOW_SIZE] - 1 self.samples.first.delete end end @@ -316,7 +328,7 @@ module WatchHelper private def control_regs(sample) - if self.samples.count > 4 + if self.samples.count > CONF[:WINDOW_SIZE] - 1 self.samples.first.delete end end