rorvswild 1.5.17 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +49 -8
- data/lib/rorvswild/agent.rb +19 -33
- data/lib/rorvswild/deployment.rb +93 -0
- data/lib/rorvswild/host.rb +58 -0
- data/lib/rorvswild/installer.rb +29 -21
- data/lib/rorvswild/local/javascript/local.js +2 -2
- data/lib/rorvswild/local/local.html.erb +1 -1
- data/lib/rorvswild/local/stylesheet/local.css +4 -0
- data/lib/rorvswild/metrics/cpu.rb +47 -16
- data/lib/rorvswild/metrics/memory.rb +1 -1
- data/lib/rorvswild/metrics.rb +11 -12
- data/lib/rorvswild/plugin/net_http.rb +1 -1
- data/lib/rorvswild/queue.rb +2 -2
- data/lib/rorvswild/version.rb +1 -1
- data/lib/rorvswild.rb +3 -0
- metadata +7 -5
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: f0d7eae69ceb93804c2297b8fb97a400e09d183eeeb46ac879dc02873ba7f5b0
|
|
4
|
+
data.tar.gz: 0bfe3e2d48fcecd010eeb399ad896d6e4e519073aa6ae0fc160ebcb9e1cf554c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5bf001a094bfa234414b8247c18d57159b734f1a829ef62997cdf66b7265fdc40e9cdad0530ecac8bc108459b202930487f0cad30b610cc4ebd7b00326ef17af
|
|
7
|
+
data.tar.gz: 25ace108524d491befd74c9682c92f2a95e17c4ee4b8e11174143bb29425685074d81923f4cf981e0f0dc313ab7c493731206037d6036d2d74ff633411519ffd
|
data/README.md
CHANGED
|
@@ -218,30 +218,71 @@ In the case you want a custom logger such as Syslog, you can only do it by initi
|
|
|
218
218
|
RorVsWild.start(api_key: "API_KEY", logger: Logger::Syslog.new)
|
|
219
219
|
```
|
|
220
220
|
|
|
221
|
-
|
|
221
|
+
### Deployment tracking
|
|
222
222
|
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
It
|
|
223
|
+
Since version 1.6.0, RorVsWild compares performances between each deployment.
|
|
224
|
+
That is convenient to detect quickly a performance deterioration.
|
|
225
|
+
|
|
226
|
+
It is working without any actions from your part if the application is :
|
|
227
|
+
|
|
228
|
+
- Deployed via Capistrano
|
|
229
|
+
- Inside a Git repositoriy
|
|
230
|
+
- Hosted on Heroku if [Dyno metadata](https://devcenter.heroku.com/articles/dyno-metadata) is enabled
|
|
231
|
+
- Hosted on Scalingo
|
|
232
|
+
|
|
233
|
+
Because we are not aware of all cloud hosting providers, there is a generic method to provide these data via the configuration :
|
|
227
234
|
|
|
228
235
|
```yaml
|
|
229
236
|
# config/rorvswild.yml
|
|
230
237
|
production:
|
|
231
238
|
api_key: API_KEY
|
|
232
|
-
|
|
233
|
-
|
|
239
|
+
deployment:
|
|
240
|
+
revision: <%= "Anything that will return the deployment version" %> # Mandatory
|
|
241
|
+
description: <%= "Eventually if you have a description such as a Git message" %>
|
|
242
|
+
author: <%= "Author's name of the deployment" %>
|
|
243
|
+
email: <%= "emailOf@theAuthor.com" %>
|
|
234
244
|
```
|
|
235
245
|
|
|
236
246
|
Here is the equivalent if you prefer initialising RorVsWild manually :
|
|
237
247
|
|
|
238
248
|
```ruby
|
|
239
249
|
# config/initializers/rorvswild.rb
|
|
240
|
-
RorVsWild.start(api_key: "API_KEY",
|
|
250
|
+
RorVsWild.start(api_key: "API_KEY", deployment: {
|
|
251
|
+
revision: "Unique version number such as Git commit ID",
|
|
252
|
+
description: "Message such as in Git",
|
|
253
|
+
author: "Deployer's name",
|
|
254
|
+
email: "Deployer's email"
|
|
255
|
+
})
|
|
241
256
|
```
|
|
242
257
|
|
|
258
|
+
Only the revision is mandatory, but it's better if you are able to provide more information.
|
|
259
|
+
|
|
260
|
+
|
|
261
|
+
#### Server metrics monitoring
|
|
262
|
+
|
|
263
|
+
Since version 1.6.0 RorVsWild monitors server metrics such as load average, CPU, memory, swap and disk space.
|
|
264
|
+
For now, only Linux is supported.
|
|
243
265
|
The data are available in a server tab beside requests and jobs.
|
|
244
266
|
|
|
267
|
+
Metrics are grouped by hostnames.
|
|
268
|
+
Cloud providers give random hostnames which change on every deployment.
|
|
269
|
+
You can manually define them:
|
|
270
|
+
|
|
271
|
+
```yaml
|
|
272
|
+
# config/rorvswild.yml
|
|
273
|
+
production:
|
|
274
|
+
api_key: API_KEY
|
|
275
|
+
server:
|
|
276
|
+
name: <%= "Some code that return a relevant hostname" %>
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
Here is the equivalent if you prefer initialising RorVsWild manually :
|
|
280
|
+
|
|
281
|
+
```ruby
|
|
282
|
+
# config/initializers/rorvswild.rb
|
|
283
|
+
RorVsWild.start(api_key: "API_KEY", server: {name: "host.name"})
|
|
284
|
+
```
|
|
285
|
+
|
|
245
286
|
## Contributing
|
|
246
287
|
|
|
247
288
|
1. Fork it ( https://github.com/[my-github-username]/rorvswild/fork )
|
data/lib/rorvswild/agent.rb
CHANGED
|
@@ -30,16 +30,18 @@ module RorVsWild
|
|
|
30
30
|
@client = Client.new(@config)
|
|
31
31
|
@queue = config[:queue] || Queue.new(client)
|
|
32
32
|
@locator = RorVsWild::Locator.new
|
|
33
|
+
Host.load_config(config)
|
|
34
|
+
Deployment.load_config(config)
|
|
33
35
|
|
|
34
36
|
RorVsWild.logger.debug("Start RorVsWild #{RorVsWild::VERSION}")
|
|
35
37
|
setup_plugins
|
|
36
38
|
cleanup_data
|
|
39
|
+
send_deployment
|
|
37
40
|
end
|
|
38
41
|
|
|
39
42
|
def load_features
|
|
40
43
|
features = config[:features] || []
|
|
41
|
-
features.include?("server_metrics")
|
|
42
|
-
require "rorvswild/metrics" if features.include?("server_metrics")
|
|
44
|
+
RorVsWild.logger.info("Server metrics are now monitored enabled by default") if features.include?("server_metrics")
|
|
43
45
|
end
|
|
44
46
|
|
|
45
47
|
def setup_plugins
|
|
@@ -85,7 +87,7 @@ module RorVsWild
|
|
|
85
87
|
raise
|
|
86
88
|
ensure
|
|
87
89
|
current_data[:runtime] = RorVsWild.clock_milliseconds - current_data[:started_at]
|
|
88
|
-
|
|
90
|
+
queue_job
|
|
89
91
|
end
|
|
90
92
|
end
|
|
91
93
|
|
|
@@ -96,7 +98,7 @@ module RorVsWild
|
|
|
96
98
|
def stop_request
|
|
97
99
|
return unless current_data
|
|
98
100
|
current_data[:runtime] = RorVsWild.clock_milliseconds - current_data[:started_at]
|
|
99
|
-
|
|
101
|
+
queue_request
|
|
100
102
|
end
|
|
101
103
|
|
|
102
104
|
def catch_error(extra_details = nil, &block)
|
|
@@ -109,7 +111,7 @@ module RorVsWild
|
|
|
109
111
|
end
|
|
110
112
|
|
|
111
113
|
def record_error(exception, extra_details = nil)
|
|
112
|
-
|
|
114
|
+
send_error(exception_to_hash(exception, extra_details))
|
|
113
115
|
end
|
|
114
116
|
|
|
115
117
|
def push_exception(exception, options = nil)
|
|
@@ -153,21 +155,8 @@ module RorVsWild
|
|
|
153
155
|
config[:ignore_jobs].include?(name)
|
|
154
156
|
end
|
|
155
157
|
|
|
156
|
-
def
|
|
157
|
-
|
|
158
|
-
rescue Exception => ex
|
|
159
|
-
@os_description = RbConfig::CONFIG["host_os"]
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
def hostname
|
|
163
|
-
if gae_instance = ENV["GAE_INSTANCE"] || ENV["CLOUD_RUN_EXECUTION"]
|
|
164
|
-
gae_instance
|
|
165
|
-
elsif dyno = ENV["DYNO"] # Heroku
|
|
166
|
-
dyno.start_with?("run.") ? "run.*" :
|
|
167
|
-
dyno.start_with?("release.") ? "release.*" : dyno
|
|
168
|
-
else
|
|
169
|
-
Socket.gethostname
|
|
170
|
-
end
|
|
158
|
+
def send_deployment
|
|
159
|
+
client.post("/deployments", deployment: Deployment.to_h)
|
|
171
160
|
end
|
|
172
161
|
|
|
173
162
|
#######################
|
|
@@ -177,7 +166,12 @@ module RorVsWild
|
|
|
177
166
|
private
|
|
178
167
|
|
|
179
168
|
def initialize_data
|
|
180
|
-
Thread.current[:rorvswild_data] = {
|
|
169
|
+
Thread.current[:rorvswild_data] = {
|
|
170
|
+
sections: [],
|
|
171
|
+
section_stack: [],
|
|
172
|
+
environment: Host.to_h,
|
|
173
|
+
started_at: RorVsWild.clock_milliseconds,
|
|
174
|
+
}
|
|
181
175
|
end
|
|
182
176
|
|
|
183
177
|
def cleanup_data
|
|
@@ -186,15 +180,15 @@ module RorVsWild
|
|
|
186
180
|
result
|
|
187
181
|
end
|
|
188
182
|
|
|
189
|
-
def
|
|
183
|
+
def queue_request
|
|
190
184
|
(data = cleanup_data) && data[:name] && queue.push_request(data)
|
|
191
185
|
end
|
|
192
186
|
|
|
193
|
-
def
|
|
187
|
+
def queue_job
|
|
194
188
|
queue.push_job(cleanup_data)
|
|
195
189
|
end
|
|
196
190
|
|
|
197
|
-
def
|
|
191
|
+
def send_error(hash)
|
|
198
192
|
client.post_async("/errors".freeze, error: hash)
|
|
199
193
|
end
|
|
200
194
|
|
|
@@ -208,15 +202,7 @@ module RorVsWild
|
|
|
208
202
|
backtrace: exception.backtrace || ["No backtrace"],
|
|
209
203
|
exception: exception.class.to_s,
|
|
210
204
|
extra_details: context,
|
|
211
|
-
environment:
|
|
212
|
-
os: os_description,
|
|
213
|
-
user: Etc.getlogin,
|
|
214
|
-
host: Socket.gethostname,
|
|
215
|
-
ruby: RUBY_DESCRIPTION,
|
|
216
|
-
pid: Process.pid,
|
|
217
|
-
cwd: Dir.pwd,
|
|
218
|
-
lib_paths: locator.lib_paths,
|
|
219
|
-
},
|
|
205
|
+
environment: Host.to_h,
|
|
220
206
|
}
|
|
221
207
|
end
|
|
222
208
|
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RorVsWild
|
|
4
|
+
module Deployment
|
|
5
|
+
def self.load_config(config)
|
|
6
|
+
read
|
|
7
|
+
if hash = config[:deployment]
|
|
8
|
+
@description = hash[:description]
|
|
9
|
+
@revision = hash[:revision]
|
|
10
|
+
@author = hash[:author]
|
|
11
|
+
@email = hash[:email]
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.revision
|
|
16
|
+
@revision
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.description
|
|
20
|
+
@description
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.author
|
|
24
|
+
@author
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.email
|
|
28
|
+
@email
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.ruby
|
|
32
|
+
RUBY_VERSION
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.rails
|
|
36
|
+
Rails.version if defined?(Rails)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.rorvswild
|
|
40
|
+
RorVsWild::VERSION
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.to_h
|
|
44
|
+
@to_h ||= {revision: revision, description: description, author: author, email: email, ruby: ruby, rails: rails, rorvswild: rorvswild}.compact
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def self.read
|
|
48
|
+
read_from_heroku || read_from_scalingo || read_from_git || read_from_capistrano
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
private
|
|
52
|
+
|
|
53
|
+
def self.read_from_heroku
|
|
54
|
+
return unless ENV["HEROKU_SLUG_COMMIT"]
|
|
55
|
+
@revision = ENV["HEROKU_SLUG_COMMIT"]
|
|
56
|
+
@description = ENV["HEROKU_SLUG_DESCRIPTION"]
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def self.read_from_scalingo
|
|
60
|
+
return unless ENV["SOURCE_VERSION"]
|
|
61
|
+
@revision = ENV["SOURCE_VERSION"]
|
|
62
|
+
end
|
|
63
|
+
|
|
64
|
+
def self.read_from_git
|
|
65
|
+
@revision = normalize_string(`git rev-parse HEAD`) rescue nil
|
|
66
|
+
return unless @revision
|
|
67
|
+
lines = `git log -1 --pretty=%an%n%ae%n%B`.lines rescue nil
|
|
68
|
+
return unless lines
|
|
69
|
+
@author = normalize_string(lines[0])
|
|
70
|
+
@email = normalize_string(lines[1])
|
|
71
|
+
@description = lines[2..-1] && normalize_string(lines[2..-1].join)
|
|
72
|
+
@revision
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
def self.read_from_capistrano
|
|
76
|
+
return unless File.readable?("REVISION")
|
|
77
|
+
return unless @revision = File.read("REVISION")
|
|
78
|
+
lines = `git --git-dir ../../repo log --format=%an%n%ae%n%B -n 1 #{@revision}`.lines rescue nil
|
|
79
|
+
return unless lines
|
|
80
|
+
@author = normalize_string(lines[0])
|
|
81
|
+
@email = normalize_string(lines[1])
|
|
82
|
+
@description = lines[2..-1] && normalize_string(lines[2..-1].join)
|
|
83
|
+
@revision
|
|
84
|
+
end
|
|
85
|
+
|
|
86
|
+
def self.normalize_string(string)
|
|
87
|
+
if string
|
|
88
|
+
string = string.strip
|
|
89
|
+
string.empty? ? nil : string
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
end
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module RorVsWild
|
|
4
|
+
module Host
|
|
5
|
+
def self.load_config(config)
|
|
6
|
+
@name = config.dig(:server, :name)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def self.os
|
|
10
|
+
@os_description ||= `uname -sr`.strip
|
|
11
|
+
rescue Exception => ex
|
|
12
|
+
@os_description = RbConfig::CONFIG["host_os"]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def self.user
|
|
16
|
+
Etc.getlogin
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def self.ruby
|
|
20
|
+
RUBY_DESCRIPTION
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def self.rails
|
|
24
|
+
Rails.version if defined?(Rails)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.name
|
|
28
|
+
@name ||= if gae_instance = ENV["GAE_INSTANCE"] || ENV["CLOUD_RUN_EXECUTION"]
|
|
29
|
+
gae_instance
|
|
30
|
+
elsif dyno = ENV["DYNO"] # Heroku
|
|
31
|
+
dyno.start_with?("run.") ? "run.*" :
|
|
32
|
+
dyno.start_with?("release.") ? "release.*" : dyno
|
|
33
|
+
else
|
|
34
|
+
Socket.gethostname
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def self.pid
|
|
39
|
+
Process.pid
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def self.cwd
|
|
43
|
+
Dir.pwd
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def self.revision
|
|
47
|
+
Deployment.revision
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
def self.revision_description
|
|
51
|
+
Deployment.description
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
def self.to_h
|
|
55
|
+
@to_h ||= {os: os, user: user, host: name, ruby: ruby, rails: rails, pid: pid, cwd: cwd, revision: revision}.compact
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
data/lib/rorvswild/installer.rb
CHANGED
|
@@ -4,7 +4,7 @@ module RorVsWild
|
|
|
4
4
|
|
|
5
5
|
def self.create_rails_config(api_key)
|
|
6
6
|
if File.directory?("config")
|
|
7
|
-
if !File.
|
|
7
|
+
if !File.exist?(PATH)
|
|
8
8
|
File.write(PATH, template(api_key))
|
|
9
9
|
puts "File #{PATH} has been created. Restart / deploy your app to start collecting data."
|
|
10
10
|
else
|
|
@@ -19,26 +19,34 @@ module RorVsWild
|
|
|
19
19
|
<<YAML
|
|
20
20
|
production:
|
|
21
21
|
api_key: #{api_key}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
22
|
+
# ignore_requests: # Do not monitor the following actions
|
|
23
|
+
# - SecretController#index
|
|
24
|
+
# ignore_jobs: # Do not monitor the following jobs
|
|
25
|
+
# - SecretJob
|
|
26
|
+
# ignore_exceptions: # Do not record the following exceptions
|
|
27
|
+
# - ActionController::RoutingError # By default to ignore 404
|
|
28
|
+
# ignore_plugins:
|
|
29
|
+
# - ActionController
|
|
30
|
+
# - ActionMailer
|
|
31
|
+
# - ActionView
|
|
32
|
+
# - ActiveJob
|
|
33
|
+
# - ActiveRecord
|
|
34
|
+
# - DelayedJob
|
|
35
|
+
# - Elasticsearch
|
|
36
|
+
# - Mongo
|
|
37
|
+
# - NetHttp
|
|
38
|
+
# - Redis
|
|
39
|
+
# - Resque
|
|
40
|
+
# - Sidekiq
|
|
41
|
+
# logger: log/rorvswild.log # By default it uses Rails.logger or Logger.new(STDOUT)
|
|
42
|
+
# # Deployment tracking is working without any actions from your part if the Rails app
|
|
43
|
+
# # is inside a Git repositoriy, is deployed via Capistrano.
|
|
44
|
+
# # In the other cases, you can provide the following details.
|
|
45
|
+
# deployment:
|
|
46
|
+
# revision: <%= "Anything that will return the deployment version" %> # Mandatory
|
|
47
|
+
# description: <%= "Eventually if you have a description such as a Git message" %>
|
|
48
|
+
# author: <%= "Author's name of the deployment" %>
|
|
49
|
+
# email: <%= "emailOf@theAuthor.com" %>
|
|
42
50
|
YAML
|
|
43
51
|
end
|
|
44
52
|
end
|
|
@@ -77,9 +77,9 @@ RorVsWild.Local.prototype.goToHistory = function(event) {
|
|
|
77
77
|
this.render()
|
|
78
78
|
}
|
|
79
79
|
|
|
80
|
-
RorVsWild.Local.prototype.
|
|
80
|
+
RorVsWild.Local.prototype.containerClass = function() {
|
|
81
81
|
if (!this.active)
|
|
82
|
-
return
|
|
82
|
+
return "is-hidden"
|
|
83
83
|
}
|
|
84
84
|
|
|
85
85
|
RorVsWild.Local.kindToLanguage = function(kind) {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
</div>
|
|
5
5
|
|
|
6
6
|
<script type="x-tmpl-mustache" data-partial="RorVsWild.Local">
|
|
7
|
-
<div id="rorvswild-local-requests" class="rorvswild-local-panel
|
|
7
|
+
<div id="rorvswild-local-requests" class="rorvswild-local-panel {{containerClass}}">
|
|
8
8
|
|
|
9
9
|
<div class="rorvswild-local-panel__header">
|
|
10
10
|
<a href="https://www.rorvswild.com" class="rorvswild-local-panel__logo">
|
|
@@ -1,30 +1,61 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
module RorVsWild
|
|
2
4
|
class Metrics
|
|
3
5
|
class Cpu
|
|
4
6
|
attr_reader :user, :system, :idle, :waiting, :stolen
|
|
5
7
|
attr_reader :load_average, :count
|
|
6
8
|
|
|
9
|
+
def initialize
|
|
10
|
+
@old_stat = Stat.read
|
|
11
|
+
end
|
|
12
|
+
|
|
7
13
|
def update
|
|
8
|
-
if
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
14
|
+
if @old_stat && (new_stat = Stat.read)
|
|
15
|
+
if (total = new_stat.total - @old_stat.total) > 0
|
|
16
|
+
@user = (new_stat.user - @old_stat.user) * 100 / total
|
|
17
|
+
@system = (new_stat.system - @old_stat.system) * 100 / total
|
|
18
|
+
@idle = (new_stat.idle - @old_stat.idle) * 100 / total
|
|
19
|
+
@waiting = (new_stat.iowait - @old_stat.iowait) * 100 / total
|
|
20
|
+
@stolen = (new_stat.steal - @old_stat.steal) * 100 / total
|
|
21
|
+
@old_stat = new_stat
|
|
22
|
+
end
|
|
15
23
|
end
|
|
16
|
-
|
|
17
|
-
|
|
24
|
+
@load_average = File.read("/proc/loadavg").to_f if File.readable?("/proc/loadavg")
|
|
25
|
+
@count = `nproc`.to_i rescue nil
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
class Stat
|
|
29
|
+
attr_reader :user, :nice, :system, :idle, :iowait, :irq, :softirq, :steal, :guest, :guest_nice, :total
|
|
30
|
+
|
|
31
|
+
def initialize(user, nice, system, idle, iowait, irq, softirq, steal, guest, guest_nice)
|
|
32
|
+
@user = user
|
|
33
|
+
@nice = nice
|
|
34
|
+
@system = system
|
|
35
|
+
@idle = idle
|
|
36
|
+
@iowait = iowait
|
|
37
|
+
@irq = irq
|
|
38
|
+
@softirq = softirq
|
|
39
|
+
@steal = steal
|
|
40
|
+
@guest = guest
|
|
41
|
+
@guest_nice = guest_nice
|
|
42
|
+
@total = user + nice + system + idle + iowait + irq + softirq + steal + guest + guest_nice
|
|
18
43
|
end
|
|
19
|
-
|
|
20
|
-
|
|
44
|
+
|
|
45
|
+
def self.parse(string)
|
|
46
|
+
for row in string.lines
|
|
47
|
+
if row.start_with?("cpu ")
|
|
48
|
+
array = row.split[1..-1].map(&:to_i)[0,10]
|
|
49
|
+
array.fill(0, array.size, 10 - array.size) if array.size < 10
|
|
50
|
+
return new(*array)
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
nil
|
|
21
54
|
end
|
|
22
|
-
end
|
|
23
55
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
nil
|
|
56
|
+
def self.read
|
|
57
|
+
parse(File.read("/proc/stat")) if File.readable?("/proc/stat")
|
|
58
|
+
end
|
|
28
59
|
end
|
|
29
60
|
end
|
|
30
61
|
end
|
|
@@ -23,7 +23,7 @@ module RorVsWild
|
|
|
23
23
|
SWAP_FREE = "SwapFree" # Amount of swap space that is currently unused.
|
|
24
24
|
|
|
25
25
|
def update
|
|
26
|
-
info = read_meminfo
|
|
26
|
+
return unless info = read_meminfo
|
|
27
27
|
@ram_total = convert_to_bytes(info[MEM_TOTAL])
|
|
28
28
|
@ram_free = convert_to_bytes(info[MEM_FREE])
|
|
29
29
|
@ram_available = convert_to_bytes(info[MEM_AVAILABLE])
|
data/lib/rorvswild/metrics.rb
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
module RorVsWild
|
|
2
2
|
class Metrics
|
|
3
|
-
UPDATE_INTERVAL_MS = 60_000 # One metric every minute
|
|
4
|
-
|
|
5
3
|
attr_reader :cpu, :memory, :storage, :updated_at
|
|
6
4
|
|
|
7
5
|
def initialize
|
|
@@ -11,22 +9,23 @@ module RorVsWild
|
|
|
11
9
|
end
|
|
12
10
|
|
|
13
11
|
def update
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
storage.update
|
|
18
|
-
@updated_at = RorVsWild.clock_milliseconds
|
|
19
|
-
end
|
|
12
|
+
cpu.update
|
|
13
|
+
memory.update
|
|
14
|
+
storage.update
|
|
20
15
|
end
|
|
21
16
|
|
|
22
|
-
def
|
|
23
|
-
|
|
17
|
+
def update_every_minute
|
|
18
|
+
return unless Host.os.include?("Linux")
|
|
19
|
+
if !@updated_at || @updated_at.min != Time.now.min
|
|
20
|
+
@updated_at = Time.now
|
|
21
|
+
update
|
|
22
|
+
end
|
|
24
23
|
end
|
|
25
24
|
|
|
26
25
|
def to_h
|
|
27
26
|
{
|
|
28
|
-
hostname:
|
|
29
|
-
os:
|
|
27
|
+
hostname: Host.name,
|
|
28
|
+
os: Host.os,
|
|
30
29
|
cpu_user: cpu.user,
|
|
31
30
|
cpu_system: cpu.system,
|
|
32
31
|
cpu_idle: cpu.idle,
|
|
@@ -19,7 +19,7 @@ module RorVsWild
|
|
|
19
19
|
end
|
|
20
20
|
|
|
21
21
|
def request_with_rorvswild(req, body = nil, &block)
|
|
22
|
-
return request_without_rorvswild(req, body, &block) if request_called_twice?
|
|
22
|
+
return request_without_rorvswild(req, body, &block) if !RorVsWild.agent || request_called_twice?
|
|
23
23
|
RorVsWild.agent.measure_section("#{req.method} #{address}", kind: HTTP) do
|
|
24
24
|
request_without_rorvswild(req, body, &block)
|
|
25
25
|
end
|
data/lib/rorvswild/queue.rb
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
module RorVsWild
|
|
2
2
|
class Queue
|
|
3
|
-
SLEEP_TIME =
|
|
3
|
+
SLEEP_TIME = 10
|
|
4
4
|
FLUSH_TRESHOLD = 10
|
|
5
5
|
|
|
6
6
|
attr_reader :mutex, :thread, :client
|
|
@@ -52,7 +52,7 @@ module RorVsWild
|
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def pull_server_metrics
|
|
55
|
-
@metrics && @metrics.
|
|
55
|
+
@metrics && @metrics.update_every_minute && @metrics.to_h
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
def flush_indefinetely
|
data/lib/rorvswild/version.rb
CHANGED
data/lib/rorvswild.rb
CHANGED
metadata
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rorvswild
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.6.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Alexis Bernard
|
|
8
8
|
- Antoine Marguerie
|
|
9
|
-
autorequire:
|
|
9
|
+
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date:
|
|
12
|
+
date: 2023-02-07 00:00:00.000000000 Z
|
|
13
13
|
dependencies: []
|
|
14
14
|
description: Performances and errors insights for rails developers.
|
|
15
15
|
email:
|
|
@@ -27,6 +27,8 @@ files:
|
|
|
27
27
|
- lib/rorvswild.rb
|
|
28
28
|
- lib/rorvswild/agent.rb
|
|
29
29
|
- lib/rorvswild/client.rb
|
|
30
|
+
- lib/rorvswild/deployment.rb
|
|
31
|
+
- lib/rorvswild/host.rb
|
|
30
32
|
- lib/rorvswild/installer.rb
|
|
31
33
|
- lib/rorvswild/local.rb
|
|
32
34
|
- lib/rorvswild/local/javascript/application.js
|
|
@@ -69,7 +71,7 @@ licenses:
|
|
|
69
71
|
metadata:
|
|
70
72
|
source_code_uri: https://github.com/BaseSecrete/rorvswild
|
|
71
73
|
changelog_uri: https://github.com/BaseSecrete/rorvswild/blob/master/CHANGELOG.md
|
|
72
|
-
post_install_message:
|
|
74
|
+
post_install_message:
|
|
73
75
|
rdoc_options: []
|
|
74
76
|
require_paths:
|
|
75
77
|
- lib
|
|
@@ -85,7 +87,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
85
87
|
version: '0'
|
|
86
88
|
requirements: []
|
|
87
89
|
rubygems_version: 3.2.22
|
|
88
|
-
signing_key:
|
|
90
|
+
signing_key:
|
|
89
91
|
specification_version: 4
|
|
90
92
|
summary: Ruby on Rails applications monitoring
|
|
91
93
|
test_files: []
|