server_metrics 1.2.14 → 1.2.18

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d0866cb360c322dd639f687db9331f027d287155
4
- data.tar.gz: 72ef85ce24454c67f178237ae5b4a1631183f429
3
+ metadata.gz: 79ef80a2159b7e4572c1d95ccfe02ea9e356eb08
4
+ data.tar.gz: 88e3b4bbe5c1a2bbb5b3824f4b85de04e3382ade
5
5
  SHA512:
6
- metadata.gz: 036fb66268f2f4475e02c16ae4ad29c62e12e0714c1b0692e712b661622bea293b645478e0c4b88afd617c9ab5a3b5194e1068b09ba4e81159b83ec38837919c
7
- data.tar.gz: fbaa6810e494021f4fdfaf7cca0e058518aa896cbdfb72139a04d3f7821c50ba68d6ab17e06cfe413558cff896efd93e5774d1e166d6623c96a80cf03f6cef64
6
+ metadata.gz: 7b128f526ac97d986c8d8f13236ca19ede9a9585a9dd17d7916050cb05eb52623a7edd710e02081d0ff6ae1bd080f33d323ac574662a10cb29a0454a1dab0ea8
7
+ data.tar.gz: 4a6f352c28598a98c01b59e860a3623fcfc2fffa39f05f90feaf752ca293c467582531db9d4d4d4228e4fa701042d9a4df1f6883388d9db5333a187cec0c66cb
@@ -1,3 +1,15 @@
1
+ # 1.2.17
2
+
3
+ * Fixed collector sort block older Rubies compatibility
4
+
5
+ # 1.2.16
6
+
7
+ * ignoring disc devices via regexp
8
+
9
+ # 1.2.15
10
+
11
+ * Update gemspec
12
+
1
13
  # 1.2.14
2
14
 
3
15
  * Disk symlink alias uses full path
@@ -64,7 +76,7 @@
64
76
  Performance related:
65
77
 
66
78
  * Using `Dir#glob` vs. `Dir#foreach`
67
- * Using `File#read` vs. `cat FILE`.
79
+ * Using `File#read` vs. `cat FILE`.
68
80
  * Removing commented out and unused elements from `SysLite::ProcTable`
69
81
  * Removed method_missing logic in `Processes::Process` to access the `ProcTableStruct`
70
82
  * `Disk` added caching logic via a `@option[:ttl]` to execute slow system calls at a lower interval (ex: ev 60 seconds)
@@ -100,7 +112,7 @@ Performance related:
100
112
 
101
113
  ## 0.0.9.0
102
114
 
103
- * Reporting process memory in MB, not in page size.
115
+ * Reporting process memory in MB, not in page size.
104
116
  * When determining process cpu usage, caching number of processors.
105
117
 
106
118
  ## 0.0.8.9
@@ -20,7 +20,7 @@ module ServerMetrics
20
20
  @options = options
21
21
  @data={}
22
22
  @memory={}
23
- @collector_id = self.class.name+'-'+@options.to_a.sort_by { |a| a.first }.flatten.join('-')
23
+ @collector_id = self.class.name+'-'+@options.to_a.sort_by { |a| a.first.to_s }.flatten.join('-')
24
24
  @error=nil
25
25
  end
26
26
 
@@ -11,14 +11,14 @@ class ServerMetrics::Disk < ServerMetrics::MultiCollector
11
11
  # forcing English for parsing
12
12
  ENV['LC_ALL'] = 'C'
13
13
  ENV['LANG'] = 'C'
14
-
14
+
15
15
  devices.each do |device|
16
16
  get_sizes(device) # does its own reporting
17
17
  get_io_stats(device[:name]) if linux? # does its own reporting
18
18
  end
19
19
  end
20
-
21
- # System calls are slow. Read once every minute and not on every innvocation.
20
+
21
+ # System calls are slow. Read once every minute and not on every innvocation.
22
22
  def df_output
23
23
  if @last_df_output.nil? or @last_df_output < (Time.now-@options[:ttl].to_i*60)
24
24
  @last_df_output = Time.now
@@ -27,14 +27,19 @@ class ServerMetrics::Disk < ServerMetrics::MultiCollector
27
27
  @df_output
28
28
  end
29
29
  end
30
-
31
- # System calls are slow. Read once every minute and not on every innvocation.
30
+
31
+ # System calls are slow. Read once every minute and not on every innvocation.
32
32
  def devices
33
33
  if @devices.nil? or @last_devices_output < (Time.now-@options[:ttl].to_i*60)
34
34
  @last_devices_output = Time.now
35
35
  # if running inside a docker container, we want the devices mounted on the host
36
36
  mount_output = dockerized_agent? ? `cat /host/etc/mtab` : `mount`
