server_metrics 0.0.8.2 → 0.0.8.3
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.
data/CHANGELOG.md
ADDED
File without changes
|
File without changes
|
@@ -54,7 +54,7 @@ class ServerMetrics::Processes
|
|
54
54
|
def calculate_processes
|
55
55
|
num_processors = ServerMetrics::SystemInfo.num_processors
|
56
56
|
## 1. get a list of all processes
|
57
|
-
processes = Sys::ProcTable.ps.map{|p| ServerMetrics::Processes::Process.new(p) } # our Process object adds a method
|
57
|
+
processes = Sys::ProcTable.ps.map{|p| ServerMetrics::Processes::Process.new(p) } # our Process object adds a method some behavior
|
58
58
|
|
59
59
|
## 2. loop through each process and calculate the CPU time.
|
60
60
|
# The CPU values returned by ProcTable are cumulative for the life of the process, which is not what we want.
|
@@ -117,8 +117,14 @@ class ServerMetrics::Processes
|
|
117
117
|
# Relies on the /proc directory (/proc/timer_list). We need this because the process CPU utilization is measured in jiffies.
|
118
118
|
# In order to calculate the process' % usage of total CPU resources, we need to know how many jiffies have passed.
|
119
119
|
# Unfortunately, jiffies isn't a fixed value (it can vary between 100 and 250 per second), so we need to calculate it ourselves.
|
120
|
+
#
|
121
|
+
# if /proc/timer_list isn't available, fall back to the assumption of 100 jiffies/second (10 milliseconds/jiffy)
|
120
122
|
def get_jiffies
|
121
|
-
|
123
|
+
if File.exist?('/proc/timer_list')
|
124
|
+
`cat /proc/timer_list`.match(/^jiffies: (\d+)$/)[1].to_i
|
125
|
+
else
|
126
|
+
(Time.now.to_f*100).to_i
|
127
|
+
end
|
122
128
|
end
|
123
129
|
|
124
130
|
# for persisting to a file -- conforms to same basic API as the Collectors do.
|
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: 0.0.8.
|
4
|
+
version: 0.0.8.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-
|
12
|
+
date: 2013-12-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: sys-proctable
|
@@ -131,12 +131,13 @@ extensions: []
|
|
131
131
|
extra_rdoc_files: []
|
132
132
|
files:
|
133
133
|
- .gitignore
|
134
|
+
- CHANGELOG.md
|
134
135
|
- Gemfile
|
135
136
|
- LICENSE.txt
|
136
137
|
- README.md
|
137
138
|
- Rakefile
|
138
|
-
- example_processes.rb
|
139
|
-
- example_usage.rb
|
139
|
+
- examples/example_processes.rb
|
140
|
+
- examples/example_usage.rb
|
140
141
|
- lib/server_metrics.rb
|
141
142
|
- lib/server_metrics/collector.rb
|
142
143
|
- lib/server_metrics/collectors/cpu.rb
|
@@ -171,7 +172,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
171
172
|
version: '0'
|
172
173
|
segments:
|
173
174
|
- 0
|
174
|
-
hash:
|
175
|
+
hash: 3865381402127672943
|
175
176
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
176
177
|
none: false
|
177
178
|
requirements:
|
@@ -180,7 +181,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
181
|
version: '0'
|
181
182
|
segments:
|
182
183
|
- 0
|
183
|
-
hash:
|
184
|
+
hash: 3865381402127672943
|
184
185
|
requirements: []
|
185
186
|
rubyforge_project:
|
186
187
|
rubygems_version: 1.8.25
|