site24x7_apminsight 1.7.2 → 1.8.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.0
1
+ 1.8.2
@@ -19,22 +19,28 @@ module ManageEngine
19
19
  @@objects = nil
20
20
  #Don't Change the Order of Initialize
21
21
  def initializeObjects
22
- @agent_initialized = false
23
- @shutdown = false
24
- @constants = ManageEngine::APMConstants.new
25
- @log = ManageEngine::APMLogger.new
26
- @util = ManageEngine::APMUtil.new
27
- @util.setLogger @log
28
- @config = ManageEngine::APMConfig.new
29
- @connector = ManageEngine::APMConnector.new
30
- @store = ManageEngine::APMMetricsStore.new
31
- @collector = ManageEngine::APMMetricsCollector.new
32
- @txn_util = ManageEngine::TransactionUtil.new
33
- @formatter = ManageEngine::APMMetricsFormatter.new
34
- @parser = ManageEngine::APMMetricsParser.new
35
- @agent = ManageEngine::APMAgent.new
36
- @last_dispatch_time = @@objects.util.currenttimemillis
37
- @@objects.log.debug "[APMObjectHolder] [ All Objects Initialized ] "
22
+ begin
23
+ @agent_initialized = false
24
+ @shutdown = false
25
+ @constants = ManageEngine::APMConstants.new
26
+ @log = ManageEngine::APMLogger.new
27
+ @util = ManageEngine::APMUtil.new
28
+ @util.setLogger @log
29
+ @config = ManageEngine::APMConfig.new
30
+ @connector = ManageEngine::APMConnector.new
31
+ @store = ManageEngine::APMMetricsStore.new
32
+ @collector = ManageEngine::APMMetricsCollector.new
33
+ @txn_util = ManageEngine::TransactionUtil.new
34
+ @formatter = ManageEngine::APMMetricsFormatter.new
35
+ @parser = ManageEngine::APMMetricsParser.new
36
+ @agent = ManageEngine::APMAgent.new
37
+ @last_dispatch_time = @@objects.util.currenttimemillis
38
+ @@objects.log.debug "[APMObjectHolder] [ All Objects Initialized ] "
39
+ rescue Exception => e
40
+ puts "Error initializing APM Insight Ruby agent. #{e.message}"
41
+ @shutdown = true
42
+ @agent_initialized = false
43
+ end
38
44
  end
39
45
 
40
46
  def self.instance
@@ -3,7 +3,7 @@ require 'json'
3
3
  require 'socket'
4
4
  require 'net/http'
5
5
  require 'agent/am_objectholder'
6
- require 'version'
6
+ require 'agent/version'
7
7
 
8
8
  module ManageEngine
9
9
  class APMConfig
@@ -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 : @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 : @obj.constants.site24x7USurl
28
28
  end
29
29
  @db_operations =["select","insert","update","delete"]
30
30
  urlMergePattern
@@ -246,7 +246,10 @@ module ManageEngine
246
246
  def getHostType
247
247
  begin
248
248
  # Check for AWS environment
249
- response = Net::HTTP.get_response(URI('http://169.254.169.254/latest/meta-data/'))
249
+ # response = Net::HTTP.get_response(URI('http://169.254.169.254/latest/meta-data/'))
250
+ url = URI.parse('http://169.254.169.254/latest/meta-data/')
251
+ request = Net::HTTP::Get.new(url.path)
252
+ response = Net::HTTP.start(url.host, url.port, :read_timeout => 2) {|http| http.request(request)}
250
253
  if (response.kind_of? Net::HTTPOK)
251
254
  @hostType = "AWS"
252
255
  return @hostType
@@ -256,7 +259,10 @@ module ManageEngine
256
259
 
257
260
  begin
258
261
  #Check for Azure environment
259
- response = Net::HTTP.get_response(URI('http://169.254.169.254/metadata/v1/maintenance'))
262
+ # response = Net::HTTP.get_response(URI('http://169.254.169.254/metadata/v1/maintenance'))
263
+ url = URI.parse('http://169.254.169.254/metadata/v1/maintenance')
264
+ request = Net::HTTP::Get.new(url.path)
265
+ response = Net::HTTP.start(url.host, url.port, :read_timeout => 2) {|http| http.request(request)}
260
266
  if (response.kind_of? Net::HTTPOK)
261
267
  @hostType = "AZURE"
262
268
  return @hostType
@@ -315,14 +321,20 @@ module ManageEngine
315
321
  end
316
322
 
317
323
  def getDispatcher
