apminsight 1.8.3 → 1.8.7
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/agent/configuration/am_configuration.rb +56 -23
- data/lib/agent/logging/am_logger.rb +1 -1
- data/lib/agent/server/am_agent.rb +24 -12
- data/lib/agent/server/am_connector.rb +1 -1
- data/lib/agent/server/worker/am_worker.rb +2 -2
- data/lib/agent/util/am_constants.rb +5 -3
- data/lib/agent/util/am_util.rb +12 -13
- data/lib/agent/version.rb +2 -2
- metadata +3 -3
@@ -7,7 +7,7 @@ require 'agent/version'
|
|
7
7
|
|
8
8
|
module ManageEngine
|
9
9
|
class APMConfig
|
10
|
-
attr_reader :agenthost,:agentport,:instance_id,:alreadyconnected,:apmhost,:apmport,:license_key,:site24x7, :site24x7url, :hostType
|
10
|
+
attr_reader :agenthost,:agentport,:instance_id,:alreadyconnected,:apmhost,:apmport,:license_key,:site24x7, :site24x7url, :hostType,:delayedStart
|
11
11
|
attr_reader :appname,:proxyneeded, :apdex_t, :trans_trace, :trans_trace_t, :sql_capture, :sql_capture_params, :sql_trace_t,:proxy_user,:proxy_pass, :metric_overflow_t, :trace_overflow_t, :dbmetric_overflow_t
|
12
12
|
attr_reader :proxy_host,:proxy_port ,:is_secured, :logs_dir ,:connection_retry,:agent_enabled,:connect_interval,:db_operations,:txn_skip_listen, :url_merge_pattern
|
13
13
|
attr_accessor :app_db,:app_dispatcher,:lastupdatedtime
|
@@ -24,7 +24,7 @@ module ManageEngine
|
|
24
24
|
@alreadyconnected = checkAgentInfo
|
25
25
|
@site24x7 = checkLicenseFile
|
26
26
|
if (@site24x7)
|
27
|
-
@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
|
27
|
+
@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 : @license_key.start_with?('gd_') ? @obj.constants.site24x7GDurl : @license_key.start_with?('jp_') ? @obj.constants.site24x7JPurl : @obj.constants.site24x7USurl
|
28
28
|
end
|
29
29
|
@db_operations =["select","insert","update","delete"]
|
30
30
|
urlMergePattern
|
@@ -54,10 +54,11 @@ module ManageEngine
|
|
54
54
|
|
55
55
|
def configureFile
|
56
56
|
begin
|
57
|
-
if(FileTest.
|
57
|
+
if(FileTest.exist?(@obj.constants.apm_conf))
|
58
58
|
#conf file exists in APPlication Home
|
59
59
|
@obj.log.debug "Config File Exists. It is read from #{@obj.constants.apm_conf}"
|
60
60
|
@config = @obj.util.readProperties(@obj.constants.apm_conf)
|
61
|
+
secureConfFile "#{@obj.constants.apm_conf}"
|
61
62
|
else
|
62
63
|
gemSpecs = Gem.loaded_specs[@obj.constants.s247_apm_gem]
|
63
64
|
if (gemSpecs == nil)
|
@@ -72,13 +73,14 @@ module ManageEngine
|
|
72
73
|
#copied sucessfully
|
73
74
|
@obj.log.info "Config File copied to application home directory. It is read from #{@obj.constants.apm_conf}"
|
74
75
|
@config = @obj.util.readProperties(@obj.constants.apm_conf)
|
76
|
+
secureConfFile "#{@obj.constants.apm_conf}"
|
75
77
|
else
|
76
78
|
#Problem in copying, so reading props from Conf file in Gem Location
|
77
79
|
@obj.log.warn "Config File not copied. It is read from #{gem_conf}"
|
78
80
|
@config = @obj.util.readProperties(gem_conf)
|
81
|
+
secureConfFile gem_conf
|
79
82
|
end
|
80
83
|
end
|
81
|
-
|
82
84
|
rescue Exception=>e
|
83
85
|
@obj.log.info "[Exception] Problem in Reading Configuration File : \n File : #{@obj.constants.apm_conf}"
|
84
86
|
@obj.log.logException "#{e.message}",e
|
@@ -87,8 +89,16 @@ module ManageEngine
|
|
87
89
|
end
|
88
90
|
end
|
89
91
|
|
92
|
+
def secureConfFile(file)
|
93
|
+
begin
|
94
|
+
File.chmod(0600, file)
|
95
|
+
rescue Exception => e
|
96
|
+
@obj.log.warn "Unable to secure the conf file #{file}"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
90
100
|
def checkAgentInfo
|
91
|
-
if FileTest.
|
101
|
+
if FileTest.exist?(@obj.constants.agent_conf)
|
92
102
|
@obj.log.debug "Status : Agent Already Connected"
|
93
103
|
props = @obj.util.readProperties(@obj.constants.agent_conf)
|
94
104
|
instance_id = props["agent.id"]
|
@@ -111,21 +121,20 @@ module ManageEngine
|
|
111
121
|
end
|
112
122
|
|
113
123
|
def checkLicenseFile
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
124
|
+
@obj.constants.setLicenseKey @license_key
|
125
|
+
if(@license_key.start_with?('APMI_'))
|
126
|
+
@obj.log.info "Connecting to App Manager"
|
127
|
+
false
|
128
|
+
else
|
129
|
+
@obj.log.info "Connecting to Site24x7"
|
130
|
+
true
|
131
|
+
end
|
123
132
|
end
|
124
133
|
|
125
134
|
def urlMergePattern
|
126
135
|
@url_merge_pattern = Hash.new
|
127
136
|
begin
|
128
|
-
if (FileTest.
|
137
|
+
if (FileTest.exist?(@obj.constants.mergepattern_conf))
|
129
138
|
@url_merge_pattern=@obj.util.readProperties(@obj.constants.mergepattern_conf)
|
130
139
|
end
|
131
140
|
rescue Exception => e
|
@@ -138,6 +147,8 @@ module ManageEngine
|
|
138
147
|
@instance_id = props["agent.id"]
|
139
148
|
@agent_enabled= @obj.util.getBooleanValue props["agent.enabled"]
|
140
149
|
@obj.util.writeProperties(@obj.constants.agent_conf,props)
|
150
|
+
|
151
|
+
secureConfFile(@obj.constants.agent_conf)
|
141
152
|
end
|
142
153
|
|
143
154
|
def initValues
|
@@ -160,6 +171,7 @@ module ManageEngine
|
|
160
171
|
@dbmetric_overflow_t=500
|
161
172
|
@trace_overflow_t=30
|
162
173
|
@site24x7url = @obj.constants.site24x7USurl #default agent communication URL
|
174
|
+
@delayedStart = false
|
163
175
|
end
|
164
176
|
|
165
177
|
def assignConfig
|
@@ -201,6 +213,7 @@ module ManageEngine
|
|
201
213
|
when "metricstore.metric.bucket.size" then @metric_overflow_t = isInteger(@metric_overflow_t, value)
|
202
214
|
when "metricstore.dbmetric.bucket.size" then @dbmetric_overflow_t = isInteger(@dbmetric_overflow_t, value)
|
203
215
|
when "transaction.tracestore.size" then @trace_overflow_t = isInteger(@trace_overflow_t, value)
|
216
|
+
when "agent.delay.start" then @delayedStart=@obj.util.getBooleanValue value
|
204
217
|
end
|
205
218
|
end
|
206
219
|
store_encrypted_data(@config)
|
@@ -246,8 +259,7 @@ module ManageEngine
|
|
246
259
|
def getHostType
|
247
260
|
begin
|
248
261
|
# Check for AWS environment
|
249
|
-
|
250
|
-
url = URI.parse('http://169.254.169.254/latest/meta-data/')
|
262
|
+
url = URI.parse('http://169.254.169.254/latest/meta-data/') # AWS metadata url
|
251
263
|
request = Net::HTTP::Get.new(url.path)
|
252
264
|
response = Net::HTTP.start(url.host, url.port, :read_timeout => 2) {|http| http.request(request)}
|
253
265
|
if (response.kind_of? Net::HTTPOK)
|
@@ -259,8 +271,7 @@ module ManageEngine
|
|
259
271
|
|
260
272
|
begin
|
261
273
|
#Check for Azure environment
|
262
|
-
|
263
|
-
url = URI.parse('http://169.254.169.254/metadata/v1/maintenance')
|
274
|
+
url = URI.parse('http://169.254.169.254/metadata/v1/maintenance') # Azure metadata url
|
264
275
|
request = Net::HTTP::Get.new(url.path)
|
265
276
|
response = Net::HTTP.start(url.host, url.port, :read_timeout => 2) {|http| http.request(request)}
|
266
277
|
if (response.kind_of? Net::HTTPOK)
|
@@ -270,6 +281,15 @@ module ManageEngine
|
|
270
281
|
rescue Exception => e
|
271
282
|
end
|
272
283
|
|
284
|
+
begin
|
285
|
+
# Check for Heroku env. In the backgroud it is using AWS EC2, hence sending as AWS
|
286
|
+
if (ENV.has_key?('DYNO') || ENV.has_key?('STACK'))
|
287
|
+
@hostType = "AWS"
|
288
|
+
return @hostType
|
289
|
+
end
|
290
|
+
rescue Exception => e
|
291
|
+
end
|
292
|
+
|
273
293
|
@hostType = nil
|
274
294
|
end
|
275
295
|
|
@@ -289,11 +309,24 @@ module ManageEngine
|
|
289
309
|
def getEnvData
|
290
310
|
env = Hash.new
|
291
311
|
begin
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
312
|
+
env["OS"] = Gem::Platform.local.os
|
313
|
+
env["OS Version"] = Gem::Platform.local.version
|
314
|
+
env["OS Arch"] = Gem::Platform.local.cpu
|
315
|
+
env["Ruby Version"] = "#{RUBY_VERSION}"
|
316
|
+
gemSpecs = Gem.loaded_specs[@obj.constants.s247_apm_gem]
|
317
|
+
if (gemSpecs == nil)
|
318
|
+
gemSpecs = Gem.loaded_specs[@obj.constants.apm_gem]
|
319
|
+
end
|
320
|
+
if (gemSpecs != nil)
|
321
|
+
env["Agent Installed Path"] = gemSpecs.full_gem_path
|
322
|
+
end
|
323
|
+
|
324
|
+
# ENV.to_hash.each do |key, value|
|
325
|
+
# env[key] = value
|
326
|
+
# end
|
327
|
+
env["Application Path"] = "#{Dir.pwd}"
|
296
328
|
rescue Exception=>e
|
329
|
+
@obj.log.warn "Error in capturing env data. #{e.message}"
|
297
330
|
end
|
298
331
|
env
|
299
332
|
end
|
@@ -40,7 +40,7 @@ module ManageEngine
|
|
40
40
|
def getLogsPath
|
41
41
|
props = {}
|
42
42
|
begin
|
43
|
-
if FileTest.
|
43
|
+
if FileTest.exist?(@obj.constants.apm_conf)
|
44
44
|
propsFile=File.open(@obj.constants.apm_conf, 'r')
|
45
45
|
propsFile.read.each_line do |line|
|
46
46
|
line.strip!
|
@@ -9,7 +9,16 @@ module ManageEngine
|
|
9
9
|
def initialize
|
10
10
|
@obj = ManageEngine::APMObjectHolder.instance
|
11
11
|
@obj.log.debug "Agent Initialization - START"
|
12
|
-
|
12
|
+
if @obj.config.delayedStart
|
13
|
+
@obj.log.info "Delaying agent handshake as per configuration.."
|
14
|
+
@obj.agent_initialized = true # to be reset when connecting
|
15
|
+
@apm = Thread.new do
|
16
|
+
sleep ((@obj.config.connect_interval).to_i)/2
|
17
|
+
doConnect
|
18
|
+
end
|
19
|
+
else
|
20
|
+
doConnect
|
21
|
+
end
|
13
22
|
|
14
23
|
if !@obj.shutdown && @obj.agent_initialized
|
15
24
|
@obj.log.info "Agent Initialization - DONE"
|
@@ -26,12 +35,12 @@ module ManageEngine
|
|
26
35
|
#@obj.instrumenter.doUnSubscribe
|
27
36
|
@obj.shutdownagent
|
28
37
|
end
|
29
|
-
|
30
|
-
|
31
|
-
end
|
38
|
+
end
|
32
39
|
|
33
40
|
def doConnect
|
34
41
|
begin
|
42
|
+
@obj.agent_initialized=false #resetting, to go with the flow
|
43
|
+
|
35
44
|
if @obj.shutdown
|
36
45
|
@obj.log.info "[ Problem in Agent Startup ]"
|
37
46
|
else
|
@@ -39,17 +48,20 @@ module ManageEngine
|
|
39
48
|
resp = nil
|
40
49
|
if @obj.config.alreadyconnected
|
41
50
|
@obj.log.debug "[doConnect] Already Connected - Make Contact - Instance id = #{@obj.config.instance_id}"
|
42
|
-
|
43
|
-
resp = startConnect "?license.key="+@obj.config.license_key+"&instance_id="+@obj.config.instance_id,agentInfo
|
44
|
-
else
|
45
|
-
resp = startConnect "?instance_id="+@obj.config.instance_id,agentInfo
|
46
|
-
end
|
51
|
+
resp = startConnect "?license.key="+@obj.config.license_key+"&instance_id="+@obj.config.instance_id,agentInfo
|
47
52
|
else
|
48
53
|
@obj.log.debug "[doConnect] Going to connect - New "
|
49
|
-
if @obj.config.site24x7
|
50
|
-
resp = startConnect "?license.key="+@obj.config.license_key,agentInfo
|
54
|
+
# if @obj.config.site24x7
|
55
|
+
# resp = startConnect "?license.key="+@obj.config.license_key,agentInfo
|
56
|
+
# else
|
57
|
+
# resp = startConnect "",agentInfo
|
58
|
+
# end
|
59
|
+
# Checking the license pattern for APM as per team requirement
|
60
|
+
if !@obj.config.site24x7 && !@obj.config.license_key.match?("APMI_[A-Fa-f0-9]{64}")
|
61
|
+
@obj.log.info "Invalid license key for App Manager, aborting agent init"
|
62
|
+
@obj.shutdown=true
|
51
63
|
else
|
52
|
-
|
64
|
+
resp = startConnect "?license.key="+@obj.config.license_key,agentInfo
|
53
65
|
end
|
54
66
|
end
|
55
67
|
|
@@ -19,7 +19,7 @@ module ManageEngine
|
|
19
19
|
|
20
20
|
u = url uri
|
21
21
|
#@obj.log.info "[connector] [ POST] START"
|
22
|
-
@obj.log.debug "[connector] [ POST] :
|
22
|
+
@obj.log.debug "[connector] [ POST] : #{u}\n#{data}"
|
23
23
|
con = connection(u)
|
24
24
|
req = Net::HTTP::Post.new(u.request_uri,initheader = {'Content-Type' =>'application/json'})
|
25
25
|
req.body=data.to_json
|
@@ -16,17 +16,17 @@ class APMWorker
|
|
16
16
|
@obj = ManageEngine::APMObjectHolder.instance
|
17
17
|
|
18
18
|
if @status=="working"
|
19
|
-
@obj.log.debug "
|
19
|
+
@obj.log.debug "worker thread already started"
|
20
20
|
elsif @status == "initialized"
|
21
21
|
@obj.log.info "start worker thread for - #{Process.pid} :: #{@status} "
|
22
22
|
#@obj.log.info "Starting APMWorker Thread #{Process.pid} "
|
23
23
|
@apm = Thread.new do
|
24
24
|
@status = 'working'
|
25
25
|
while !@obj.shutdown do
|
26
|
+
sleep (@obj.config.connect_interval).to_i
|
26
27
|
checkforagentstatus
|
27
28
|
updateConfig
|
28
29
|
dc
|
29
|
-
sleep (@obj.config.connect_interval).to_i
|
30
30
|
end#w
|
31
31
|
@status= "end"
|
32
32
|
@obj.log.debug "Worker thread ends"
|
@@ -3,7 +3,7 @@ module ManageEngine
|
|
3
3
|
class APMConstants
|
4
4
|
|
5
5
|
attr_reader :conf_location, :apm_gem,:s247_apm_gem,:apm_conf,:agent_conf,:connection_open_timeout,:connection_read_timeout,:connect_uri,:connect_data_uri,:connect_trace_uri,:connect_config_update_uri,:mergepattern_conf
|
6
|
-
attr_reader :site24x7USurl, :site24x7EUurl, :site24x7CNurl, :site24x7INurl, :site24x7AUurl
|
6
|
+
attr_reader :site24x7USurl, :site24x7EUurl, :site24x7CNurl, :site24x7INurl, :site24x7AUurl, :site24x7GDurl, :site24x7JPurl
|
7
7
|
attr_reader :licence_exceeds,:licence_expired,:unmanage_agent,:manage_agent,:agent_config_updated,:error_notfound,:error_server,:delete_agent,:response_code,:custom_config_info, :agent_specific_info
|
8
8
|
attr_reader :mf_transaction,:mf_separator,:mf_db,:mf_apdex,:mf_namespace,:mf_name,:mf_all,:agent_store,:agent_lock,:mf_overflow
|
9
9
|
attr_reader :mf_logmetric, :mf_logmetric_warning, :mf_exception_st, :mf_err_st, :mf_loginfo, :mf_loginfo_time, :mf_loginfo_level, :mf_loginfo_str, :mf_loginfo_err_clz, :mf_loginfo_st, :mf_loginfo_level_warn
|
@@ -12,8 +12,8 @@ module ManageEngine
|
|
12
12
|
def initialize
|
13
13
|
@conf_location=ENV.has_key?('APMINSIGHT_HOME') ? ENV['APMINSIGHT_HOME']+"/" : "./"
|
14
14
|
#File path for APM Conf file
|
15
|
-
@apm_gem
|
16
|
-
@s247_apm_gem
|
15
|
+
@apm_gem="apminsight"
|
16
|
+
@s247_apm_gem="site24x7_apminsight"
|
17
17
|
|
18
18
|
#File path for APM Conf file
|
19
19
|
@apm_conf=@conf_location + "apminsight.conf"
|
@@ -55,6 +55,8 @@ module ManageEngine
|
|
55
55
|
@site24x7CNurl = "https://plusinsight.site24x7.cn/"
|
56
56
|
@site24x7AUurl = "https://plusinsight.site24x7.net.au/"
|
57
57
|
@site24x7INurl = "https://plusinsight.site24x7.in/"
|
58
|
+
@site24x7GDurl = "https://gdplusinsight.site24x7.com/"
|
59
|
+
@site24x7JPurl = "https://plusinsight.site24x7.jp/"
|
58
60
|
|
59
61
|
#Response Codes
|
60
62
|
@licence_expired = 701
|
data/lib/agent/util/am_util.rb
CHANGED
@@ -50,22 +50,21 @@ module ManageEngine
|
|
50
50
|
props = {}
|
51
51
|
begin
|
52
52
|
propsFile=File.open(filepath, 'r')
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
53
|
+
propsFile.read.each_line do |line|
|
54
|
+
line.strip!
|
55
|
+
if (line[0] != ?# and line[0] != ?=)
|
56
|
+
i = line.index('=')
|
57
|
+
if (i)
|
58
|
+
props[line[0..i - 1].strip] = line[i + 1..-1].strip
|
59
|
+
else
|
60
|
+
props[line] = ''
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
propsFile.close
|
64
65
|
rescue Exception=>e
|
65
66
|
@log.info "Problem in Reading Property File : #{e.message} "
|
66
67
|
@log.error "#{e.backtrace}"
|
67
|
-
ensure
|
68
|
-
propsFile.close
|
69
68
|
end
|
70
69
|
props
|
71
70
|
end
|
data/lib/agent/version.rb
CHANGED
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 8
|
8
|
-
-
|
9
|
-
version: 1.8.
|
8
|
+
- 7
|
9
|
+
version: 1.8.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Adithyan P
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date:
|
17
|
+
date: 2023-07-05 00:00:00 +05:30
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|