Class: ManageEngine::APMConfig
- Inherits:
-
Object
- Object
- ManageEngine::APMConfig
- Defined in:
- lib/agent/configuration/am_configuration.rb
Instance Attribute Summary collapse
-
#agent_enabled ⇒ Object
readonly
Returns the value of attribute agent_enabled.
-
#agenthost ⇒ Object
readonly
Returns the value of attribute agenthost.
-
#agentport ⇒ Object
readonly
Returns the value of attribute agentport.
-
#alreadyconnected ⇒ Object
readonly
Returns the value of attribute alreadyconnected.
-
#apdex_t ⇒ Object
readonly
Returns the value of attribute apdex_t.
-
#apmhost ⇒ Object
readonly
Returns the value of attribute apmhost.
-
#apmport ⇒ Object
readonly
Returns the value of attribute apmport.
-
#app_db ⇒ Object
Returns the value of attribute app_db.
-
#app_dispatcher ⇒ Object
Returns the value of attribute app_dispatcher.
-
#appname ⇒ Object
readonly
Returns the value of attribute appname.
-
#connect_interval ⇒ Object
readonly
Returns the value of attribute connect_interval.
-
#connection_retry ⇒ Object
readonly
Returns the value of attribute connection_retry.
-
#db_operations ⇒ Object
readonly
Returns the value of attribute db_operations.
-
#dbmetric_overflow_t ⇒ Object
readonly
Returns the value of attribute dbmetric_overflow_t.
-
#hostType ⇒ Object
readonly
Returns the value of attribute hostType.
-
#instance_id ⇒ Object
readonly
Returns the value of attribute instance_id.
-
#is_secured ⇒ Object
readonly
Returns the value of attribute is_secured.
-
#lastupdatedtime ⇒ Object
Returns the value of attribute lastupdatedtime.
-
#license_key ⇒ Object
readonly
Returns the value of attribute license_key.
-
#logs_dir ⇒ Object
readonly
Returns the value of attribute logs_dir.
-
#metric_overflow_t ⇒ Object
readonly
Returns the value of attribute metric_overflow_t.
-
#proxy_host ⇒ Object
readonly
Returns the value of attribute proxy_host.
-
#proxy_pass ⇒ Object
readonly
Returns the value of attribute proxy_pass.
-
#proxy_port ⇒ Object
readonly
Returns the value of attribute proxy_port.
-
#proxy_user ⇒ Object
readonly
Returns the value of attribute proxy_user.
-
#proxyneeded ⇒ Object
readonly
Returns the value of attribute proxyneeded.
-
#site24x7 ⇒ Object
readonly
Returns the value of attribute site24x7.
-
#site24x7url ⇒ Object
readonly
Returns the value of attribute site24x7url.
-
#sql_capture ⇒ Object
readonly
Returns the value of attribute sql_capture.
-
#sql_capture_params ⇒ Object
readonly
Returns the value of attribute sql_capture_params.
-
#sql_trace_t ⇒ Object
readonly
Returns the value of attribute sql_trace_t.
-
#trace_overflow_t ⇒ Object
readonly
Returns the value of attribute trace_overflow_t.
-
#trans_trace ⇒ Object
readonly
Returns the value of attribute trans_trace.
-
#trans_trace_t ⇒ Object
readonly
Returns the value of attribute trans_trace_t.
-
#txn_skip_listen ⇒ Object
readonly
Returns the value of attribute txn_skip_listen.
-
#url_merge_pattern ⇒ Object
readonly
Returns the value of attribute url_merge_pattern.
Instance Method Summary collapse
- #assignConfig ⇒ Object
- #checkAgentInfo ⇒ Object
-
#checkAndGetEnvValue(data) ⇒ Object
Checks whether the given value is Environment Variable.
- #checkLicenseFile ⇒ Object
- #configureFile ⇒ Object
- #getAgentConfigData ⇒ Object
- #getAgentInfo ⇒ Object
- #getDispatcher ⇒ Object
- #getEnvData ⇒ Object
- #getHostType ⇒ Object
-
#initialize ⇒ APMConfig
constructor
A new instance of APMConfig.
- #initValues ⇒ Object
- #isFloat(default, value) ⇒ Object
- #isInteger(default, value) ⇒ Object
- #store_encrypted_data(config) ⇒ Object
- #update_config(configInfo) ⇒ Object
- #updateAgentInfoFile(props) ⇒ Object
- #urlMergePattern ⇒ Object
Constructor Details
#initialize ⇒ APMConfig
Returns a new instance of APMConfig.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/agent/configuration/am_configuration.rb', line 14 def initialize @obj = ManageEngine::APMObjectHolder.instance #@config = @obj.util.readProperties(@obj.constants.apm_conf) configureFile @agenthost = Socket.gethostname assignConfig @obj.log.setLevel @config["apminsight.log.level"] @instance_id = 0 @agent_enabled = false @alreadyconnected = checkAgentInfo @site24x7 = checkLicenseFile if (@site24x7) @site24x7url = @license_key.start_with?('eu_') ? @obj.constants.site24x7EUurl : @license_key.start_with?('cn_') ? @obj.constants.site24x7CNurl : @license_key.start_with?('au_') ? @obj.constants.site24x7AUurl : @license_key.start_with?('in_') ? @obj.constants.site24x7INurl : @obj.constants.site24x7USurl end @db_operations =["select","insert","update","delete"] urlMergePattern @hostType = getHostType @obj.log.info "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" @obj.log.info "APP HOME #{File.absolute_path(".")} " @obj.log.info "APP HOME #{Dir.pwd} " @obj.log.info "Agent Version : #{ManageEngine::APMInsight::VERSION}" #@obj.log.info "Configuration : " #@obj.log.info "Hostname : #{@agenthost}" @obj.log.info "Host Type: #{@hostType}" @obj.log.info "Agent Already Connected : #{@alreadyconnected}" @obj.log.info "Agent Enabled : #{@agent_enabled}" @obj.log.info "Allowed DB Operations : #{@db_operations}" # @config.each do|key,val| # @obj.log.info "#{key} => #{val}" # end @obj.log.info "URL Merge Patterns" @url_merge_pattern.each do |key, val| @obj.log.info "#{key} => #{val}" end @obj.log.info "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" @app_db="dummydb" @app_dispatcher = getDispatcher @lastupdatedtime=File.mtime(@obj.constants.apm_conf).to_i end |
Instance Attribute Details
#agent_enabled ⇒ Object (readonly)
Returns the value of attribute agent_enabled.
12 13 14 |
# File 'lib/agent/configuration/am_configuration.rb', line 12 def agent_enabled @agent_enabled end |
#agenthost ⇒ Object (readonly)
Returns the value of attribute agenthost.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def agenthost @agenthost end |
#agentport ⇒ Object (readonly)
Returns the value of attribute agentport.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def agentport @agentport end |
#alreadyconnected ⇒ Object (readonly)
Returns the value of attribute alreadyconnected.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def alreadyconnected @alreadyconnected end |
#apdex_t ⇒ Object (readonly)
Returns the value of attribute apdex_t.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def apdex_t @apdex_t end |
#apmhost ⇒ Object (readonly)
Returns the value of attribute apmhost.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def apmhost @apmhost end |
#apmport ⇒ Object (readonly)
Returns the value of attribute apmport.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def apmport @apmport end |
#app_db ⇒ Object
Returns the value of attribute app_db.
13 14 15 |
# File 'lib/agent/configuration/am_configuration.rb', line 13 def app_db @app_db end |
#app_dispatcher ⇒ Object
Returns the value of attribute app_dispatcher.
13 14 15 |
# File 'lib/agent/configuration/am_configuration.rb', line 13 def app_dispatcher @app_dispatcher end |
#appname ⇒ Object (readonly)
Returns the value of attribute appname.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def appname @appname end |
#connect_interval ⇒ Object (readonly)
Returns the value of attribute connect_interval.
12 13 14 |
# File 'lib/agent/configuration/am_configuration.rb', line 12 def connect_interval @connect_interval end |
#connection_retry ⇒ Object (readonly)
Returns the value of attribute connection_retry.
12 13 14 |
# File 'lib/agent/configuration/am_configuration.rb', line 12 def connection_retry @connection_retry end |
#db_operations ⇒ Object (readonly)
Returns the value of attribute db_operations.
12 13 14 |
# File 'lib/agent/configuration/am_configuration.rb', line 12 def db_operations @db_operations end |
#dbmetric_overflow_t ⇒ Object (readonly)
Returns the value of attribute dbmetric_overflow_t.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def dbmetric_overflow_t @dbmetric_overflow_t end |
#hostType ⇒ Object (readonly)
Returns the value of attribute hostType.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def hostType @hostType end |
#instance_id ⇒ Object (readonly)
Returns the value of attribute instance_id.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def instance_id @instance_id end |
#is_secured ⇒ Object (readonly)
Returns the value of attribute is_secured.
12 13 14 |
# File 'lib/agent/configuration/am_configuration.rb', line 12 def is_secured @is_secured end |
#lastupdatedtime ⇒ Object
Returns the value of attribute lastupdatedtime.
13 14 15 |
# File 'lib/agent/configuration/am_configuration.rb', line 13 def lastupdatedtime @lastupdatedtime end |
#license_key ⇒ Object (readonly)
Returns the value of attribute license_key.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def license_key @license_key end |
#logs_dir ⇒ Object (readonly)
Returns the value of attribute logs_dir.
12 13 14 |
# File 'lib/agent/configuration/am_configuration.rb', line 12 def logs_dir @logs_dir end |
#metric_overflow_t ⇒ Object (readonly)
Returns the value of attribute metric_overflow_t.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def metric_overflow_t @metric_overflow_t end |
#proxy_host ⇒ Object (readonly)
Returns the value of attribute proxy_host.
12 13 14 |
# File 'lib/agent/configuration/am_configuration.rb', line 12 def proxy_host @proxy_host end |
#proxy_pass ⇒ Object (readonly)
Returns the value of attribute proxy_pass.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def proxy_pass @proxy_pass end |
#proxy_port ⇒ Object (readonly)
Returns the value of attribute proxy_port.
12 13 14 |
# File 'lib/agent/configuration/am_configuration.rb', line 12 def proxy_port @proxy_port end |
#proxy_user ⇒ Object (readonly)
Returns the value of attribute proxy_user.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def proxy_user @proxy_user end |
#proxyneeded ⇒ Object (readonly)
Returns the value of attribute proxyneeded.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def proxyneeded @proxyneeded end |
#site24x7 ⇒ Object (readonly)
Returns the value of attribute site24x7.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def site24x7 @site24x7 end |
#site24x7url ⇒ Object (readonly)
Returns the value of attribute site24x7url.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def site24x7url @site24x7url end |
#sql_capture ⇒ Object (readonly)
Returns the value of attribute sql_capture.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def sql_capture @sql_capture end |
#sql_capture_params ⇒ Object (readonly)
Returns the value of attribute sql_capture_params.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def sql_capture_params @sql_capture_params end |
#sql_trace_t ⇒ Object (readonly)
Returns the value of attribute sql_trace_t.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def sql_trace_t @sql_trace_t end |
#trace_overflow_t ⇒ Object (readonly)
Returns the value of attribute trace_overflow_t.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def trace_overflow_t @trace_overflow_t end |
#trans_trace ⇒ Object (readonly)
Returns the value of attribute trans_trace.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def trans_trace @trans_trace end |
#trans_trace_t ⇒ Object (readonly)
Returns the value of attribute trans_trace_t.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def trans_trace_t @trans_trace_t end |
#txn_skip_listen ⇒ Object (readonly)
Returns the value of attribute txn_skip_listen.
12 13 14 |
# File 'lib/agent/configuration/am_configuration.rb', line 12 def txn_skip_listen @txn_skip_listen end |
#url_merge_pattern ⇒ Object (readonly)
Returns the value of attribute url_merge_pattern.
12 13 14 |
# File 'lib/agent/configuration/am_configuration.rb', line 12 def url_merge_pattern @url_merge_pattern end |
Instance Method Details
#assignConfig ⇒ Object
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 |
# File 'lib/agent/configuration/am_configuration.rb', line 165 def assignConfig initValues @config.each do |key,value| value = checkAndGetEnvValue(value) case key when "application.name" then @appname=value if (ENV.has_key?('APM_APPLICATION_NAME')) @appname = ENV['APM_APPLICATION_NAME'] end when "apm.host" then @apmhost=value when "apm.port" then @apmport=isInteger(@apmport,value) when "license.key" then @license_key=value if (@license_key.empty? && ENV.has_key?('S247_LICENSE_KEY')) @license_key = ENV['S247_LICENSE_KEY'] end when "behind.proxy" then @proxyneeded=@obj.util.getBooleanValue value when "agent.server.port" then @agentport=isInteger(@agentport,value) when "apdex.threshold" then @apdex_t=isFloat(@apdex_t,value) when "transaction.trace.enabled" then @trans_trace=@obj.util.getBooleanValue value when "transaction.trace.threshold" then @trans_trace_t=isFloat(@trans_trace_t,value) when "sql.capture.enabled" then @sql_capture=@obj.util.getBooleanValue value when "transaction.trace.sql.parametrize" then @sql_capture_params=@obj.util.getBooleanValue value when "transaction.trace.sql.stacktrace.threshold" then @sql_trace_t=isFloat(@sql_trace_t,value) when "proxy.server.host" then @proxy_host=value when "proxy.server.port" then @proxy_port=isInteger(@proxy_port,value) when "proxy.auth.username" then @proxy_user=value when "proxy.auth.password" then @proxy_pass=@obj.util.decrypt value, @license_key if (@proxy_pass == nil) @proxy_pass = value end when "apm.protocol.https" then @is_secured=@obj.util.getBooleanValue value when "apminsight.log.dir" then @logs_dir=value when "apminsight.log.level" then @obj.log.setLevel value when "agent.connection.retry" then @connection_retry=value #Not in Conf - yet to come when "agent.polling.interval" then @connect_interval=isInteger(@connect_interval, value)#Not in Conf - yet to come when "transaction.skip.listening" then @txn_skip_listen=@obj.util.getArray value.gsub("\s", ""),"," when "metricstore.metric.bucket.size" then @metric_overflow_t = isInteger(@metric_overflow_t, value) when "metricstore.dbmetric.bucket.size" then @dbmetric_overflow_t = isInteger(@dbmetric_overflow_t, value) when "transaction.tracestore.size" then @trace_overflow_t = isInteger(@trace_overflow_t, value) end end store_encrypted_data(@config) end |
#checkAgentInfo ⇒ Object
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/agent/configuration/am_configuration.rb', line 90 def checkAgentInfo if FileTest.exists?(@obj.constants.agent_conf) @obj.log.debug "Status : Agent Already Connected" props = @obj.util.readProperties(@obj.constants.agent_conf) instance_id = props["agent.id"] if (instance_id == nil || instance_id == "") # If instance id is not found or empty, it means the apminsight.info is being modified by user # Ignore all its entry @obj.log.warn "File: #{@obj.constants.agent_conf} is corrupted. Agent will continue ignoring these values." return false else @instance_id = instance_id end @agent_enabled= @obj.util.getBooleanValue props["agent.enabled"] true else @obj.log.info "Status : Agent not connected" false end end |
#checkAndGetEnvValue(data) ⇒ Object
Checks whether the given value is Environment Variable
210 211 212 213 214 215 216 217 218 219 |
# File 'lib/agent/configuration/am_configuration.rb', line 210 def checkAndGetEnvValue(data) begin value = "#{data}"[/\{(.*)\}/,1] if (value != nil && ENV.has_key?(value)) return data.gsub(/\{.*\}/, ENV[value]) end rescue Exception=>e end return data end |
#checkLicenseFile ⇒ Object
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/agent/configuration/am_configuration.rb', line 113 def checkLicenseFile if(@license_key != nil) @obj.log.info "License key is not null. Connecting to site24x7" @obj.constants.setLicenseKey @license_key true else @obj.log.info "License key is null. Connecting to APPManager" false end end |
#configureFile ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/agent/configuration/am_configuration.rb', line 55 def configureFile begin if(FileTest.exists?(@obj.constants.apm_conf)) #conf file exists in APPlication Home @obj.log.debug "Config File Exists. It is read from #{@obj.constants.apm_conf}" @config = @obj.util.readProperties(@obj.constants.apm_conf) else gemSpecs = Gem.loaded_specs[@obj.constants.s247_apm_gem] if (gemSpecs == nil) gemSpecs = Gem.loaded_specs[@obj.constants.apm_gem] end gem_conf = gemSpecs.full_gem_path #gem_conf = File.join(gem_conf, 'lib') gem_conf = File.join(gem_conf, 'conf') gem_conf = File.join(gem_conf, 'apminsight.conf') #conf file not exists in APPlications Home. So 1. copy it for gem locations if @obj.util.copyFiles gem_conf,@obj.constants.apm_conf #copied sucessfully @obj.log.info "Config File copied to application home directory. It is read from #{@obj.constants.apm_conf}" @config = @obj.util.readProperties(@obj.constants.apm_conf) else #Problem in copying, so reading props from Conf file in Gem Location @obj.log.warn "Config File not copied. It is read from #{gem_conf}" @config = @obj.util.readProperties(gem_conf) end end rescue Exception=>e @obj.log.info "[Exception] Problem in Reading Configuration File : \n File : #{@obj.constants.apm_conf}" @obj.log.logException "#{e.message}",e @config = @obj.util.readProperties(gem_conf) ensure end end |
#getAgentConfigData ⇒ Object
301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 |
# File 'lib/agent/configuration/am_configuration.rb', line 301 def getAgentConfigData agentconfig = Hash.new agentconfig["last.modified.time"]=@lastupdatedtime*1000 agentconfig["apdex.threshold"]=@apdex_t agentconfig["sql.capture.enabled"]=0 if @sql_capture agentconfig["sql.capture.enabled"]=1 end agentconfig["transaction.trace.enabled"]=0 if @trans_trace agentconfig["transaction.trace.enabled"]=1 end agentconfig["transaction.trace.threshold"]=@trans_trace_t agentconfig["transaction.trace.sql.parametrize"]=0 if @sql_capture_params agentconfig["transaction.trace.sql.parametrize"]=1 end agentconfig["transaction.trace.sql.stacktrace.threshold"]=@sql_trace_t agentconfig["transaction.tracking.request.interval"]=1 agentconfig end |
#getAgentInfo ⇒ Object
276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/agent/configuration/am_configuration.rb', line 276 def getAgentInfo data = Hash.new agentdata = Hash.new agentdata = {"application.type"=>"RUBY","application.name"=>@appname,"hostname"=>@agenthost,"port"=>@agentport,"agent.version"=>ManageEngine::APMInsight::MAJOR_VERSION} if (@hostType != nil) agentdata["host.type"]=@hostType end data["agent_info"]=agentdata data["environment"]=getEnvData data["custom_config_info"]=getAgentConfigData data end |
#getDispatcher ⇒ Object
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 |
# File 'lib/agent/configuration/am_configuration.rb', line 323 def getDispatcher @obj.log.info "Server: #{ENV['SERVER_SOFTWARE']}" dispatcher = "unknown" if defined?(PhusionPassenger) then dispatcher = "passenger" end if defined?(Unicorn) then dispatcher = "unicorn" end if defined?(Rainbows) then dispatcher = "rainbows" end dispatcher end |
#getEnvData ⇒ Object
289 290 291 292 293 294 295 296 297 298 299 |
# File 'lib/agent/configuration/am_configuration.rb', line 289 def getEnvData env = Hash.new begin ENV.to_hash.each do |key, value| env[key] = value end #env["Application Path"]="#{Rails.root}" rescue Exception=>e end env end |
#getHostType ⇒ Object
246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 |
# File 'lib/agent/configuration/am_configuration.rb', line 246 def getHostType begin # Check for AWS environment # response = Net::HTTP.get_response(URI('http://169.254.169.254/latest/meta-data/')) url = URI.parse('http://169.254.169.254/latest/meta-data/') request = Net::HTTP::Get.new(url.path) response = Net::HTTP.start(url.host, url.port, :read_timeout => 2) {|http| http.request(request)} if (response.kind_of? Net::HTTPOK) @hostType = "AWS" return @hostType end rescue Exception => e end begin #Check for Azure environment # response = Net::HTTP.get_response(URI('http://169.254.169.254/metadata/v1/maintenance')) url = URI.parse('http://169.254.169.254/metadata/v1/maintenance') request = Net::HTTP::Get.new(url.path) response = Net::HTTP.start(url.host, url.port, :read_timeout => 2) {|http| http.request(request)} if (response.kind_of? Net::HTTPOK) @hostType = "AZURE" return @hostType end rescue Exception => e end @hostType = nil end |
#initValues ⇒ Object
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/agent/configuration/am_configuration.rb', line 143 def initValues @apmport=8080 @appname="My Application" @proxyneeded = false @proxy_host="localhost" @proxy_port=80 @proxy_user="" @proxy_pass="" @is_secured=false @logs_dir="./log" @connection_retry = 0 @connect_interval = 60 @apdex_t=0.5 @txn_skip_listen=Array.new @trans_trace_t=2 @sql_trace_t=3 @metric_overflow_t=250 @dbmetric_overflow_t=500 @trace_overflow_t=30 @site24x7url = @obj.constants.site24x7USurl #default agent communication URL end |
#isFloat(default, value) ⇒ Object
350 351 352 353 354 355 356 357 |
# File 'lib/agent/configuration/am_configuration.rb', line 350 def isFloat default,value if @obj.util.is_float value value.to_f else default.to_f @obj.log.info "Problem in getting Integer Value #{value} .. So setting default value #{default} " end end |
#isInteger(default, value) ⇒ Object
340 341 342 343 344 345 346 347 348 |
# File 'lib/agent/configuration/am_configuration.rb', line 340 def isInteger default,value if @obj.util.is_integer value value.to_i else @obj.log.info "Problem in getting Integer Value #{value} .. So setting default value #{default} " default.to_i end end |
#store_encrypted_data(config) ⇒ Object
221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/agent/configuration/am_configuration.rb', line 221 def store_encrypted_data config data = config["proxy.auth.password"] if (data != nil && @obj.util.decrypt(data, @license_key) == nil) # checking whether data is already encrypted begin file_contents = "" conf_file = File.open(@obj.constants.apm_conf, 'r') conf_file.read.each_line do |line| if line.start_with?("proxy.auth.password") file_contents += "proxy.auth.password=" + @obj.util.encrypt(config["proxy.auth.password"], @license_key) else file_contents += line end #file_contents += "\n" end #end of do read loop conf_file.close conf_file = File.open(@obj.constants.apm_conf, "w+") conf_file.puts file_contents conf_file.close file_contents = nil # clearing memory rescue Exception=>e @obj.log.logException "Error while encrypting file", e end end # if already encrypted end |
#update_config(configInfo) ⇒ Object
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 |
# File 'lib/agent/configuration/am_configuration.rb', line 359 def update_config configInfo filepath = @obj.constants.apm_conf f = "apminsight.conf.new" begin propsFile=File.open(filepath, 'r') file = File.new(f,"w+") propsFile.read.each_line do |line| line.strip! if (line[0] != ?# and line[0] != ?=) i = line.index('=') if (i) key1 = line[0..i - 1].strip if configInfo.has_key?(key1) file.puts "#{key1}=#{configInfo[key1]}\n" else file.puts "#{line}\n" end else file.puts "#{line}\n" end else file.puts "#{line}\n" end end rescue Exception=>e @obj.log.info "Problem in Reading / Writing Property File : #{e.message} " @obj.log.error "#{e.backtrace}" ensure propsFile.close file.close end res = @obj.util.copyFiles f, filepath if res @obj.log.info "copyFiles result = #{res}" #delete apminsight.conf.new has to be done end configureFile assignConfig end |
#updateAgentInfoFile(props) ⇒ Object
137 138 139 140 141 |
# File 'lib/agent/configuration/am_configuration.rb', line 137 def updateAgentInfoFile(props) @instance_id = props["agent.id"] @agent_enabled= @obj.util.getBooleanValue props["agent.enabled"] @obj.util.writeProperties(@obj.constants.agent_conf,props) end |
#urlMergePattern ⇒ Object
125 126 127 128 129 130 131 132 133 134 135 |
# File 'lib/agent/configuration/am_configuration.rb', line 125 def urlMergePattern @url_merge_pattern = Hash.new begin if (FileTest.exists?(@obj.constants.mergepattern_conf)) @url_merge_pattern=@obj.util.readProperties(@obj.constants.mergepattern_conf) end rescue Exception => e @obj.log.info "[Exception] Problem in Reading Configuration File : \n File : #{@obj.constants.mergepattern_conf}" @obj.log.logException "#{e.message}",e end end |