318
- dispatcher = "unknown"
319
- if defined?(PhusionPassenger) then
320
- dispatcher = "passenger"
321
- end
322
- if defined?(::Unicorn) && defined?(::Unicorn::HttpServer) then
323
- dispatcher = "unicorn"
324
- end
325
- dispatcher
324
+
325
+ @obj.log.info "Server: #{ENV['SERVER_SOFTWARE']}"
326
+
327
+ dispatcher = "unknown"
328
+ if defined?(PhusionPassenger) then
329
+ dispatcher = "passenger"
330
+ end
331
+ if defined?(Unicorn) then
332
+ dispatcher = "unicorn"
333
+ end
334
+ if defined?(Rainbows) then
335
+ dispatcher = "rainbows"
336
+ end
337
+ dispatcher
326
338
  end
327
339
 
328
340
  def isInteger default,value
@@ -3,7 +3,7 @@ require 'agent/metrics/exception_record'
3
3
  module APMInsight
4
4
  module Agent
5
5
  class SequenceBook
6
- attr_reader :openTracker, :closedTracker, :rootTracker, :trackerCount, :exceptionBag, :listenFlag
6
+ attr_reader :openTracker, :closedTracker, :rootTracker, :trackerCount, :closedTrackerCount, :exceptionBag, :listenFlag
7
7
 
8
8
  def initialize
9
9
  @rootTracker = createDummyTracker()
@@ -11,6 +11,7 @@ module APMInsight
11
11
  @openTracker = nil
12
12
 
13
13
  @trackerCount = 0
14
+ @closedTrackerCount = 0
14
15
  @listenFlag = -1
15
16
  # @exceptionBag = Array.new
16
17
  end
@@ -54,6 +55,7 @@ module APMInsight
54
55
  end
55
56
 
56
57
  def closeTracker tracker
58
+ @closedTrackerCount += 1
57
59
  @closedTracker = tracker
58
60
  tracker.sibling = nil
59
61
  @openTracker = nil
@@ -61,12 +63,16 @@ module APMInsight
61
63
  # Marks end of transaction
62
64
  if @rootTracker == tracker
63
65
  if @listenFlag < 1 || (@listenFlag >= 1 && @trackerCount > 1)
64
-
65
- sequenceBag = Hash.new
66
- sequenceBag["roottracker"] = @rootTracker
67
- sequenceBag["exceptions"] = @exceptionBag
68
-
69
- ManageEngine::APMObjectHolder.instance.collector.updateTransaction(@rootTracker.url, sequenceBag)
66
+ # if some trackers are not closed, while processing the metrics, it may go into infinite loop
67
+ if (@closedTrackerCount - @trackerCount) == 0
68
+ sequenceBag = Hash.new
69
+ sequenceBag["roottracker"] = @rootTracker
70
+ sequenceBag["exceptions"] = @exceptionBag
71
+
72
+ ManageEngine::APMObjectHolder.instance.collector.updateTransaction(@rootTracker.url, sequenceBag)
73
+ else
74
+ ManageEngine::APMObjectHolder.instance.log.warn "Some trackers are not closed, dropping the metrics for #{@rootTracker.url}"
75
+ end
70
76
  end
71
77
  closeSequence()
72
78
  end
@@ -76,6 +82,7 @@ module APMInsight
76
82
  @rootTracker = nil
77
83
  @openTracker = @closedTracker = nil
78
84
  @trackerCount = 0
85
+ @closedTrackerCount = 0
79
86
  Thread.current[:apminsight] = nil
80
87
  end
81
88
 
@@ -84,8 +91,10 @@ module APMInsight
84
91
  if @exceptionBag == nil
85
92
  @exceptionBag = Set.new
86
93
  end
87
- exceptionRecord = ::APMInsight::Errors::ExceptionRecord.new(exception)
88
- @exceptionBag.add(exceptionRecord)
94
+ if (@exceptionBag.size() < 10)
95
+ exceptionRecord = ::APMInsight::Errors::ExceptionRecord.new(exception)
96
+ @exceptionBag.add(exceptionRecord)
97
+ end
89
98
  rescue Exception=>e
90
99
  end
91
100
  end
@@ -99,7 +108,8 @@ module APMInsight
99
108
  end
100
109
 
101
110
  def checkAndArrestSequence
102
- if ++@trackerCount == 1000
111
+ @trackerCount += 1
112
+ if @trackerCount == 1000
103
113
  @listenFlag = 1
104
114
  end
105
115
 
@@ -4,6 +4,8 @@ require "logger"
4
4
  module ManageEngine
5
5
  class APMLogger
6
6
  @apmlog=nil;
7
+ @apmLogPath=nil;
8
+
7
9
  def initialize
