instrumental_tools 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -10,8 +10,6 @@ Use to collect various monitoring statistics of a server. Execute with:
10
10
  instrument_server -k <INSTRUMENTAL_API_KEY>
11
11
  ```
12
12
 
13
- Linux note: Install iostat (part of the sysstat package) in order to collect disk I/O metrics.
14
-
15
13
  Mac OS note: Due to a bug in Ruby, instrument_server can occasionally deadlock ([bug report](http://bugs.ruby-lang.org/issues/5811)).
16
14
 
17
15
  ## instrumental
@@ -208,7 +208,7 @@ class SystemInspector
208
208
  end
209
209
 
210
210
  def self.load_disks
211
- { :gauges => disks.merge(iostat) }
211
+ { :gauges => disks.merge(diskstats) }
212
212
  end
213
213
 
214
214
  def self.disks
@@ -227,16 +227,26 @@ class SystemInspector
227
227
  output
228
228
  end
229
229
 
230
- def self.iostat
230
+ def self.diskstats
231
+ entries = `cat /proc/diskstats`.chomp.split("\n").map do |line|
232
+ values = line.split
233
+ entry = {}
234
+ entry[:time] = Time.now
235
+ entry[:device] = values[2]
236
+ entry[:read] = values[6].to_f
237
+ entry[:write] = values[10].to_f
238
+ entry[:io] = entry[:read] + entry[:write]
239
+ SystemInspector.memory.store("disk_stats_#{entry[:device]}".to_sym, entry)
240
+ end
241
+
231
242
  output = {}
232
- if system('iostat > /dev/null 2>&1')
233
- lines = `iostat -dx`.split("\n")
234
- header = lines.grep(/^Device/i).first
235
- dev_lines = lines[(lines.index(header) + 1)..-1]
236
- util_index = header.split.index('%util')
237
- dev_lines.each do |dev_line|
238
- values = dev_line.split
239
- output["disk.#{values[0]}.percent_utilization"] = values[util_index].to_f
243
+ entries.each do |entry|
244
+ if previous_entry = SystemInspector.memory.retrieve("disk_stats_#{entry[:device]}".to_sym)
245
+ time_delta = (entry[:time] - previous_entry[:time]) * 1000
246
+ [:read, :write, :io].each do |type|
247
+ utilization_delta = entry[type] - previous_entry[type]
248
+ output["disk.#{entry[:device]}.#{type}_utilization"] = utilization_delta / time_delta * 100
249
+ end
240
250
  end
241
251
  end
242
252
  output
@@ -327,12 +337,6 @@ class ServerController < Pidly::Control
327
337
  alias_method :clean, :clean!
328
338
  end
329
339
 
330
- def terminal_messages
331
- if `which iostat`.chomp.empty?
332
- puts 'Install iostat (sysstat package) to collect disk I/O metrics.'
333
- end
334
- end
335
-
336
340
  def require_api_key(options, parser)
337
341
  unless options[:api_key] # present?
338
342
  print parser.help
@@ -365,7 +369,6 @@ option_parser = OptionParser.new do |opts|
365
369
  end
366
370
  opts.on('-h', '--help', 'Display this screen') do
367
371
  puts opts
368
- terminal_messages
369
372
  exit
370
373
  end
371
374
  end
@@ -1,5 +1,5 @@
1
1
  module Instrumental
2
2
  module Tools
3
- VERSION = "0.3.1"
3
+ VERSION = "0.3.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: instrumental_tools
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 1
10
- version: 0.3.1
9
+ - 2
10
+ version: 0.3.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Elijah Miller
@@ -21,7 +21,8 @@ cert_chain: []
21
21
  date: 2012-01-11 00:00:00 Z
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
24
- type: :runtime
24
+ name: json
25
+ prerelease: false
25
26
  requirement: &id001 !ruby/object:Gem::Requirement
26
27
  none: false
27
28
  requirements:
@@ -31,11 +32,11 @@ dependencies:
31
32
  segments:
32
33
  - 0
33
34
  version: "0"
34
- name: json
35
+ type: :runtime
35
36
  version_requirements: *id001
36
- prerelease: false
37
37
  - !ruby/object:Gem::Dependency
38
- type: :runtime
38
+ name: instrumental_agent
39
+ prerelease: false
39
40
  requirement: &id002 !ruby/object:Gem::Requirement
40
41
  none: false
41
42
  requirements:
@@ -46,11 +47,11 @@ dependencies:
46
47
  - 0
47
48
  - 5
48
49
  version: "0.5"
49
- name: instrumental_agent
50
+ type: :runtime
50
51
  version_requirements: *id002
51
- prerelease: false
52
52
  - !ruby/object:Gem::Dependency
53
- type: :runtime
53
+ name: pidly
54
+ prerelease: false
54
55
  requirement: &id003 !ruby/object:Gem::Requirement
55
56
  none: false
56
57
  requirements:
@@ -62,11 +63,11 @@ dependencies:
62
63
  - 1
63
64
  - 3
64
65
  version: 0.1.3
65
- name: pidly
66
+ type: :runtime
66
67
  version_requirements: *id003
67
- prerelease: false
68
68
  - !ruby/object:Gem::Dependency
69
- type: :development
69
+ name: rake
70
+ prerelease: false
70
71
  requirement: &id004 !ruby/object:Gem::Requirement
71
72
  none: false
72
73
  requirements:
@@ -76,9 +77,8 @@ dependencies:
76
77
  segments:
77
78
  - 0
78
79
  version: "0"
79
- name: rake
80
+ type: :development
80
81
  version_requirements: *id004
81
- prerelease: false
82
82
  description: Tools for displaying information from and reporting to Instrumental (instrumentalapp.com)
83
83
  email:
84
84
  - support@instrumentalapp.com