apminsight 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,60 @@
1
+ This License Agreement details the policy for license of ManageEngine APM Insight Ruby Agent ("Licensed Software")
2
+ Please read the following license carefully, before either (i) downloading the Licensed Software from an authorized website, or (ii) installing the Licensed Software. You acknowledge that you have read this License Agreement, have understood it, and agree to be bound by its terms. If you do not agree to the terms and conditions of this Agreement, do not download or install the Licensed Software.
3
+
4
+ 1. LICENSE GRANT
5
+
6
+ Zoho Corp. grants to you a non-exclusive, non-transferable, world-wide license to use the Licensed Software, including user documentation and updates during and as part of your subscription to APM Insight ("the Service").Licensed Software forms part and parcel of your subscription to the Service. You agree not to use the Licensed Software in any manner not explicitly permitted herein. Since the Licensed Software is provided as part of the Service, you also agree to comply with the terms under which the Service is provided to you.
7
+
8
+ 2. THIRD PARTY PRODUCTS:
9
+
10
+ The Licensed Software may contain software which originated with third party vendors and without limiting the general applicability of the other provisions of this Agreement, you agree that (a) the title to any third party software incorporated in the Licensed Software shall remain with the third party which supplied the same; and (b) you will not distribute any such third party software available with the Licensed Software, unless the license terms of such third party software provide otherwise.
11
+
12
+ 3. RESTRICTIONS ON USE:
13
+
14
+ In addition to all other terms and conditions of this Agreement, you shall not:
15
+ i. remove any copyright, trademark or other proprietary notices from the Licensed Software or its copies;
16
+ ii. make any copies except for one back-up or archival copy, for temporary emergency purpose;
17
+ iii. rent, lease, license, sublicense or distribute the Licensed Software or any portions of it on a standalone basis or as part of your application;
18
+ iv. modify or enhance the Licensed Software;
19
+ v. reverse engineer, decompile or disassemble the Licensed Software;
20
+
21
+ 4. TECHNICAL SUPPORT:
22
+
23
+ Technical support for the Licensed Software is provided as part of your subscription to the Service. Technical support for the Licensed Software is co-terminus with your subscription to the Service.
24
+
25
+ 5. OWNERSHIP AND INTELLECTUAL PROPERTY:
26
+
27
+ Zoho Corp. owns all right, title and interest in and to the Licensed Software. Zoho Corp. expressly reserves all rights not granted to you herein, including the right to discontinue or not to release any Software and to alter prices, features, specifications, capabilities, functions, licensing terms, release dates, general availability or characteristics of the Licensed Software. The Software is only licensed and not sold to you by Zoho Corp.
28
+
29
+ 6. AUDIT:
30
+
31
+ Zoho Corp. has the right to audit your Use of the Licensed Software by providing at least seven (7) days prior written notice of its intention to conduct such an audit at your facilities during normal business hours.
32
+
33
+ 7. CONFIDENTIALITY:
34
+
35
+ The Licensed Software contains proprietary information of Zoho Corp. that are protected by the laws of the United States and you hereby agree to take all reasonable efforts to maintain the confidentiality of the Licensed Software. You agree to reasonably communicate the terms and conditions of this Agreement to those persons employed by you who come into contact with or access the Licensed Software, and to use reasonable efforts to ensure their compliance with such terms and conditions, including but not limited to, not knowingly permitting such persons to use any portion of the Licensed Software for a purpose that is not allowed under this Agreement.
36
+
37
+ 8. WARRANTY DISCLAIMER:
38
+
39
+ ZOHO CORP. DOES NOT WARRANT THAT THE LICENSED SOFTWARE WILL BE ERROR-FREE. EXCEPT AS PROVIDED HEREIN, THE LICENSED SOFTWARE IS FURNISHED "AS IS" WITHOUT WARRANTY OF ANY KIND, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE AND WITHOUT WARRANTY AS TO THE PERFORMANCE OR RESULTS YOU MAY OBTAIN BY USING THE LICENSED SOFTWARE. YOU ARE SOLELY RESPONSIBLE FOR DETERMINING THE APPROPRIATENESS OF USING THE LICENSED SOFTWARE AND ASSUME ALL RISKS ASSOCIATED WITH THE USE OF IT, INCLUDING BUT NOT LIMITED TO THE RISKS OF PROGRAM ERRORS, DAMAGE TO OR LOSS OF DATA, PROGRAMS OR EQUIPMENT, AND UNAVAILABILITY OR INTERRUPTION OF OPERATIONS.
40
+ BECAUSE SOME JURISDICTIONS DO NOT ALLOW FOR THE EXCLUSION OR LIMITATION OF IMPLIED WARRANTIES, THE ABOVE EXCLUSIONS OR LIMITATIONS MAY NOT APPLY TO YOU.
41
+
42
+ 9. LIMITATION OF LIABILITY:
43
+
44
+ IN NO EVENT WILL ZOHO CORP. BE LIABLE TO YOU OR ANY THIRD PARTY FOR ANY SPECIAL, INCIDENTAL, INDIRECT, PUNITIVE OR EXEMPLARY OR CONSEQUENTIAL DAMAGES, OR DAMAGES FOR LOSS OF BUSINESS, LOSS OF PROFITS, BUSINESS INTERRUPTION, OR LOSS OF BUSINESS INFORMATION ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM OR FOR ANY CLAIM BY ANY OTHER PARTY EVEN IF ZOHO CORP. HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. ZOHO CORP.'S ENTIRE LIABILITY WITH RESPECT TO ITS OBLIGATIONS UNDER THIS AGREEMENT OR OTHERWISE WITH RESPECT TO THE LICENSED SOFTWARE SHALL NOT EXCEED THE SUBSCRIPTION FEE PAID BY YOU FOR THE SERVICE.
45
+ BECAUSE SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES, THE ABOVE EXCLUSIONS OR LIMITATIONS MAY NOT APPLY TO YOU.
46
+
47
+ 10. INDEMNIFICATION:
48
+
49
+ Zoho Corp. agrees to indemnify and defend you from and against any and all claims, actions or proceedings, arising out of any claim that the Licensed Software infringes or violates any valid U.S. patent, copyright or trade secret right of any third party; so long as you provide; (i) prompt written notice to Zoho Corp. of such claim; (ii) cooperate with Zoho Corp. in the defense and/or settlement thereof, at Zoho Corp.'s expense; and, (iii) allow Zoho Corp. to control the defense and all related settlement negotiations. The above is Zoho Corp.'s sole obligation to you and shall be your sole and exclusive remedy pursuant to this Agreement for intellectual property infringement.
50
+ Zoho Corp. shall have no indemnity obligation for claims of infringement to the extent resulting or alleged to result from (i) any combination, operation, or use of the Licensed Software with any programs or equipment not supplied by Zoho Corp.; (ii) any modification of the Licensed Software by a party other than Zoho Corp.; and (iii) your failure, within a reasonable time frame, to implement any replacement or modification of Licensed Software provided by Zoho Corp.
51
+
52
+ 11. TERMINATION:
53
+
54
+ This Agreement is co-terminus with your subscription to the Service. You may terminate this Agreement at any time by destroying or returning to Zoho Corp. all copies of the Licensed Software in your possession. Zoho Corp. may terminate this Agreement for any reason, including but not limited to your breach of any of the terms of this Agreement. Upon termination, you shall destroy or return to Zoho Corp. all copies of the Licensed Software and certify in writing that all known copies have been destroyed. All provisions relating to confidentiality, proprietary rights, non-disclosure, and limitation of liability shall survive the termination of this Agreement.
55
+
56
+ 12. GENERAL:
57
+
58
+ If you are a resident of the United States or Canada, this Agreement shall be governed by and interpreted in all respects by the laws of the State of California, without reference to conflict of laws' principles, as such laws are applied to agreements entered into and to be performed entirely within California between California residents. If you are a resident of any other country, this Agreement shall be governed by and interpreted in all respects by the laws of the Republic of India without reference to conflict of laws' principles, as such laws are applied to agreements entered into and to be performed entirely within the Republic of India between residents of the Republic of India. If you are a resident of the United States or Canada, you agree to submit to the personal jurisdiction of the courts in the Northern District of California. If you are a resident of any other country, you agree to submit to the personal jurisdiction of the courts in Chennai, India. This Agreement constitutes the entire agreement between the parties, and supersedes all prior communications, understandings or agreements between the parties. Any waiver or modification of this Agreement shall only be effective if it is in writing and signed by both parties hereto. If any part of this Agreement is found to be invalid or unenforceable, the remainder shall be interpreted so as to reasonably effect the intention of the parties.
59
+
60
+
@@ -0,0 +1,69 @@
1
+ APM Insight Ruby Agent
2
+ Applications Manager's Ruby agent gives you end-to-end web-transaction awareness enabling you to isolate performance issues and resolve them quickly.Applications Manager requires a monitoring agent (ruby gem) to be deployed in your application server to monitor Ruby application performance. Download the latest Ruby Agent(apminsight.gem) and deploy it in your application server. The agent collects application performance metrics and sends it to the central Applications Manager server at fixed intervals i.e. every 60 seconds.
3
+
4
+ Installing APM Insight Agent
5
+
6
+ Ruby Agent installation can be done in two ways:
7
+
8
+ * Install from RubyGems by using the following command in the system where Ruby is installed :
9
+
10
+ gem install apminsight
11
+
12
+ OR
13
+
14
+ * Download the apminsight.gem file directly from our website or the RubyGems website and run the command
15
+
16
+ gem install apminsight.gem
17
+
18
+ Configuration
19
+
20
+ After installation of the gem:
21
+
22
+ For each of your applications, add the following line to the application gemfile:
23
+
24
+ gem 'apminsight'
25
+
26
+ OR
27
+
28
+ For each of your applications, add the following line to the application initializer block:
29
+
30
+ require 'apminsight'
31
+
32
+ A copy of the configuration file apminsight.conf will be available in the <Gem Installed folder> /apminsight/conf/. Configure the class name in the configuration file(include.packages), so that all the methods in that class can be instrumented and details will be reported in tracedata.
33
+
34
+
35
+ The following configuration options are mandatory and should be provided for the agent to be initialized:
36
+
37
+ application.name - The application's name to be displayed in Applications Manager.
38
+
39
+ apm.host - The host where Applications Manager is running.
40
+
41
+ apm.port - The HTTP port of Applications Manager.
42
+
43
+ behind.proxy - The proxy network under which the agent is installed
44
+
45
+ agent.server.port - The HTTP listening port of the Application Server.
46
+
47
+ More configuration options of APM Insight Ruby Agent can be found here.
48
+
49
+ Supported Environments :
50
+
51
+ Ruby - 1.8.7 and higher
52
+
53
+ Rails - 3.0 and higher
54
+
55
+ References
56
+
57
+ * Download link for Applications Manager
58
+
59
+ http://www.manageengine.com/products/applications_manager/
60
+
61
+ * Download link for apminsight
62
+
63
+ http://www.manageengine.com/products/applications_manager/
64
+ http://rubygems.org/gems/apminsight
65
+
66
+ * Help Documentation for apminsight
67
+
68
+ http://www.manageengine.com/products/applications_manager/help/APMInsight/installing-transaction-agent.html
69
+
@@ -0,0 +1,63 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
17
+ gem.name = "apminsight"
18
+ gem.homepage = "http://github.com/defunkt/manageengine_rubyagent"
19
+ gem.license = "MIT"
20
+ gem.summary = %Q{Application Performace Monitor}
21
+ gem.description = %Q{Application Performace Monitor : Monitor the web tranasactions}
22
+ gem.email = "sabarinathan@zohcorp.com"
23
+ gem.authors = ["Sabari"]
24
+ gem.files=Dir.glob('lib/**/*.*')
25
+ # dependencies defined in Gemfile
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rake/testtask'
30
+ Rake::TestTask.new(:test) do |test|
31
+ test.libs << 'lib' << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+
36
+ require 'rcov/rcovtask'
37
+ Rcov::RcovTask.new do |test|
38
+ test.libs << 'test'
39
+ test.pattern = 'test/**/test_*.rb'
40
+ test.verbose = true
41
+ test.rcov_opts << '--exclude "gems/*"'
42
+ end
43
+
44
+ task :default => :test
45
+
46
+ require 'rake/rdoctask'
47
+ Rake::RDocTask.new do |rdoc|
48
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
49
+
50
+ rdoc.rdoc_dir = 'rdoc'
51
+ rdoc.title = "apm-agent #{version}"
52
+ rdoc.rdoc_files.include('README*')
53
+ rdoc.rdoc_files.include('lib/**/*.*')
54
+ rdoc.rdoc_files.include('lib/agent/**/*.*')
55
+ rdoc.rdoc_files.include('lib/agent/*.*')
56
+ rdoc.rdoc_files.include('lib/agent/logging/*.*')
57
+ rdoc.rdoc_files.include('lib/agent/server/*.*')
58
+ rdoc.rdoc_files.include('lib/agent/server/worker/*.*')
59
+ rdoc.rdoc_files.include('lib/agent/configuration/*.*')
60
+ rdoc.rdoc_files.include('lib/agent/metrics/*.*')
61
+ rdoc.rdoc_files.include('lib/agent/util/*.*')
62
+ rdoc.rdoc_files.include('lib/config/*.*')
63
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.3
@@ -0,0 +1,105 @@
1
+ # $Id$
2
+ #
3
+ ################### APM Insight Agent Configuration File ###################
4
+ #
5
+ #This file contains configuration options for APM Insight agent installation in your Application Server.
6
+ #
7
+ #NOTE: Though the properties can be defined in any different order, it is advisable to maintain
8
+ #the below order for related properties and ease of reference.
9
+ #
10
+ #All the configuration options defaults to factory configuration if commented or not supported values
11
+
12
+ #Logical name of your application.Say for example you have "Order Processing" applications running in
13
+ #10 instances of Tomcat server. Specify the name as "Order Processing" for the name in all the 10
14
+ #instances while deploying the agent. Applications Manager will group the data from 10 instances of
15
+ #Tomcat and provide response time, throughput etc.
16
+ application.name=My Application
17
+
18
+ #Name of the host or IPV4 address where the Applications Manager is installed and running.
19
+ #[Mandatory]
20
+ apm.host=localhost
21
+
22
+ #Whether the data to the Applications Manager should be sent through HTTPS protocol.
23
+ #default value: false
24
+ apm.protocol.https=false
25
+
26
+ #HTTP/HTTPS Port of the Applications Manager.(Specify HTTPS port if apm.protocol.https is true)
27
+ #[Mandatory]
28
+ apm.port=9090
29
+
30
+ #APM Insight agent communicates to the Applications Manager through the HTTP/HTTPS protocol.
31
+ #Specify Proxy server configuration when there is a proxy server between APM Insight agent and
32
+ #Applications Manager server. To check whether there is a proxy, open a browser in the APM Insight
33
+ #Agent machine and try connect to http(s)://apm.host:apm.port/ It should display the login page of
34
+ #Applications Manager.Check with your network administrators if you are not able to see the login page,
35
+ #may be port has to be opened in firewall. Check whether any proxy server is configured in the browser
36
+ #and specify those values here. When there is no proxy specified in the browser, then it is a direct
37
+ #connection available between the two machines and no need to configure proxy details here.
38
+ #
39
+ behind.proxy=false
40
+ #proxy.server.host=proxyserver
41
+ #proxy.server.port=proxyport
42
+ #proxy.auth.username=proxyuser
43
+ #proxy.auth.password=proxypassword
44
+
45
+ #Application Server HTTP/HTTPS listening port.Say for example when you are deploying the agent in Tomcat
46
+ #Server running in 8080 port, specify the value as 8080.
47
+ #[Mandatory]
48
+ agent.server.port=8080
49
+
50
+ #The Apdex (Application Performance Index) threshold is used to calculate application performance score.
51
+ #More at http://www.apdex.org.
52
+ #A Transaction is said to be satisfied, if the response time is equal to or below the apdex.threshold.
53
+ #A Transaction is said to be tolerating, if the response time is greater than apdex.threshold and less
54
+ #than 4 times of apdex.threshold. A Transaction is said to be frustrated, if the response time is greater
55
+ #than 4 times of apdex.threshold. Say for example when you specify the value as 2, transactions with response
56
+ #time less than 2 seconds is considered as satisfied, transactions with response time greater than 2 and
57
+ #less than 8 is considered as tolerating and transactions with response time greater than 8 seconds is
58
+ #considered as frustrating.
59
+ #default value: 0.5 (second)
60
+ apdex.threshold=0.5
61
+
62
+ #Whether SQL queries getting executed in your application need to be tracked or not.
63
+ #default value: true
64
+ sql.capture.enabled=true
65
+
66
+ #Whether the transaction trace is enabled or not. Setting this value to true will send the trace of the
67
+ #slow transaction.
68
+ #default value: true
69
+ transaction.trace.enabled=true
70
+
71
+ #Threshold to construct the trace for slow transactions. Transaction Traces violating this threshold will be
72
+ #collected and sent to the server. Used to analyze and troubleshoot the Transaction by the user.
73
+ #default value: 2 (second)
74
+ transaction.trace.threshold=2
75
+
76
+ #When the sql query capturing is enabled(set to true), should the queries in traces be parameterized?
77
+ #Meaning, strip all the literal values from the sql statement
78
+ #default value: true
79
+ transaction.trace.sql.parametrize=true
80
+
81
+ #Threshold value to generate a stack trace to identify the caller who executed a slow query. This stack
82
+ #trace is sent to the server for the user to analyze and troubleshoot
83
+ #default value: 3 (second)
84
+ transaction.trace.sql.stacktrace.threshold=3
85
+
86
+ #The packages which also needs to be instrumented. By Default, APM Insight does not instrument all the class
87
+ #loaded in the JVM. eg: configuring com/test/customimpl/.* will include all the packages & classes that
88
+ #starts with com.test.customimpl. It is best if this is enabled only in the testing/staging environment.
89
+ #Use comma(,) to separate multiple entries.
90
+ #include.packages=
91
+
92
+ #Sampling counter.Say for example when you specify the value as 20, agent will track one in 20 transactions.
93
+ #default value: 1 (request)
94
+ transaction.tracking.request.interval=1
95
+
96
+ #Directory where agent logs information separately.
97
+ #Defaults to the directory where apminsight-javaagent.jar is installed.
98
+ #Use backward slash(/) as path separator.
99
+ #apminsight.log.dir=./apminsight/logs
100
+
101
+ #The log level at which the APM Insight agent should record logging
102
+ #information. The levels are SEVERE, WARNING, INFO, FINE in the order
103
+ #respectively. Defaults to the level INFO if commented or mentioned
104
+ #incorrectly.
105
+ apminsight.log.level=INFO
@@ -0,0 +1,66 @@
1
+
2
+ require "agent/configuration/am_configuration"
3
+ require "agent/logging/am_logger"
4
+ require "agent/util/am_util"
5
+ require "agent/util/am_constants"
6
+ require "agent/server/am_connector"
7
+ require "agent/server/am_agent"
8
+ require "agent/metrics/am_metricscollector"
9
+ require "agent/metrics/am_metricstore"
10
+ require "agent/metrics/am_metricsformatter"
11
+ require "agent/metrics/am_metricsparser"
12
+ require "agent/server/instrument/am_instrumenter"
13
+
14
+ module ManageEngine
15
+
16
+ class APMObjectHolder
17
+ attr_reader :config,:log,:util,:constants,:shutdown,:connector,:agent,:collector
18
+ attr_accessor :shutdown,:agent_initialized,:last_dispatch_time,:instrumenter,:store,:formatter,:parser
19
+ @@objects = nil
20
+ #Don't Change the Order of Initialize
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
+ @instrumenter = ManageEngine::APMInstrumenter.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 ] "
38
+ end
39
+
40
+ def self.instance
41
+ if(@@objects==nil)
42
+ @@objects = ManageEngine::APMObjectHolder.new
43
+ @@objects.initializeObjects
44
+ end
45
+ return @@objects
46
+ end
47
+
48
+ def shutdownagent
49
+ ###@agent_initialized=false
50
+ #@shutdown = true
51
+ #@constants = nil
52
+ #@util = nil
53
+ #@config = nil
54
+ #@connector = nil
55
+ #@store = nil
56
+ #@collector=nil
57
+ #@instrumenter = nil
58
+ #@formatter = nil
59
+ #@parser = nil
60
+ #@agent = nil
61
+ #@log.info "[ APMObjectHolder ][ All Objects deleted ] "
62
+ #@log = nil
63
+ end
64
+
65
+ end #c
66
+ end#m
@@ -0,0 +1,190 @@
1
+ require 'rubygems'
2
+ require 'json'
3
+ require 'socket'
4
+ require 'rails'
5
+ require 'agent/am_objectholder'
6
+
7
+ module ManageEngine
8
+ class APMConfig
9
+ attr_reader :agenthost,:agentport,:instance_id,:alreadyconnected,:apmhost,:apmport
10
+ attr_reader :appname,:proxyneeded, :apdex_t, :trans_trace, :trans_trace_t, :sql_capture, :sql_capture_params, :sql_trace_t,:proxy_user,:proxy_pass
11
+ attr_reader :proxy_host,:proxy_port ,:is_secured, :logs_dir ,:connection_retry,:agent_enabled,:connect_interval,:db_operations,:include_packages
12
+ attr_accessor :app_db,:app_dispatcher,:lastupdatedtime
13
+ def initialize
14
+ @obj = ManageEngine::APMObjectHolder.instance
15
+
16
+ #@config = @obj.util.readProperties(@obj.constants.apm_conf)
17
+ configureFile
18
+ @agenthost = Socket.gethostname
19
+ assignConfig
20
+ @obj.log.setLevel @config["apminsight.log.level"]
21
+ @instance_id = 0
22
+ @agent_enabled = false
23
+ @alreadyconnected = checkAgentInfo
24
+ @db_operations =["select","insert","update","delete"]
25
+ @obj.log.debug "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
26
+ @obj.log.debug "APP HOME #{File.absolute_path(".")} "
27
+ @obj.log.debug "APP HOME #{Dir.pwd} "
28
+ @obj.log.debug "Configuration : "
29
+ @obj.log.debug "Agent Name : #{@agenthost}"
30
+ @obj.log.debug "Agent Already Connected : #{@alreadyconnected}"
31
+ @obj.log.debug "Agent Enabled : #{@agent_enabled}"
32
+ @obj.log.debug "Allowed DB Operations : #{@db_operations}"
33
+ @config.each do|key,val|
34
+ @obj.log.info "#{key} => #{val}"
35
+ end
36
+ @obj.log.debug "@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"
37
+ @app_db="dummydb"
38
+ @app_dispatcher = getDispatcher
39
+ @lastupdatedtime=File.mtime(@obj.constants.apm_conf).to_i
40
+ end
41
+
42
+ def configureFile
43
+ begin
44
+ gem_conf = Gem.loaded_specs[@obj.constants.apm_gem].full_gem_path
45
+ #gem_conf = File.join(gem_conf, 'lib')
46
+ gem_conf = File.join(gem_conf, 'conf')
47
+ gem_conf = File.join(gem_conf, 'apminsight.conf')
48
+ if(FileTest.exists?(@obj.constants.apm_conf))
49
+ #conf file exists in APPlication Home
50
+ @obj.log.debug "Config File Read from #{@obj.constants.apm_conf}"
51
+ @config = @obj.util.readProperties(@obj.constants.apm_conf)
52
+ else
53
+ #conf file not exists in APPlications Home. So 1. copy it for gem locations
54
+ if @obj.util.copyFiles gem_conf,@obj.constants.apm_conf
55
+ #copied sucessfully
56
+ @obj.log.debug "Config File Read from #{@obj.constants.apm_conf}"
57
+ @config = @obj.util.readProperties(@obj.constants.apm_conf)
58
+ else
59
+ #Problem in copying, so reading props from Conf file in Gem Location
60
+ @obj.log.debug "Config File Read from #{gem_conf}"
61
+ @config = @obj.util.readProperties(gem_conf)
62
+ end
63
+ end
64
+
65
+ rescue Exception=>e
66
+ @obj.log.info "[Exception] Problem in Reading Configuration File : \n File : #{@obj.constants.apm_conf}"
67
+ @obj.log.logException "#{e.message}",e
68
+ @config = @obj.util.readProperties(gem_conf)
69
+ ensure
70
+ end
71
+ end
72
+
73
+ def checkAgentInfo
74
+ if FileTest.exists?(@obj.constants.agent_conf)
75
+ @obj.log.debug "Status : Agent Already Connected"
76
+ props = @obj.util.readProperties(@obj.constants.agent_conf)
77
+ @instance_id = props["agent.id"]
78
+ @agent_enabled= @obj.util.getBooleanValue props["agent.enabled"]
79
+ true
80
+ else
81
+ @obj.log.info "Status : Agent not connected"
82
+ false
83
+ end
84
+ end
85
+
86
+ def updateAgentInfoFile(props)
87
+ @instance_id = props["agent.id"]
88
+ @agent_enabled= @obj.util.getBooleanValue props["agent.enabled"]
89
+ @obj.util.writeProperties(@obj.constants.agent_conf,props)
90
+ end
91
+
92
+ def initValues
93
+ @apmport=8080
94
+ @appname="My Application"
95
+ @proxyneeded = false
96
+ @proxy_host="localhost"
97
+ @proxy_port=80
98
+ @proxy_user=""
99
+ @proxy_pass=""
100
+ @is_secured=false
101
+ @logs_dir="./log"
102
+ @connection_retry = 0
103
+ @connect_interval = 60
104
+ @apdex_t=0.5
105
+ @include_packages=Array.new
106
+ @trans_trace_t=2
107
+ @sql_trace_t=3
108
+ end
109
+
110
+ def assignConfig
111
+ initValues
112
+ @config.each do |key,value|
113
+ case key
114
+ when "application.name" then @appname=value
115
+ when "apm.host" then @apmhost=value
116
+ when "apm.port" then @apmport=isInteger(@apmport,value)
117
+ when "behind.proxy" then @proxyneeded=@obj.util.getBooleanValue value
118
+ when "agent.server.port" then @agentport=isInteger(@agentport,value)
119
+ when "apdex.threshold" then @apdex_t=isFloat(@apdex_t,value)
120
+ when "transaction.trace.enabled" then @trans_trace=@obj.util.getBooleanValue value
121
+ when "transaction.trace.threshold" then @trans_trace_t=isFloat(@trans_trace_t,value)
122
+ when "sql.capture.enabled" then @sql_capture=@obj.util.getBooleanValue value
123
+ when "transaction.trace.sql.parametrize" then @sql_capture_params=@obj.util.getBooleanValue value
124
+ when "transaction.trace.sql.stacktrace.threshold" then @sql_trace_t=isFloat(@sql_trace_t,value)
125
+ when "proxy.server.host" then @proxy_host=value
126
+ when "proxy.server.port" then @proxy_port=value
127
+ when "proxy.auth.username" then @proxy_user=value
128
+ when "proxy.auth.password" then @proxy_pass=value
129
+ when "apminsight.secure" then @is_secured=@obj.util.getBooleanValue value
130
+ when "apminsight.log.dir" then @logs_dir=value
131
+ when "agent.connection.retry" then @connection_retry=value #Not in Conf - yet to come
132
+ when "agent.connection.interval" then @connect_interval=value#Not in Conf - yet to come
133
+ when "include.packages" then @include_packages=@obj.util.getArray value,","
134
+ end
135
+ end
136
+ end
137
+
138
+ def getAgentInfo
139
+ data = Hash.new
140
+ agentdata = Hash.new
141
+ agentdata = {"application.type"=>"RUBY","application.name"=>@appname,"hostname"=>@agenthost,"port"=>@agentport,"agent.version"=>"1.0"}
142
+ data["agent_info"]=agentdata
143
+ data["environment"]=getEnvData
144
+ data
145
+ end
146
+
147
+ def getEnvData
148
+ env = Hash.new
149
+ begin
150
+ ENV.to_hash.each do |key, value|
151
+ env[key] = value
152
+ end
153
+ env["Application Path"]="#{Rails.root}"
154
+ rescue Exception=>e
155
+ end
156
+ env
157
+ end
158
+
159
+
160
+ def getDispatcher
161
+ dispatcher = "unknown"
162
+ if defined?(PhusionPassenger) then
163
+ dispatcher = "passenger"
164
+ end
165
+ dispatcher
166
+ end
167
+
168
+ def isInteger default,value
169
+ if @obj.util.is_integer value
170
+ value.to_i
171
+ else
172
+ @obj.log.info "Problem in getting Integer Value #{value} .. So setting default value #{default} "
173
+ default.to_i
174
+ end
175
+
176
+ end
177
+
178
+ def isFloat default,value
179
+ if @obj.util.is_float value
180
+ value.to_f
181
+ else
182
+ default.to_f
183
+ @obj.log.info "Problem in getting Integer Value #{value} .. So setting default value #{default} "
184
+ end
185
+ end
186
+
187
+
188
+ end#c
189
+ end#m
190
+