8
10
  @obj=ManageEngine::APMObjectHolder.instance
9
11
  path = getLogsPath
@@ -11,13 +13,19 @@ module ManageEngine
11
13
  if Dir[path] == []
12
14
  Dir.mkdir(path)
13
15
  end
14
- path= path + '/apm.log'
16
+ @apmLogPath= path + '/apm.log'
15
17
  #puts "#{path}"
16
18
  # file = open(path, File::WRONLY | File::APPEND | File::CREAT)
17
- @apmlog = Logger.new(path, 10, 5 * 1024 * 1024)
18
- # @apmlog = Logger.new(file)
19
- @apmlog.level = Logger::INFO
20
- @apmlog.datetime_format = "%Y-%m-%d %H:%M:%S"
19
+ begin
20
+ @apmlog = Logger.new(@apmLogPath, 10, 5 * 1024 * 1024)
21
+ @apmlog.level = Logger::INFO
22
+ rescue Exception => e
23
+ puts "Unable to create/edit the log file #{@apmLogPath}. Writing agent logs to STDOUT.\nError: #{e.message}"
24
+ @apmlog = Logger.new(STDOUT)
25
+ @apmlog.level = Logger::WARN
26
+ end
27
+ # @apmlog = Logger.new(file)
28
+ @apmlog.datetime_format = "%Y-%m-%d %H:%M:%S"
21
29
  @apmlog.formatter = proc do |severity, datetime, progname, msg|
22
30
  "[#{datetime}|#{Process.pid}][#{severity}]:#{msg}\n"
23
31
  end
@@ -25,6 +33,9 @@ module ManageEngine
25
33
 
26
34
  end
27
35
 
36
+ def getLogFilePath
37
+ return @apmLogPath
38
+ end
28
39
 
29
40
  def getLogsPath
30
41
  props = {}
@@ -53,7 +64,7 @@ module ManageEngine
53
64
  if props["apminsight.log.dir"]!=nil
54
65
  return props["apminsight.log.dir"]
55
66
  else
56
- return "./log"
67
+ return @obj.constants.conf_location+"log"
57
68
  end
58
69
 
59
70
  end
@@ -17,7 +17,8 @@ module ManageEngine
17
17
 
18
18
  doDispatcherActions
19
19
  doCollect
20
- puts "APM Insight Ruby Agent Started"
20
+ puts "APM Insight Ruby Agent Started. Agent files are located at #{@obj.constants.conf_location}"
21
+ puts "Agent log file apm.log is generated at #{@obj.log.getLogFilePath}"
21
22
  else
22
23
  @obj.log.info "Agent Initialization Failed - Going to shutdown"
23
24
  #While parsing the response from /arh/connect we set instrumenter to nil on delete request
@@ -116,6 +117,14 @@ module ManageEngine
116
117
  old_object.bind(self).call(worker)
117
118
  end
118
119
  end
120
+ when 'rainbows'
121
+ Rainbows::HttpServer.class_eval do
122
+ old_object = instance_method(:worker_loop)
123
+ define_method(:worker_loop) do |worker|
124
+ ::ManageEngine::APMObjectHolder.instance.agent.doCollect
125
+ old_object.bind(self).call(worker)
126
+ end
127
+ end
119
128
  else#case
120
129
 
121
130
  end#case
@@ -109,14 +109,14 @@ module ManageEngine
109
109
  #con.verify_mode=OpenSSL::SSL::VERIFY_NONE
110
110
  #@obj.log.info "connection = #{con}"
111
111
  end
112
- con=getScheme(con)
112
+ con=getScheme(con, url)
113
113
  con.open_timeout = @obj.constants.connection_open_timeout
114
114
  con.read_timeout = @obj.constants.connection_read_timeout
115
115
  con
116
116
  end
117
117
 
118
- def getScheme(con)
119
- if(@obj.config.license_key != nil || @obj.config.is_secured)
118
+ def getScheme(con, url)
119
+ if(url.to_s.start_with?("https"))
120
120
  #@obj.log.info "[connect] Secured"
121
121
  #con = Net::HTTP::Proxy(@obj.config.proxy_host, @obj.config.proxy_port,@obj.config.proxy_user,@obj.config.proxy_pass).new(url.host, url.port)
122
122
  con.use_ssl=true
@@ -21,7 +21,9 @@ module ManageEngine
21
21
 
22
22
  def detect_and_instrument
23
23
  @framework ||= SUPPORTED_FRAMEWORKS.detect{ |framework| framework.present? }
24
- @framework.instrument
24
+ if (@framework != nil)
25
+ @framework.instrument
26
+ end
25
27
 