37
- @devices = mount_output.split("\n").grep(/^\/dev/).map{|l| {:name => l.split.first, :aliases => []}} # any device that starts with /dev
37
+ # @devices = mount_output.split("\n").grep(/^\/dev/).map{|l| {:name => l.split.first, :aliases => []}} # any device that starts with /dev
38
+ @unfiltered_devices = mount_output.split("\n").grep(/^\/dev/).reject do |e|
39
+ regex = Regexp.new(@options[:ignored_devices]) rescue next
40
+ !!e.match(regex)
41
+ end # any device that starts with /dev
42
+ @devices = @unfiltered_devices.map{|l| {:name => l.split.first, :aliases => [], :mounted_on => l.split[2]}}
38
43
  if dockerized_agent?
39
44
  `blkid`.split("\n").grep(/ UUID=/).each do |device|
40
45
  name = device.match(/\A[^\:]*/)[0]
@@ -58,21 +63,23 @@ class ServerMetrics::Disk < ServerMetrics::MultiCollector
58
63
  # called from build_report for each device
59
64
  def get_sizes(device)
60
65
  header_line=df_output.first
61
- headers = header_line.split(/\s+/,6) # limit to 6 columns - last column is "mounted on"
62
- parsed_lines=[] # Each line will look like {"%iused" => "38%","Avail" => "289Gi", "Capacity=> "38%", "Filesystem"=> "/dev/disk0s2","Mounted => "/", "Size" => "465Gi", "Used" => "176Gi", "ifree" => "75812051", "iused" => "46116178"}
66
+ headers = header_line.split(/\s+/,6).map(&:chomp) # limit to 6 columns - last column is "mounted on"
67
+ parsed_lines=[] # Each line will look like {"%iused" => "38%","Avail" => "289Gi", "Capacity=> "38%", "Filesystem"=> "/dev/disk0s2","Mounted on"=> "/", "Size" => "465Gi", "Used" => "176Gi", "ifree" => "75812051", "iused" => "46116178"}
63
68
 
64
69
  df_output[1..df_output.size-1].each do |line|
65
- values=line.split(/\s+/,6)
66
- parsed_lines<<Hash[*headers.zip(values).flatten]
70
+ values=line.split(/\s+/,6).map(&:chomp)
71
+ parsed_lines << Hash[*headers.zip(values).flatten]
67
72
  end
68
73
 
69
74
  # select the right line
70
75
  hash = parsed_lines.find {|l| l["Filesystem"] == device[:name]}
71
76
  # device wasn't found. check device aliases
72
77
  if hash.nil?
73
- hash = parsed_lines.find {|l| device[:aliases].include?(l["Filesystem"])}
78
+ hash = parsed_lines.find do |l|
79
+ device[:aliases].include?(l["Filesystem"]) || device[:mounted_on] == l["Mounted on"]
80
+ end
74
81
  end
75
- # device wasn't found. could be a mapped device. skip over.
82
+ # device wasn't found. could be a mapped device. skip over.
76
83
  return if hash.nil?
77
84
  result = {}
78
85
  hash.each_pair do |key,value|
@@ -1,3 +1,3 @@
1
1
  module ServerMetrics
2
- VERSION = '1.2.14'
2
+ VERSION = '1.2.18'
3
3
  end
@@ -7,10 +7,10 @@ Gem::Specification.new do |spec|
7
7
  spec.name = "server_metrics"
8
8
  spec.version = ServerMetrics::VERSION
9
9
  spec.authors = ["Andre Lewis", "Derek Haynes", "Matt Rose"]
10
- spec.email = ["support@scoutapp.com"]
10
+ spec.email = ["support.server@pingdom.com"]
11
11
  spec.description = %q{Collect information about disks, memory, CPU, networks, and processes}
12
12
  spec.summary = %q{Used by the Scout agent, but also available as a stand-lone gem}
13
- spec.homepage = "http://scoutapp.com"
13
+ spec.homepage = "http://server.pingdom.com"
14
14
  spec.license = "MIT"
15
15
 
16
16
  spec.files = `git ls-files`.split($/)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: server_metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.14
4
+ version: 1.2.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andre Lewis
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2016-06-07 00:00:00.000000000 Z
13
+ date: 2018-03-05 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -112,7 +112,7 @@ dependencies:
112
112
  version: '2.14'
113
113
  description: Collect information about disks, memory, CPU, networks, and processes
114
114
  email:
115
- - support@scoutapp.com
115
+ - support.server@pingdom.com
116
116
  executables: []
117
117
  extensions: []
118
118
  extra_rdoc_files: []
@@ -150,7 +150,7 @@ files:
150
150
  - test/test_basics.rb
151
151
  - test/test_helper.rb
152
152
  - test/test_with_fixtures.rb
153
- homepage: http://scoutapp.com
153
+ homepage: http://server.pingdom.com
154
154
  licenses:
155
155
  - MIT
156
156
  metadata: {}