module TelemetryDaemon
Public Instance Methods
api_host(api_host)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 5 def api_host(api_host) Telemetry.api_host = api_host end
api_token(token)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 9 def api_token(token) Telemetry.token = token end
barchart(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 66 def barchart(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :barchart, tag, frequency, offset, block ] end
begin_interval(&block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 50 def begin_interval(&block) @@begin_interval = block end
box(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 76 def box(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :countdown, tag, frequency, offset, block ] end
bulletchart(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 71 def bulletchart(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :value, tag, frequency, offset, block ] end
clock(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 81 def clock(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :countdown, tag, frequency, offset, block ] end
compass(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 91 def compass(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :countdown, tag, frequency, offset, block ] end
countdown(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 86 def countdown(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :countdown, tag, frequency, offset, block ] end
custom(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 96 def custom(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :custom, tag, frequency, offset, block ] end
end_interval(&block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 58 def end_interval(&block) @@end_interval = block end
flows_expire_in(i)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 26 def flows_expire_in(i) @@flows_expire_in = i end
funnelchart(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 101 def funnelchart(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :funnelchart, tag, frequency, offset, block ] end
gauge(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 106 def gauge(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :gauge, tag, frequency, offset, block ] end
graph(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 111 def graph(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :graph, tag, frequency, offset, block ] end
grid(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 116 def grid(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :gid, tag, frequency, offset, block ] end
histogram(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 121 def histogram(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :histogram, tag, frequency, offset, block ] end
icon(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 126 def icon(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :icon, tag, frequency, offset, block ] end
iframe(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 136 def iframe(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :iframe, tag, frequency, offset, block ] end
image(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 131 def image(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :image, tag, frequency, offset, block ] end
interval(interval)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 21 def interval(interval) @@interval = interval end
log(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 141 def log(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :log, tag, frequency, offset, block ] end
log_level(log_level)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 13 def log_level(log_level) level = log_level.to_s if log_level == 'debug' Telemetry.logger.level = Logger::DEBUG Telemetry.logger.debug "Starting Debug Logging" end end
map(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 146 def map(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :map, tag, frequency, offset, block ] end
multigauge(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 151 def multigauge(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :multigauge, tag, frequency, offset, block ] end
multivalue(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 156 def multivalue(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :multivalue, tag, frequency, offset, block ] end
piechart(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 161 def piechart(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :piechart, tag, frequency, offset, block ] end
run_begin_interval()
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 54 def run_begin_interval @@begin_interval.yield if @@begin_interval end
run_end_interval()
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 62 def run_end_interval @@end_interval.yield if @@end_interval end
run_scheduled_flow_updates()
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 236 def run_scheduled_flow_updates @@buffer = {} @@tasks ||= {} @@next_run_at ||= {} @@tasks.each do |task| @@h = {} variant, tag, frequency, offset, block = task now = Time.now # Check whether we should wait an interval before running if frequency > 0 Telemetry::logger.debug "Task #{task[0]} #{task[1]} (every #{task[2]}s)" #Telemetry::logger.debug "Update frequency is #{frequency} now #{Time.now.to_i} next #{@@next_run_at[tag]}" if @@next_run_at[tag] && @@next_run_at[tag] > now.to_i Telemetry::logger.debug " - Not scheduled yet (waiting #{-(now.to_i - @@next_run_at[tag])}s)" next end @@next_run_at[tag] = now.to_i + frequency Telemetry::logger.debug " - Running intermittant task at #{now}" # If an offset is defined then align runtimes to the offset # How close you can get to the desired offset depends on the global interval. So set it relatively small # when using this feature if offset and offset >= 0 and offset <= 86400 this_morning = Time.new(now.year, now.month, now.day).to_i time_since_offset = now.to_i - this_morning - offset time_since_offset += 86400 if time_since_offset < 0 @@next_run_at[tag] -= time_since_offset % frequency #Telemetry::logger.debug "#{now.to_i} #{@@next_run_at[tag]}" end else Telemetry::logger.debug " - Task #{task[0]} #{task[1]}" end # Execute the flow Telemetry.logger.debug " + Executing task #{task[0]} #{task[1]}" block.yield if @@h == {} Telemetry.logger.debug " - Skipping empty task values #{task[0]} #{task[1]}" next end # Use global default to set expires_at field if necessary if @@flows_expire_in and not @@h[:expires_at] set expires_at: Time.now.to_i + @@flows_expire_in end values = @@h # Telemetry.logger.debug " - Values for #{task[0]} #{task[1]}:\n#{values}\n#{@@last_values[tag]}" # Telemetry.logger.debug "LV\n\n #{@@last_values}\n\n" @@buffer[tag] = values end @@buffer end
scatterplot(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 166 def scatterplot(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :scatterplot, tag, frequency, offset, block ] end
servers(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 171 def servers(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :servers, tag, frequency, offset, block ] end
set(x)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 42 def set(x) x.each {|k,v| @@h[k.to_sym] = v} end
set_json(x)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 38 def set_json(x) x.each {|k,v| @@h[k.to_sym] = MultiJson.load(v)} end
status(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 176 def status(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :servers, tag, frequency, offset, block ] end
table(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 181 def table(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :table, tag, frequency, offset, block ] end
text(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 186 def text(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :text, tag, frequency, offset, block ] end
tickertape(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 191 def tickertape(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :tickertape, tag, frequency, offset, block ] end
timechart(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 196 def timechart(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :timechart, tag, frequency, offset, block ] end
timeline(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 201 def timeline(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :timeline, tag, frequency, offset, block ] end
timeseries(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 206 def timeseries(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :timeseries, tag, frequency, offset, block ] end
upstatus(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 211 def upstatus(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :upstatus, tag, frequency, offset, block ] end
value(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 216 def value(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :value, tag, frequency, offset, block ] end
video(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 221 def video(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :value, tag, frequency, offset, block ] end
wait_for_interval_from(timestamp)
click to toggle source
Ensure a minimum of 1 second between loops
# File lib/telemetry/daemon_config_parser.rb, line 31 def wait_for_interval_from(timestamp) @@interval ||= 60 @@interval = 1.0 if @@interval < 1 sleep_length = timestamp + @@interval.to_f - Time.now.to_f sleep sleep_length if sleep_length > 0 end
waterfall(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 226 def waterfall(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :waterfall, tag, frequency, offset, block ] end
weather(tag, frequency = 0, offset=nil, &block)
click to toggle source
# File lib/telemetry/daemon_config_parser.rb, line 231 def weather(tag, frequency = 0, offset=nil, &block) @@tasks ||= [] @@tasks << [ :countdown, tag, frequency, offset, block ] end