26
28
  DATABASE_INTERCEPTORS.each do |interceptor|
27
29
  if (interceptor.present?)
@@ -28,7 +28,12 @@ module ManageEngine
28
28
  end
29
29
 
30
30
  def duration
31
- (@endtime - @starttime).to_i
31
+ begin
32
+ (@endtime - @starttime).to_i
33
+ rescue Exception=>e
34
+ @logger.warn "Name: #{name} Starttime: #{starttime} Endtime: #{endtime}"
35
+ raise e
36
+ end
32
37
  end
33
38
 
34
39
  def ==(obj)
@@ -2,33 +2,33 @@
2
2
  module ManageEngine
3
3
  class APMConstants
4
4
 
5
- attr_reader :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
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
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
10
10
  attr_reader :en_alphabets, :en_numerals
11
11
 
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="apminsight"
16
- @s247_apm_gem="site24x7_apminsight"
15
+ @apm_gem=@conf_location + "apminsight"
16
+ @s247_apm_gem=@conf_location + "site24x7_apminsight"
17
17
 
18
18
  #File path for APM Conf file
19
- @apm_conf="apminsight.conf"
19
+ @apm_conf=@conf_location + "apminsight.conf"
20
20
 
21
21
  #file path for agent id, enable details
22
- @agent_conf="apminsight.info"
22
+ @agent_conf=@conf_location + "apminsight.info"
23
23
 
24
24
  #file path for agent data store lock
25
- @agent_lock="apminsight.lock"
25
+ @agent_lock=@conf_location + "apminsight.lock"
26
26
 
27
27
  #file path for agent data store lock
28
- @agent_store="apminsight.store"
28
+ @agent_store=@conf_location + "apminsight.store"
29
29
 
30
30
  #file name for url merge patterns
31
- @mergepattern_conf="transaction_merge_patterns.conf"
31
+ @mergepattern_conf=@conf_location + "transaction_merge_patterns.conf"
32
32
 
33
33
 
34
34
  #Timeout for opening Connections
@@ -53,6 +53,8 @@ module ManageEngine
53
53
  @site24x7USurl = "https://plusinsight.site24x7.com/"
54
54
  @site24x7EUurl = "https://plusinsight.site24x7.eu/"
55
55
  @site24x7CNurl = "https://plusinsight.site24x7.cn/"
56
+ @site24x7AUurl = "https://plusinsight.site24x7.net.au/"
57
+ @site24x7INurl = "https://plusinsight.site24x7.in/"
56
58
 
57
59
  #Response Codes
58
60
  @licence_expired = 701
@@ -6,8 +6,8 @@
6
6
 
7
7
  module ManageEngine
8
8
  class APMInsight
9
- VERSION = '1.7.2'
10
- MAJOR_VERSION = '1.7'
11
- MINOR_VERSION = '2'
9
+ VERSION = '1.8.3'
10
+ MAJOR_VERSION = '1.8'
11
+ MINOR_VERSION = '3'
12
12
  end
13
13
  end
@@ -3,7 +3,7 @@
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
- require './lib/version'
6
+ require './lib/agent/version'
7
7
  require 'date'
8
8
 
9
9
  Gem::Specification.new do |s|
@@ -28,7 +28,6 @@ Gem::Specification.new do |s|
28
28
  'VERSION',
29
29
  'site24x7-agent.gemspec',
30
30
  'conf/apminsight.conf',
31
- 'lib/version.rb',
32
31
  'lib/site24x7_apminsight.rb',
33
32
  'lib/agent/**/*'
34
33
  ]
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 1
7
- - 7
8
- - 2
9
- version: 1.7.2
7
+ - 8
8
+ - 3
9
+ version: 1.8.3
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: 2018-06-21 00:00:00 +05:30
17
+ date: 2021-03-23 00:00:00 +05:30
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -104,7 +104,6 @@ files:
104
104
  - VERSION
105
105
  - site24x7-agent.gemspec
106
106
  - conf/apminsight.conf
107
- - lib/version.rb
108
107
  - lib/site24x7_apminsight.rb
109
108
  - lib/agent/am_objectholder.rb
110
109
  - lib/agent/api/custom_tracker.rb
@@ -134,6 +133,7 @@ files:
134
133
  - lib/agent/util/am_constants.rb
135
134
  - lib/agent/util/am_util.rb
136
135
  - lib/agent/util/transaction_util.rb
136
+ - lib/agent/version.rb
137
137
  has_rdoc: true
138
138
  homepage: https://www.site24x7.com/help/apm/ruby-agent.html
139
139
  licenses: []