server_metrics 1.2.7 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/lib/server_metrics.rb +1 -0
- data/lib/server_metrics/backward_compatibility_patch.rb +17 -0
- data/lib/server_metrics/collectors/disk.rb +1 -1
- data/lib/server_metrics/version.rb +1 -1
- data/test/test_helper.rb +5 -1
- data/test/test_with_fixtures.rb +6 -6
- metadata +20 -19
checksums.yaml
CHANGED
@@ -1,15 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
data.tar.gz: !binary |-
|
6
|
-
OTA2NDQzYWFkYmJmMjY5MTIxY2QxYTkyYzA4ODIwNjU3OTUwYmY4Nw==
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a4040b1194f4904d529f0b9325e5770d33ca7364
|
4
|
+
data.tar.gz: 2cd897acaa0dbde2e0a44e4a3d83fa3263b8720c
|
7
5
|
SHA512:
|
8
|
-
metadata.gz:
|
9
|
-
|
10
|
-
Mjc0ZDk4OWU4YTYxZmM0OTIwOTQyYzY4YmY3MDA2OGIwYjI1MGEwMmJmNDgw
|
11
|
-
NmI4MzEzNjRjN2IxMTQ1ZmIxOTk4ZjYxMGJhNzYyM2Q2YmVhMGQ=
|
12
|
-
data.tar.gz: !binary |-
|
13
|
-
NmU4NTliMTFlNTQ0ODY0YzA1YzIyOWMyZDc0ZDA5ZTI0Njc3Yzk0NTU3YTlk
|
14
|
-
YjE5ZWJlMDE3NTE0YTYwNDgyN2QyZWRmZWQxNDBmNGE0ODY1MWQwNWJhYTRi
|
15
|
-
MjRiZmViMDk0YTNlOWU1NjhiNzkwZGZlNGM5YmQ4NzRkMDUyZjE=
|
6
|
+
metadata.gz: 18a1aaf212424d1d3801b7d1519980aacad35b9b84cbda28774638c70cb93fbf6db786e0222ef0c7366a4556cabd413067a166a92ac4feeada4f181a20b60ab0
|
7
|
+
data.tar.gz: b55d1b3a853393b13c86a817a38e33d2587f659733613f5b31abd4fd518f08c5977b3a1406a7e00aa5d672bf99d857cd04c9a0f9878f44936505499055387d03
|
data/lib/server_metrics.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
# Ruby 1.8.6 compatibility
|
2
|
+
if !String.method_defined?(:lines)
|
3
|
+
class String
|
4
|
+
def lines
|
5
|
+
to_a
|
6
|
+
end
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
# Ruby 1.8.6 compatibility
|
11
|
+
if !String.method_defined?(:start_with?)
|
12
|
+
class String
|
13
|
+
def start_with?(matcher)
|
14
|
+
!!match(/\A#{matcher}/)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -44,7 +44,7 @@ class ServerMetrics::Disk < ServerMetrics::MultiCollector
|
|
44
44
|
|
45
45
|
df_output[1..df_output.size-1].each do |line|
|
46
46
|
values=line.split(/\s+/,6)
|
47
|
-
parsed_lines<<Hash[headers.zip(values)]
|
47
|
+
parsed_lines<<Hash[*headers.zip(values).flatten]
|
48
48
|
end
|
49
49
|
|
50
50
|
# select the right line
|
data/test/test_helper.rb
CHANGED
@@ -1,6 +1,10 @@
|
|
1
1
|
$LOAD_PATH << File.expand_path( File.dirname(__FILE__) + '/../lib' ) # needed because when running tests, Rubygems manage $LOAD_PATH like it does in runtime
|
2
2
|
require 'rubygems' # so the development-only dependencies below can be loaded
|
3
|
-
|
3
|
+
begin
|
4
|
+
require 'pry'
|
5
|
+
rescue LoadError
|
6
|
+
# not using pry
|
7
|
+
end
|
4
8
|
require 'awesome_print'
|
5
9
|
require 'timecop'
|
6
10
|
require 'test/unit'
|
data/test/test_with_fixtures.rb
CHANGED
@@ -6,7 +6,7 @@ class TestWithFixtures < Test::Unit::TestCase
|
|
6
6
|
fixture = fixtures(:cpu)
|
7
7
|
c = ServerMetrics::Cpu.new()
|
8
8
|
|
9
|
-
|
9
|
+
File.expects(:read).with("/proc/stat").returns(fixture.command("cat /proc/stat 2>&1")).once
|
10
10
|
c.expects(:`).with("uptime").returns(fixture.command("uptime")).once
|
11
11
|
|
12
12
|
c.run
|
@@ -39,7 +39,7 @@ class TestWithFixtures < Test::Unit::TestCase
|
|
39
39
|
fixture = fixtures(:disk)
|
40
40
|
c.expects(:`).with("mount").returns(fixture.command("mount")).once
|
41
41
|
c.expects(:`).with("df -Pkh").returns(fixture.command("df -Pkh")).once
|
42
|
-
|
42
|
+
File.expects(:readlines).with("/proc/diskstats").returns(fixture.command("cat /proc/diskstats")).once
|
43
43
|
c.run
|
44
44
|
|
45
45
|
assert_equal ["/dev/xvda1"], c.data.keys
|
@@ -98,7 +98,7 @@ eos
|
|
98
98
|
fixture = fixtures(:disk)
|
99
99
|
c.expects(:`).with("mount").returns(fixture.command("mount")).once
|
100
100
|
c.expects(:`).with("df -Pkh").returns(fixture.command("df -Pkh")).once
|
101
|
-
|
101
|
+
File.expects(:readlines).with("/proc/diskstats").returns(fixture.command("cat /proc/diskstats", "ubuntu second run")).once
|
102
102
|
|
103
103
|
Timecop.travel(60) do
|
104
104
|
c.run
|
@@ -116,7 +116,7 @@ eos
|
|
116
116
|
fixture = fixtures(:memory)
|
117
117
|
c = ServerMetrics::Memory.new()
|
118
118
|
c.expects(:`).with("uname").returns("Linux").times(2)
|
119
|
-
|
119
|
+
File.expects(:read).with("/proc/meminfo").returns(fixture.command("cat /proc/meminfo")).once
|
120
120
|
c.run
|
121
121
|
assert_equal 7, c.data.keys.size
|
122
122
|
# the field names should align with the disk field names
|
@@ -133,10 +133,10 @@ eos
|
|
133
133
|
ServerMetrics::Network.any_instance.stubs("linux?").returns(true)
|
134
134
|
fixture = fixtures(:network)
|
135
135
|
c = ServerMetrics::Network.new()
|
136
|
-
|
136
|
+
File.expects(:read).with("/proc/net/dev").returns(fixture.command("cat /proc/net/dev")).once
|
137
137
|
c.run
|
138
138
|
|
139
|
-
|
139
|
+
File.expects(:read).with("/proc/net/dev").returns(fixture.command("cat /proc/net/dev", "second run")).once
|
140
140
|
Timecop.travel(60) do
|
141
141
|
c.run
|
142
142
|
end
|
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.
|
4
|
+
version: 1.2.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andre Lewis
|
@@ -10,104 +10,104 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-12-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
17
17
|
requirement: !ruby/object:Gem::Requirement
|
18
18
|
requirements:
|
19
|
-
- - ~>
|
19
|
+
- - "~>"
|
20
20
|
- !ruby/object:Gem::Version
|
21
21
|
version: '1.3'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
requirements:
|
26
|
-
- - ~>
|
26
|
+
- - "~>"
|
27
27
|
- !ruby/object:Gem::Version
|
28
28
|
version: '1.3'
|
29
29
|
- !ruby/object:Gem::Dependency
|
30
30
|
name: rake
|
31
31
|
requirement: !ruby/object:Gem::Requirement
|
32
32
|
requirements:
|
33
|
-
- -
|
33
|
+
- - ">="
|
34
34
|
- !ruby/object:Gem::Version
|
35
35
|
version: '0'
|
36
36
|
type: :development
|
37
37
|
prerelease: false
|
38
38
|
version_requirements: !ruby/object:Gem::Requirement
|
39
39
|
requirements:
|
40
|
-
- -
|
40
|
+
- - ">="
|
41
41
|
- !ruby/object:Gem::Version
|
42
42
|
version: '0'
|
43
43
|
- !ruby/object:Gem::Dependency
|
44
44
|
name: awesome_print
|
45
45
|
requirement: !ruby/object:Gem::Requirement
|
46
46
|
requirements:
|
47
|
-
- -
|
47
|
+
- - ">="
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '0'
|
50
50
|
type: :development
|
51
51
|
prerelease: false
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
53
53
|
requirements:
|
54
|
-
- -
|
54
|
+
- - ">="
|
55
55
|
- !ruby/object:Gem::Version
|
56
56
|
version: '0'
|
57
57
|
- !ruby/object:Gem::Dependency
|
58
58
|
name: pry
|
59
59
|
requirement: !ruby/object:Gem::Requirement
|
60
60
|
requirements:
|
61
|
-
- -
|
61
|
+
- - ">="
|
62
62
|
- !ruby/object:Gem::Version
|
63
63
|
version: '0'
|
64
64
|
type: :development
|
65
65
|
prerelease: false
|
66
66
|
version_requirements: !ruby/object:Gem::Requirement
|
67
67
|
requirements:
|
68
|
-
- -
|
68
|
+
- - ">="
|
69
69
|
- !ruby/object:Gem::Version
|
70
70
|
version: '0'
|
71
71
|
- !ruby/object:Gem::Dependency
|
72
72
|
name: timecop
|
73
73
|
requirement: !ruby/object:Gem::Requirement
|
74
74
|
requirements:
|
75
|
-
- -
|
75
|
+
- - ">="
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
type: :development
|
79
79
|
prerelease: false
|
80
80
|
version_requirements: !ruby/object:Gem::Requirement
|
81
81
|
requirements:
|
82
|
-
- -
|
82
|
+
- - ">="
|
83
83
|
- !ruby/object:Gem::Version
|
84
84
|
version: '0'
|
85
85
|
- !ruby/object:Gem::Dependency
|
86
86
|
name: mocha
|
87
87
|
requirement: !ruby/object:Gem::Requirement
|
88
88
|
requirements:
|
89
|
-
- -
|
89
|
+
- - ">="
|
90
90
|
- !ruby/object:Gem::Version
|
91
91
|
version: '0'
|
92
92
|
type: :development
|
93
93
|
prerelease: false
|
94
94
|
version_requirements: !ruby/object:Gem::Requirement
|
95
95
|
requirements:
|
96
|
-
- -
|
96
|
+
- - ">="
|
97
97
|
- !ruby/object:Gem::Version
|
98
98
|
version: '0'
|
99
99
|
- !ruby/object:Gem::Dependency
|
100
100
|
name: rspec
|
101
101
|
requirement: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- - ~>
|
103
|
+
- - "~>"
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '2.14'
|
106
106
|
type: :development
|
107
107
|
prerelease: false
|
108
108
|
version_requirements: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
|
-
- - ~>
|
110
|
+
- - "~>"
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '2.14'
|
113
113
|
description: Collect information about disks, memory, CPU, networks, and processes
|
@@ -117,7 +117,7 @@ executables: []
|
|
117
117
|
extensions: []
|
118
118
|
extra_rdoc_files: []
|
119
119
|
files:
|
120
|
-
- .gitignore
|
120
|
+
- ".gitignore"
|
121
121
|
- CHANGELOG.md
|
122
122
|
- Gemfile
|
123
123
|
- LICENSE.txt
|
@@ -126,6 +126,7 @@ files:
|
|
126
126
|
- examples/example_processes.rb
|
127
127
|
- examples/example_usage.rb
|
128
128
|
- lib/server_metrics.rb
|
129
|
+
- lib/server_metrics/backward_compatibility_patch.rb
|
129
130
|
- lib/server_metrics/collector.rb
|
130
131
|
- lib/server_metrics/collectors/cpu.rb
|
131
132
|
- lib/server_metrics/collectors/disk.rb
|
@@ -159,12 +160,12 @@ require_paths:
|
|
159
160
|
- lib
|
160
161
|
required_ruby_version: !ruby/object:Gem::Requirement
|
161
162
|
requirements:
|
162
|
-
- -
|
163
|
+
- - ">="
|
163
164
|
- !ruby/object:Gem::Version
|
164
165
|
version: '0'
|
165
166
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
166
167
|
requirements:
|
167
|
-
- -
|
168
|
+
- - ">="
|
168
169
|
- !ruby/object:Gem::Version
|
169
170
|
version: '0'
|
170
171
|
requirements: []
|