site24x7_apminsight 1.8.3 → 1.8.6
Sign up to get free protection for your applications and to get access to all the features.
@@ -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
|
@@ -58,6 +58,7 @@ module ManageEngine
|
|
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,6 +89,14 @@ 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
101
|
if FileTest.exists?(@obj.constants.agent_conf)
|
92
102
|
@obj.log.debug "Status : Agent Already Connected"
|
@@ -111,15 +121,14 @@ 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
|
@@ -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
|
@@ -246,8 +257,7 @@ module ManageEngine
|
|
246
257
|
def getHostType
|
247
258
|
begin
|
248
259
|
# Check for AWS environment
|
249
|
-
|
250
|
-
url = URI.parse('http://169.254.169.254/latest/meta-data/')
|
260
|
+
url = URI.parse('http://169.254.169.254/latest/meta-data/') # AWS metadata url
|
251
261
|
request = Net::HTTP::Get.new(url.path)
|
252
262
|
response = Net::HTTP.start(url.host, url.port, :read_timeout => 2) {|http| http.request(request)}
|
253
263
|
if (response.kind_of? Net::HTTPOK)
|
@@ -259,8 +269,7 @@ module ManageEngine
|
|
259
269
|
|
260
270
|
begin
|
261
271
|
#Check for Azure environment
|
262
|
-
|
263
|
-
url = URI.parse('http://169.254.169.254/metadata/v1/maintenance')
|
272
|
+
url = URI.parse('http://169.254.169.254/metadata/v1/maintenance') # Azure metadata url
|
264
273
|
request = Net::HTTP::Get.new(url.path)
|
265
274
|
response = Net::HTTP.start(url.host, url.port, :read_timeout => 2) {|http| http.request(request)}
|
266
275
|
if (response.kind_of? Net::HTTPOK)
|
@@ -270,6 +279,15 @@ module ManageEngine
|
|
270
279
|
rescue Exception => e
|
271
280
|
end
|
272
281
|
|
282
|
+
begin
|
283
|
+
# Check for Heroku env. In the backgroud it is using AWS EC2, hence sending as AWS
|
284
|
+
if (ENV.has_key?('DYNO') || ENV.has_key?('STACK'))
|
285
|
+
@hostType = "AWS"
|
286
|
+
return @hostType
|
287
|
+
end
|
288
|
+
rescue Exception => e
|
289
|
+
end
|
290
|
+
|
273
291
|
@hostType = nil
|
274
292
|
end
|
275
293
|
|
@@ -289,11 +307,24 @@ module ManageEngine
|
|
289
307
|
def getEnvData
|
290
308
|
env = Hash.new
|
291
309
|
begin
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
310
|
+
env["OS"] = Gem::Platform.local.os
|
311
|
+
env["OS Version"] = Gem::Platform.local.version
|
312
|
+
env["OS Arch"] = Gem::Platform.local.cpu
|
313
|
+
env["Ruby Version"] = "#{RUBY_VERSION}"
|
314
|
+
gemSpecs = Gem.loaded_specs[@obj.constants.s247_apm_gem]
|
315
|
+
if (gemSpecs == nil)
|
316
|
+
gemSpecs = Gem.loaded_specs[@obj.constants.apm_gem]
|
317
|
+
end
|
318
|
+
if (gemSpecs != nil)
|
319
|
+
env["Agent Installed Path"] = gemSpecs.full_gem_path
|
320
|
+
end
|
321
|
+
|
322
|
+
# ENV.to_hash.each do |key, value|
|
323
|
+
# env[key] = value
|
324
|
+
# end
|
325
|
+
env["Application Path"] = "#{Dir.pwd}"
|
296
326
|
rescue Exception=>e
|
327
|
+
@obj.log.warn "Error in capturing env data. #{e.message}"
|
297
328
|
end
|
298
329
|
env
|
299
330
|
end
|
@@ -39,17 +39,20 @@ module ManageEngine
|
|
39
39
|
resp = nil
|
40
40
|
if @obj.config.alreadyconnected
|
41
41
|
@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
|
42
|
+
resp = startConnect "?license.key="+@obj.config.license_key+"&instance_id="+@obj.config.instance_id,agentInfo
|
47
43
|
else
|
48
44
|
@obj.log.debug "[doConnect] Going to connect - New "
|
49
|
-
if @obj.config.site24x7
|
50
|
-
resp = startConnect "?license.key="+@obj.config.license_key,agentInfo
|
45
|
+
# if @obj.config.site24x7
|
46
|
+
# resp = startConnect "?license.key="+@obj.config.license_key,agentInfo
|
47
|
+
# else
|
48
|
+
# resp = startConnect "",agentInfo
|
49
|
+
# end
|
50
|
+
# Checking the license pattern for APM as per team requirement
|
51
|
+
if !@obj.config.site24x7 && !@obj.config.license_key.match?("APMI_[A-Fa-f0-9]{64}")
|
52
|
+
@obj.log.info "Invalid license key for App Manager, aborting agent init"
|
53
|
+
@obj.shutdown=true
|
51
54
|
else
|
52
|
-
|
55
|
+
resp = startConnect "?license.key="+@obj.config.license_key,agentInfo
|
53
56
|
end
|
54
57
|
end
|
55
58
|
|
@@ -16,7 +16,7 @@ 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} "
|
@@ -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/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
|
+
- 6
|
9
|
+
version: 1.8.6
|
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: 2022-08-26 00:00:00 +05:30
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|