server_metrics 1.0.3 → 1.1.0.pre
Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## 1.1.0
|
2
|
+
|
3
|
+
* sys/proctable is no longer a dependency in the gemspec.
|
4
|
+
* Linux systems with the /proc filesystem will return all process metrics
|
5
|
+
* other systems with sys/proctable installed will try to use sys/proctable, wnd will generally return a list of process names and counts (but no memory/cpu)
|
6
|
+
* all other systems: no process info returned
|
7
|
+
|
1
8
|
## 1.0.3
|
2
9
|
|
3
10
|
* Assuming 100 jiffies/second vs. reading from /proc/timer_list
|
@@ -60,15 +60,6 @@ class ServerMetrics::Memory < ServerMetrics::Collector
|
|
60
60
|
report_data[:swap_used_percent] = swap_percent_used
|
61
61
|
end
|
62
62
|
@data = report_data
|
63
|
-
|
64
|
-
rescue Exception => e
|
65
|
-
if e.message =~ /No such file or directory/
|
66
|
-
error('Unable to find /proc/meminfo',%Q(Unable to find /proc/meminfo. Please ensure your operationg system supports procfs:
|
67
|
-
http://en.wikipedia.org/wiki/Procfs)
|
68
|
-
)
|
69
|
-
else
|
70
|
-
raise
|
71
|
-
end
|
72
63
|
end
|
73
64
|
|
74
65
|
# Parses top output. Does not report swap usage.
|
@@ -1,5 +1,9 @@
|
|
1
|
-
|
2
|
-
require '
|
1
|
+
begin
|
2
|
+
require 'sys/proctable'
|
3
|
+
rescue LoadError
|
4
|
+
# we'll use SysLite::ProcTable
|
5
|
+
end
|
6
|
+
require 'server_metrics/lib/proctable_lite'
|
3
7
|
require 'server_metrics/system_info'
|
4
8
|
|
5
9
|
# Collects information on processes. Groups processes running under the same command, and sums up their CPU & memory usage.
|
@@ -11,17 +15,30 @@ require 'server_metrics/system_info'
|
|
11
15
|
#
|
12
16
|
# 2) why are the process CPU numbers lower than [top|htop]? We normalize the CPU usage according to the number of CPUs your server has. Top and htop don't do that. So on a 8 CPU system, you'd expect these numbers to be almost an order of magnitude lower.
|
13
17
|
#
|
14
|
-
#
|
15
18
|
# http://www.linuxquestions.org/questions/linux-general-1/per-process-cpu-utilization-557577/
|
19
|
+
#
|
20
|
+
# SYSTEM COMPATIBILITY NOTES
|
21
|
+
#
|
22
|
+
# * on Linux systems with the /proc filesystem: will return all process metrics
|
23
|
+
# * on other systems with sys/proctable installed: will generally return a process list and counts
|
24
|
+
# * everywhere else: no process info returned
|
25
|
+
#
|
26
|
+
#
|
27
|
+
#
|
16
28
|
class ServerMetrics::Processes
|
17
|
-
# most
|
29
|
+
# most common - used if page size can't be retrieved. units are bytes.
|
18
30
|
DEFAULT_PAGE_SIZE = 4096
|
19
31
|
|
20
32
|
def initialize(options={})
|
21
33
|
@last_run
|
22
34
|
@last_jiffies
|
23
35
|
@last_process_list
|
24
|
-
|
36
|
+
if ServerMetrics::SystemInfo.os =~ /linux/
|
37
|
+
@proc_table_klass = SysLite::ProcTable
|
38
|
+
elsif Object.const_defined?('Sys') && Sys.const_defined?('ProcTable')
|
39
|
+
@proc_table_klass = Sys::ProcTable
|
40
|
+
end
|
41
|
+
|
25
42
|
end
|
26
43
|
|
27
44
|
|
@@ -40,10 +57,14 @@ class ServerMetrics::Processes
|
|
40
57
|
# ....
|
41
58
|
# }
|
42
59
|
# }
|
43
|
-
|
60
|
+
#
|
44
61
|
def run
|
45
|
-
@
|
46
|
-
|
62
|
+
if @proc_table_klass
|
63
|
+
@processes = calculate_processes # returns a hash
|
64
|
+
@processes.keys.inject(@processes) { |processes, key| processes[key][:cmd] = key; processes }
|
65
|
+
else
|
66
|
+
@processes = {}
|
67
|
+
end
|
47
68
|
end
|
48
69
|
|
49
70
|
# called from run(). This method lists all the processes running on the server, groups them by command,
|
data/server_metrics.gemspec
CHANGED
@@ -18,8 +18,6 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency "sys-proctable"
|
22
|
-
|
23
21
|
spec.add_development_dependency "bundler", "~> 1.3"
|
24
22
|
spec.add_development_dependency "rake"
|
25
23
|
spec.add_development_dependency "awesome_print"
|
metadata
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: server_metrics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
5
|
-
prerelease:
|
4
|
+
version: 1.1.0.pre
|
5
|
+
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Andre Lewis
|
@@ -11,24 +11,8 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2014-01-
|
14
|
+
date: 2014-01-16 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
|
-
- !ruby/object:Gem::Dependency
|
17
|
-
name: sys-proctable
|
18
|
-
requirement: !ruby/object:Gem::Requirement
|
19
|
-
none: false
|
20
|
-
requirements:
|
21
|
-
- - ! '>='
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: '0'
|
24
|
-
type: :runtime
|
25
|
-
prerelease: false
|
26
|
-
version_requirements: !ruby/object:Gem::Requirement
|
27
|
-
none: false
|
28
|
-
requirements:
|
29
|
-
- - ! '>='
|
30
|
-
- !ruby/object:Gem::Version
|
31
|
-
version: '0'
|
32
16
|
- !ruby/object:Gem::Dependency
|
33
17
|
name: bundler
|
34
18
|
requirement: !ruby/object:Gem::Requirement
|
@@ -173,12 +157,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
173
157
|
- - ! '>='
|
174
158
|
- !ruby/object:Gem::Version
|
175
159
|
version: '0'
|
160
|
+
segments:
|
161
|
+
- 0
|
162
|
+
hash: 926714783005878761
|
176
163
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
164
|
none: false
|
178
165
|
requirements:
|
179
|
-
- - ! '
|
166
|
+
- - ! '>'
|
180
167
|
- !ruby/object:Gem::Version
|
181
|
-
version:
|
168
|
+
version: 1.3.1
|
182
169
|
requirements: []
|
183
170
|
rubyforge_project:
|
184
171
|
rubygems_version: 1.8.23
|
@@ -194,4 +181,3 @@ test_files:
|
|
194
181
|
- test/test_basics.rb
|
195
182
|
- test/test_helper.rb
|
196
183
|
- test/test_with_fixtures.rb
|
197
|
-
has_rdoc:
|