server/data_providers/disk_activity.rb in bloopletech-webstats-0.1.0 vs server/data_providers/disk_activity.rb in bloopletech-webstats-0.2.0

- old
+ new

@@ -1,7 +1,9 @@ class DataProviders::DiskActivity - def initialize + def initialize(settings) + @settings = self.class.default_settings.merge(settings) + @reads_sec = 0 @writes_sec = 0 @thread = Thread.new do last_time = last_reads = last_writes = 0 @@ -18,31 +20,31 @@ @writes_sec = ((writes - last_writes) / ((time - last_time).to_f / 1000.0)) * 512 end last_reads = reads last_writes = writes last_time = time - sleep(2.5) + sleep(@settings[:update_rate]) end end end def get { :reads => @reads_sec / 1024.0, :writes => @writes_sec / 1024.0 } end def renderer - information.merge({ :name => "Disk Activity", :in_sentence => "Disk Activity", :importance => importance, :contents => %{ + information.merge({ :contents => %{ sc.innerHTML = "<div class='major_figure'><span class='title'>Reads</span><span class='figure'>" + data_source['reads'] + "</span><span class='unit'>mb/s</span></div>" + "<div class='major_figure'><span class='title'>Writes</span><span class='figure'>" + data_source['writes'] + "</span><span class='unit'>mb/s</span></div>"; } }) end - def information - { :name => "Disk Activity", :in_sentence => "Disk Activity", :importance => importance } + def self.default_settings + { :update_rate => 2.5 } end - def importance - 70 + def information + { :name => "Disk Activity", :in_sentence => "Disk Activity", :importance => 70 } end def kill @thread.kill end \ No newline at end of file