bloopletech-webstats 0.5.0 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :major: 0
3
- :minor: 5
4
- :patch: 1
3
+ :minor: 6
4
+ :patch: 0
@@ -4,14 +4,12 @@ class DataProviders::UrlMonitor
4
4
  def initialize(settings)
5
5
  @settings = self.class.default_settings.merge(settings)
6
6
 
7
- @readings = []
7
+ @readings = {}
8
8
 
9
9
  @mutex = Mutex.new
10
10
 
11
11
  @thread = Thread.new do
12
12
  while(true)
13
- @mutex.synchronize { @readings = [] }
14
-
15
13
  @settings[:urls].sort.each do |url|
16
14
  duration = -1
17
15
  works = false
@@ -22,7 +20,7 @@ class DataProviders::UrlMonitor
22
20
  works = true
23
21
  rescue Exception => e
24
22
  end
25
- @mutex.synchronize { @readings << [url, { :response_time => duration * 1000, :works => works }] }
23
+ @mutex.synchronize { @readings[url] = { :response_time => duration * 1000, :works => works } }
26
24
  end
27
25
  sleep(@settings[:update_rate])
28
26
  end
@@ -32,7 +30,7 @@ class DataProviders::UrlMonitor
32
30
 
33
31
  def get
34
32
  out = {}
35
- @mutex.synchronize { out[:urls] = @readings }
33
+ @mutex.synchronize { out[:urls] = @readings.to_a.sort_by { |e| e[0] } }
36
34
  out[:urls].each do |(url, info)|
37
35
  out[:status] = 'warning' if !info[:works] or info[:response_time] > @settings[:warning_response_time_threshold] and !out[:status] == 'danger'
38
36
  out[:status] = 'danger' if !info[:works] or info[:response_time] > @settings[:danger_response_time_threshold]
@@ -55,7 +53,7 @@ sc.innerHTML = temp;
55
53
  end
56
54
 
57
55
  def self.default_settings
58
- { :update_rate => 30, :warning_response_time_threshold => 5000, :danger_response_time_threshold => 30000, :urls => ['http://localhost/'] }
56
+ { :update_rate => 30, :warning_response_time_threshold => 5000, :danger_response_time_threshold => 15000, :urls => ['http://localhost/'] }
59
57
  end
60
58
 
61
59
  def information
data/server/webstats.rb CHANGED
@@ -60,6 +60,10 @@ class Array
60
60
  end
61
61
  end
62
62
 
63
+ def symbolize_keys!
64
+ each_with_index { |v, i| self[i] = self[i].dup.symbolize_keys! if v.is_a? Hash }
65
+ end
66
+
63
67
  def stringify_keys!
64
68
  each_with_index { |v, i| self[i] = self[i].dup.stringify_keys! if v.is_a? Hash }
65
69
  end
@@ -80,6 +84,11 @@ class Hash
80
84
  end
81
85
  end
82
86
 
87
+ def symbolize_keys!
88
+ keys.each { |key| self[key.to_sym] = delete(key) }
89
+ each_pair { |k, v| self[k] = self[k].dup.symbolize_keys! if v.is_a? Hash }
90
+ end
91
+
83
92
  def stringify_keys!
84
93
  keys.each { |key| self[key.to_s] = delete(key) }
85
94
  each_pair { |k, v| self[k] = self[k].dup.stringify_keys! if v.is_a? Hash }
@@ -125,7 +134,7 @@ WEBSTATS_PATH = File.expand_path("~/.webstats")
125
134
  $settings = {}
126
135
 
127
136
  if File.exists?(WEBSTATS_PATH)
128
- $settings = YAML.load(IO.read(WEBSTATS_PATH))
137
+ $settings = YAML.load(IO.read(WEBSTATS_PATH)).symbolize_keys!
129
138
  else
130
139
  $settings['webstats'] = { 'password' => nil }
131
140
  DataProviders::DATA_SOURCES_CLASSES.each_pair { |k, v| $settings[k.to_s] = v.default_settings.stringify_keys! }
data/webstats.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{webstats}
5
- s.version = "0.5.0"
5
+ s.version = "0.6.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Brenton Fletcher"]
9
- s.date = %q{2009-04-27}
9
+ s.date = %q{2009-04-28}
10
10
  s.description = %q{Monitor server CPU/Memory/Disk Usage/URL Loading, so that you can view those statistics on a web page, as well as providing an interface to client prorams to read those statistics.}
11
11
  s.email = %q{i@bloople.net}
12
12
  s.executables = ["webstats", "webstats_growl_notifier"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bloopletech-webstats
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brenton Fletcher
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-04-27 00:00:00 -07:00
12
+ date: 2009-04-28 00:00:00 -07:00
13
13
  default_executable:
14
14
  dependencies: []
15
15