diff options
author | Eric Wong <normalperson@yhbt.net> | 2011-09-27 17:46:20 -0700 |
---|---|---|
committer | Eric Wong <normalperson@yhbt.net> | 2011-09-27 19:51:19 -0700 |
commit | e974e26fcfb78cd579556495a0635d30ec5c6976 (patch) | |
tree | fec8faa7399d0e7b245bfff5f19f9fb59d923071 /lib/raindrops/watcher.rb | |
parent | 9a42edb11efcd091623bb37a33a8ea97b39a1d85 (diff) | |
download | raindrops-e974e26fcfb78cd579556495a0635d30ec5c6976.tar.gz |
It can be useful to some to see that info all at once without hitting the HTML index page.
Diffstat (limited to 'lib/raindrops/watcher.rb')
-rw-r--r-- | lib/raindrops/watcher.rb | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/raindrops/watcher.rb b/lib/raindrops/watcher.rb index 66bc7b6..f343e43 100644 --- a/lib/raindrops/watcher.rb +++ b/lib/raindrops/watcher.rb @@ -172,14 +172,16 @@ class Raindrops::Watcher def active_stats(addr) # :nodoc: @lock.synchronize do tmp = @active[addr] or return - [ @snapshot[0], @resets[addr], tmp.dup ] + time, combined = @snapshot + [ time, @resets[addr], tmp.dup, combined[addr].active ] end end def queued_stats(addr) # :nodoc: @lock.synchronize do tmp = @queued[addr] or return - [ @snapshot[0], @resets[addr], tmp.dup ] + time, combined = @snapshot + [ time, @resets[addr], tmp.dup, combined[addr].queued ] end end @@ -204,9 +206,10 @@ class Raindrops::Watcher end def histogram_txt(agg) - updated_at, reset_at, agg = *agg + updated_at, reset_at, agg, current = *agg headers = agg_to_hash(reset_at, agg) body = agg.to_s + headers["X-Current"] = current.to_s headers["Content-Type"] = "text/plain" headers["Expires"] = (updated_at + @delay).httpdate headers["Content-Length"] = bytesize(body).to_s @@ -214,7 +217,7 @@ class Raindrops::Watcher end def histogram_html(agg, addr) - updated_at, reset_at, agg = *agg + updated_at, reset_at, agg, current = *agg headers = agg_to_hash(reset_at, agg) body = "<html>" \ "<head><title>#{hostname} - #{escape_html addr}</title></head>" \ @@ -225,6 +228,7 @@ class Raindrops::Watcher "<form action='/reset/#{escape addr}' method='post'>" \ "<input type='submit' name='x' value='reset' /></form>" \ "</body>" + headers["X-Current"] = current.to_s headers["Content-Type"] = "text/html" headers["Expires"] = (updated_at + @delay).httpdate headers["Content-Length"] = bytesize(body).to_s |