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.
-
#include_packages ⇒ Object
readonly
Returns the value of attribute include_packages.
-
#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.
-
#logs_dir ⇒ Object
readonly
Returns the value of attribute logs_dir.
-
#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.
-
#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.
-
#trans_trace ⇒ Object
readonly
Returns the value of attribute trans_trace.
-
#trans_trace_t ⇒ Object
readonly
Returns the value of attribute trans_trace_t.
Instance Method Summary collapse
- #assignConfig ⇒ Object
- #checkAgentInfo ⇒ Object
- #configureFile ⇒ Object
- #getAgentInfo ⇒ Object
- #getDispatcher ⇒ Object
- #getEnvData ⇒ Object
-
#initialize ⇒ APMConfig
constructor
A new instance of APMConfig.
- #initValues ⇒ Object
- #isFloat(default, value) ⇒ Object
- #isInteger(default, value) ⇒ Object
- #updateAgentInfoFile(props) ⇒ Object
Constructor Details
#initialize ⇒ APMConfig
Returns a new instance of APMConfig.
13 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 |
# File 'lib/agent/configuration/am_configuration.rb', line 13 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 @db_operations =["select","insert","update","delete"] @obj.log.debug "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" @obj.log.debug "APP HOME #{File.absolute_path(".")} " @obj.log.debug "APP HOME #{Dir.pwd} " @obj.log.debug "Configuration : " @obj.log.debug "Agent Name : #{@agenthost}" @obj.log.debug "Agent Already Connected : #{@alreadyconnected}" @obj.log.debug "Agent Enabled : #{@agent_enabled}" @obj.log.debug "Allowed DB Operations : #{@db_operations}" @config.each do|key,val| @obj.log.info "#{key} => #{val}" end @obj.log.debug "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@" @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.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def agent_enabled @agent_enabled end |
#agenthost ⇒ Object (readonly)
Returns the value of attribute agenthost.
9 10 11 |
# File 'lib/agent/configuration/am_configuration.rb', line 9 def agenthost @agenthost end |
#agentport ⇒ Object (readonly)
Returns the value of attribute agentport.
9 10 11 |
# File 'lib/agent/configuration/am_configuration.rb', line 9 def agentport @agentport end |
#alreadyconnected ⇒ Object (readonly)
Returns the value of attribute alreadyconnected.
9 10 11 |
# File 'lib/agent/configuration/am_configuration.rb', line 9 def alreadyconnected @alreadyconnected end |
#apdex_t ⇒ Object (readonly)
Returns the value of attribute apdex_t.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def apdex_t @apdex_t end |
#apmhost ⇒ Object (readonly)
Returns the value of attribute apmhost.
9 10 11 |
# File 'lib/agent/configuration/am_configuration.rb', line 9 def apmhost @apmhost end |
#apmport ⇒ Object (readonly)
Returns the value of attribute apmport.
9 10 11 |
# File 'lib/agent/configuration/am_configuration.rb', line 9 def apmport @apmport end |
#app_db ⇒ Object
Returns the value of attribute app_db.
12 13 14 |
# File 'lib/agent/configuration/am_configuration.rb', line 12 def app_db @app_db end |
#app_dispatcher ⇒ Object
Returns the value of attribute app_dispatcher.
12 13 14 |
# File 'lib/agent/configuration/am_configuration.rb', line 12 def app_dispatcher @app_dispatcher end |
#appname ⇒ Object (readonly)
Returns the value of attribute appname.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def appname @appname end |
#connect_interval ⇒ Object (readonly)
Returns the value of attribute connect_interval.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def connect_interval @connect_interval end |
#connection_retry ⇒ Object (readonly)
Returns the value of attribute connection_retry.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def connection_retry @connection_retry end |
#db_operations ⇒ Object (readonly)
Returns the value of attribute db_operations.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def db_operations @db_operations end |
#include_packages ⇒ Object (readonly)
Returns the value of attribute include_packages.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def include_packages @include_packages end |
#instance_id ⇒ Object (readonly)
Returns the value of attribute instance_id.
9 10 11 |
# File 'lib/agent/configuration/am_configuration.rb', line 9 def instance_id @instance_id end |
#is_secured ⇒ Object (readonly)
Returns the value of attribute is_secured.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def is_secured @is_secured end |
#lastupdatedtime ⇒ Object
Returns the value of attribute lastupdatedtime.
12 13 14 |
# File 'lib/agent/configuration/am_configuration.rb', line 12 def lastupdatedtime @lastupdatedtime end |
#logs_dir ⇒ Object (readonly)
Returns the value of attribute logs_dir.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def logs_dir @logs_dir end |
#proxy_host ⇒ Object (readonly)
Returns the value of attribute proxy_host.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def proxy_host @proxy_host end |
#proxy_pass ⇒ Object (readonly)
Returns the value of attribute proxy_pass.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def proxy_pass @proxy_pass end |
#proxy_port ⇒ Object (readonly)
Returns the value of attribute proxy_port.
11 12 13 |
# File 'lib/agent/configuration/am_configuration.rb', line 11 def proxy_port @proxy_port end |
#proxy_user ⇒ Object (readonly)
Returns the value of attribute proxy_user.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def proxy_user @proxy_user end |
#proxyneeded ⇒ Object (readonly)
Returns the value of attribute proxyneeded.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def proxyneeded @proxyneeded end |
#sql_capture ⇒ Object (readonly)
Returns the value of attribute sql_capture.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def sql_capture @sql_capture end |
#sql_capture_params ⇒ Object (readonly)
Returns the value of attribute sql_capture_params.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def sql_capture_params @sql_capture_params end |
#sql_trace_t ⇒ Object (readonly)
Returns the value of attribute sql_trace_t.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def sql_trace_t @sql_trace_t end |
#trans_trace ⇒ Object (readonly)
Returns the value of attribute trans_trace.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def trans_trace @trans_trace end |
#trans_trace_t ⇒ Object (readonly)
Returns the value of attribute trans_trace_t.
10 11 12 |
# File 'lib/agent/configuration/am_configuration.rb', line 10 def trans_trace_t @trans_trace_t end |
Instance Method Details
#assignConfig ⇒ Object
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/agent/configuration/am_configuration.rb', line 110 def assignConfig initValues @config.each do |key,value| case key when "application.name" then @appname=value when "apm.host" then @apmhost=value when "apm.port" then @apmport=isInteger(@apmport,value) 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=value when "proxy.auth.username" then @proxy_user=value when "proxy.auth.password" then @proxy_pass=value when "apminsight.secure" then @is_secured=@obj.util.getBooleanValue value when "apminsight.log.dir" then @logs_dir=value when "agent.connection.retry" then @connection_retry=value #Not in Conf - yet to come when "agent.connection.interval" then @connect_interval=value#Not in Conf - yet to come when "include.packages" then @include_packages=@obj.util.getArray value,"," end end end |
#checkAgentInfo ⇒ Object
73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/agent/configuration/am_configuration.rb', line 73 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"] @agent_enabled= @obj.util.getBooleanValue props["agent.enabled"] true else @obj.log.info "Status : Agent not connected" false end end |
#configureFile ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/agent/configuration/am_configuration.rb', line 42 def configureFile begin gem_conf = Gem.loaded_specs[@obj.constants.apm_gem].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') if(FileTest.exists?(@obj.constants.apm_conf)) #conf file exists in APPlication Home @obj.log.debug "Config File Read from #{@obj.constants.apm_conf}" @config = @obj.util.readProperties(@obj.constants.apm_conf) else #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.debug "Config File 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.debug "Config File 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 |
#getAgentInfo ⇒ Object
138 139 140 141 142 143 144 145 |
# File 'lib/agent/configuration/am_configuration.rb', line 138 def getAgentInfo data = Hash.new agentdata = Hash.new agentdata = {"application.type"=>"RUBY","application.name"=>@appname,"hostname"=>@agenthost,"port"=>@agentport,"agent.version"=>"1.0"} data["agent_info"]=agentdata data["environment"]=getEnvData data end |
#getDispatcher ⇒ Object
160 161 162 163 164 165 166 |
# File 'lib/agent/configuration/am_configuration.rb', line 160 def getDispatcher dispatcher = "unknown" if defined?(PhusionPassenger) then dispatcher = "passenger" end dispatcher end |
#getEnvData ⇒ Object
147 148 149 150 151 152 153 154 155 156 157 |
# File 'lib/agent/configuration/am_configuration.rb', line 147 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 |
#initValues ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/agent/configuration/am_configuration.rb', line 92 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 @include_packages=Array.new @trans_trace_t=2 @sql_trace_t=3 end |
#isFloat(default, value) ⇒ Object
178 179 180 181 182 183 184 185 |
# File 'lib/agent/configuration/am_configuration.rb', line 178 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
168 169 170 171 172 173 174 175 176 |
# File 'lib/agent/configuration/am_configuration.rb', line 168 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 |
#updateAgentInfoFile(props) ⇒ Object
86 87 88 89 90 |
# File 'lib/agent/configuration/am_configuration.rb', line 86 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 |