Class: RedisStat::Server
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- RedisStat::Server
- Defined in:
- lib/redis-stat/server.rb
Constant Summary collapse
- HISTORY_LENGTH =
50
- STAT_TABLE_ROWS =
10
Class Method Summary collapse
Class Method Details
.alert(error) ⇒ Object
106 107 108 109 110 111 |
# File 'lib/redis-stat/server.rb', line 106 def alert error settings.mutex.synchronize do settings.last_error = error end publish({ :error => error }) end |
.push(hosts, info, data, error) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/redis-stat/server.rb', line 88 def push hosts, info, data, error static = Hash[settings.redis_stat.tab_measures.map { |stat| [stat, hosts.map { |h| info[h][stat] }] }] data = {:at => (Time.now.to_f * 1000).to_i, :static => static, :dynamic => data, :error => error} settings.mutex.synchronize do settings.last_error = nil hist = settings.history hist << data hist.shift if hist.length > HISTORY_LENGTH end publish data end |