process-metrics 0.12.0 → 0.13.0
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.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/context/getting-started.md +24 -1
- data/lib/process/metrics/general/linux.rb +6 -1
- data/lib/process/metrics/general/process_status.rb +1 -1
- data/lib/process/metrics/general.rb +1 -0
- data/lib/process/metrics/processor.rb +1 -1
- data/lib/process/metrics/version.rb +1 -1
- data/readme.md +4 -4
- data/releases.md +4 -0
- data.tar.gz.sig +2 -1
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2822c0b3ad1a6e79d294cc8607359b1a8042818a8b07306c5685064addd4b7fd
|
|
4
|
+
data.tar.gz: f945a7b3bcf467f696c9823a11ecefa996aae3f7e9d075bcfcd6bba87edd13d1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5869ec2e258caad4625fc45f9ee572ebbf9803592f0b8ed1115e80a5f21ad7b36acc3122c9d17aa5c8816c33d76bc4393c3d6620f2ec15f44e065701168ee952
|
|
7
|
+
data.tar.gz: 7b0a434ceba0c1b0d89297825a5bde80999542e10060e5aa89bafc34e44529e75323ad5de3b3ad792e7bdaee87856e64111ba209026e597203eeed8c6ca3aad9
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/context/getting-started.md
CHANGED
|
@@ -21,6 +21,7 @@ $ gem install process-metrics
|
|
|
21
21
|
The `process-metrics` gem provides a simple interface to collect and analyze process metrics.
|
|
22
22
|
|
|
23
23
|
- {ruby Process::Metrics::General} is the main entry point for process metrics. Use {ruby Process::Metrics::General.capture} to collect metrics for one or more processes.
|
|
24
|
+
- {ruby Process::Metrics::Processor} measures processor utilization over intervals between samples.
|
|
24
25
|
- {ruby Process::Metrics::Memory} provides additional methods for collecting memory metrics when the host operating system provides the necessary information.
|
|
25
26
|
|
|
26
27
|
## Usage
|
|
@@ -67,7 +68,7 @@ The {ruby Process::Metrics::General} struct contains the following fields:
|
|
|
67
68
|
- `process_id` - Process ID, a unique identifier for the process.
|
|
68
69
|
- `parent_process_id` - Parent Process ID, the process ID of the process that started this process.
|
|
69
70
|
- `process_group_id` - Process Group ID, the process group ID of the process, which can be shared by multiple processes.
|
|
70
|
-
- `processor_utilization` -
|
|
71
|
+
- `processor_utilization` - Average processor utilization in core units over the system's observation period. `1.0` represents one fully occupied CPU core, and multi-threaded processes can exceed `1.0`.
|
|
71
72
|
- `total_size` - Memory Size (bytes), the total size of the process's memory space (usually over-estimated as it doesn't take into account shared memory).
|
|
72
73
|
- `resident_size` - Resident (Set) Size (bytes), the amount of physical memory used by the process.
|
|
73
74
|
- `processor_time` - CPU Time (s), the amount of CPU time used by the process.
|
|
@@ -89,3 +90,25 @@ The {ruby Process::Metrics::Memory} struct contains the following fields:
|
|
|
89
90
|
- `proportional_swap_size` - Proportional Swap Memory Size (bytes), the amount of memory that has been swapped to disk, excluding shared memory.
|
|
90
91
|
|
|
91
92
|
In general, the interpretation of these fields is operating system specific. At best, they provide a rough estimate of the process's memory usage, but you should consult the documentation for your operating system for more details on exactly what each field represents.
|
|
93
|
+
|
|
94
|
+
## Interval Processor Utilization
|
|
95
|
+
|
|
96
|
+
The processor utilization reported by {ruby Process::Metrics::General} is a snapshot based on the operating system's observation period. Use {ruby Process::Metrics::Processor} when you need utilization over a specific sampling interval:
|
|
97
|
+
|
|
98
|
+
``` ruby
|
|
99
|
+
processor = Process::Metrics::Processor.new
|
|
100
|
+
|
|
101
|
+
# The first sample establishes a baseline:
|
|
102
|
+
processor.sample(Process.pid)
|
|
103
|
+
|
|
104
|
+
sleep(10)
|
|
105
|
+
sample = processor.sample(Process.pid).fetch(Process.pid)
|
|
106
|
+
|
|
107
|
+
sample.duration
|
|
108
|
+
# => approximately 10.0
|
|
109
|
+
|
|
110
|
+
sample.utilization
|
|
111
|
+
# => 1.0 means one fully occupied CPU core during the interval
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
Both interfaces use the same core-unit scale. A utilization of `0.5` means half of one core on average, while `2.0` means two cores were fully occupied. Utilization is therefore not limited to the range `0.0..1.0`.
|
|
@@ -73,6 +73,11 @@ module Process
|
|
|
73
73
|
end
|
|
74
74
|
processor_time = (utime + stime).to_f / CLK_TCK
|
|
75
75
|
elapsed_time = [(uptime_jiffies - start_time).to_f / CLK_TCK, 0.0].max
|
|
76
|
+
processor_utilization = if elapsed_time > 0.0
|
|
77
|
+
processor_time.fdiv(elapsed_time)
|
|
78
|
+
else
|
|
79
|
+
0.0
|
|
80
|
+
end
|
|
76
81
|
|
|
77
82
|
command = read_command(pid, executable_name)
|
|
78
83
|
|
|
@@ -80,7 +85,7 @@ module Process
|
|
|
80
85
|
pid,
|
|
81
86
|
parent_process_id,
|
|
82
87
|
process_group_id,
|
|
83
|
-
|
|
88
|
+
processor_utilization,
|
|
84
89
|
virtual_size,
|
|
85
90
|
resident_pages * PAGE_SIZE,
|
|
86
91
|
processor_time,
|
|
@@ -17,7 +17,7 @@ module Process
|
|
|
17
17
|
pid: ->(values){values.shift.to_i},
|
|
18
18
|
ppid: ->(values){values.shift.to_i},
|
|
19
19
|
pgid: ->(values){values.shift.to_i},
|
|
20
|
-
pcpu: ->(values){values.shift.to_f},
|
|
20
|
+
pcpu: ->(values){values.shift.to_f / 100.0},
|
|
21
21
|
vsz: ->(values){values.shift.to_i * 1024},
|
|
22
22
|
rss: ->(values){values.shift.to_i * 1024},
|
|
23
23
|
time: ->(values){Process::Metrics.duration(values.shift)},
|
|
@@ -35,6 +35,7 @@ module Process
|
|
|
35
35
|
end
|
|
36
36
|
|
|
37
37
|
# General process information.
|
|
38
|
+
# @attribute [Float] The processor utilization in core units, where `1.0` represents one fully occupied CPU core. Multi-threaded processes may report values greater than `1.0`.
|
|
38
39
|
class General < Struct.new(:process_id, :parent_process_id, :process_group_id, :processor_utilization, :virtual_size, :resident_size, :processor_time, :elapsed_time, :start_time, :command, :memory)
|
|
39
40
|
# Convert the object to a JSON serializable hash.
|
|
40
41
|
def as_json
|
|
@@ -11,7 +11,7 @@ module Process
|
|
|
11
11
|
# @attribute [Integer] The process ID.
|
|
12
12
|
# @attribute [Float] The elapsed monotonic time in seconds.
|
|
13
13
|
# @attribute [Float] The CPU time consumed during the interval in seconds.
|
|
14
|
-
# @attribute [Float] The CPU utilization, where one fully occupied core
|
|
14
|
+
# @attribute [Float] The CPU utilization in core units, where `1.0` represents one fully occupied core. Multi-threaded processes may report values greater than `1.0`.
|
|
15
15
|
class Sample < Struct.new(:process_id, :duration, :processor_time, :utilization)
|
|
16
16
|
end
|
|
17
17
|
|
data/readme.md
CHANGED
|
@@ -16,6 +16,10 @@ Please see the [project documentation](https://socketry.github.io/process-metric
|
|
|
16
16
|
|
|
17
17
|
Please see the [project releases](https://socketry.github.io/process-metrics/releases/index) for all releases.
|
|
18
18
|
|
|
19
|
+
### v0.13.0
|
|
20
|
+
|
|
21
|
+
- Normalize processor utilization to core units, where `1.0` represents one fully occupied CPU core, and restore Linux reporting.
|
|
22
|
+
|
|
19
23
|
### v0.12.0
|
|
20
24
|
|
|
21
25
|
- Add `Process::Metrics::Processor` for measuring per-process CPU utilization over an interval.
|
|
@@ -56,10 +60,6 @@ Please see the [project releases](https://socketry.github.io/process-metrics/rel
|
|
|
56
60
|
|
|
57
61
|
- Handle `Errno::ESRCH: No such process @ io_fillbuf - fd:xxx /proc/xxx/smaps_rollup` by ignoring it.
|
|
58
62
|
|
|
59
|
-
### v0.6.0
|
|
60
|
-
|
|
61
|
-
- Add support for major and minor page faults on Linux: `Process::Metrics::Memory#major_faults` and `#minor_faults`. Unfortunately these metrics are not available on Darwin (macOS).
|
|
62
|
-
|
|
63
63
|
## Contributing
|
|
64
64
|
|
|
65
65
|
We welcome contributions to this project.
|
data/releases.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Releases
|
|
2
2
|
|
|
3
|
+
## v0.13.0
|
|
4
|
+
|
|
5
|
+
- Normalize processor utilization to core units, where `1.0` represents one fully occupied CPU core, and restore Linux reporting.
|
|
6
|
+
|
|
3
7
|
## v0.12.0
|
|
4
8
|
|
|
5
9
|
- Add `Process::Metrics::Processor` for measuring per-process CPU utilization over an interval.
|
data.tar.gz.sig
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
�)����q=��;��]�$]�irV��0��ޛnk}rO��'r�6�/3��gPX��Zl#�b���!2��_C:�4�.bgEL�y�1�p��6�?c>������� z�-/��އv�5FE��A���Y��]��x� �v
|
|
2
|
+
�$���������ٔ&��YqL4�u���`q�Q���iF���'�")�҃�9Su�yJ@7��ίRQ#��
|
metadata
CHANGED
metadata.gz.sig
CHANGED
|
Binary file
|