Class: Fluent::AppdynamicsInput::RedisStateStore
- Inherits:
-
Object
- Object
- Fluent::AppdynamicsInput::RedisStateStore
- Defined in:
- lib/fluent/plugin/in_appdynamics.rb
Overview
Class store in redis
Instance Method Summary collapse
-
#initialize(path, tag) ⇒ RedisStateStore
constructor
A new instance of RedisStateStore.
- #last_records(tag = nil) ⇒ Object
- #update_records(time, tag = nil) ⇒ Object
Constructor Details
#initialize(path, tag) ⇒ RedisStateStore
Returns a new instance of RedisStateStore.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/fluent/plugin/in_appdynamics.rb', line 87 def initialize(path,tag) state_key=tag #redis_server = $appsettings['redis_server'] #redis_port = $appsettings['redis_port'] #redis_spectrum_key = $appsettings['redis_spectrum_key'] ##### require 'redis' $redis = if File.exists?(path) redis_config = YAML.load_file(path) # Connect to Redis using the redis_config host and port if path begin pp "In redis #{path} Host #{redis_config['host']} port #{redis_config['port']}" $redis = Redis.new(host: redis_config['host'], port: redis_config['port']) rescue Exception => e $log.info e. $log.info e.backtrace.inspect end end else Redis.new end @data = {} end |
Instance Method Details
#last_records(tag = nil) ⇒ Object
112 113 114 115 116 117 118 119 120 |
# File 'lib/fluent/plugin/in_appdynamics.rb', line 112 def last_records(tag=nil) begin alertStart=$redis.get(tag) return alertStart rescue Exception => e $log.info e. $log.info e.backtrace.inspect end end |
#update_records(time, tag = nil) ⇒ Object
122 123 124 125 126 127 128 129 |
# File 'lib/fluent/plugin/in_appdynamics.rb', line 122 def update_records(time, tag=nil) begin alertStart=$redis.set(tag,time) rescue Exception => e $log.info e. $log.info e.backtrace.inspect end end |