Class: Metrix::ProcessMetric
- Inherits:
-
Base
- Object
- Base
- Metrix::ProcessMetric
show all
- Defined in:
- lib/metrix/process_metric.rb
Instance Attribute Summary collapse
Attributes inherited from Base
#attributes
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
ignore, #ignore_metric?, ignore_metrics, inherited, #initialize, known_metrics, #metrics, prefix, #prefix, set_known_metrics, set_prefix, subclasses, #tagged_metrics
Constructor Details
This class inherits a constructor from Metrix::Base
Instance Attribute Details
#time ⇒ Object
Returns the value of attribute time.
5
6
7
|
# File 'lib/metrix/process_metric.rb', line 5
def time
@time
end
|
Class Method Details
.all ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/metrix/process_metric.rb', line 12
def all
IO.popen("find /proc -maxdepth 2 -mindepth 2 -name stat") do |io|
io.map do |path|
Metrix::ProcessMetric.new(File.read(path.strip))
end
end
end
|
Instance Method Details
#cast_int(str) ⇒ Object
57
58
59
|
# File 'lib/metrix/process_metric.rb', line 57
def cast_int(str)
Integer(str) rescue str
end
|
#chunks ⇒ Object
29
30
31
|
# File 'lib/metrix/process_metric.rb', line 29
def chunks
@chunks ||= @raw.split(" ").map { |c| cast_int(c) }
end
|
#name ⇒ Object
21
22
23
|
# File 'lib/metrix/process_metric.rb', line 21
def name
normalize_name(comm)
end
|
#normalize_name(the_name) ⇒ Object
25
26
27
|
# File 'lib/metrix/process_metric.rb', line 25
def normalize_name(the_name)
the_name.gsub(/^\(/, "").gsub(/\)$/, "").gsub(/[^\w]+/i, "_")
end
|
33
34
35
36
37
38
39
|
# File 'lib/metrix/process_metric.rb', line 33
def tags
{
name: name,
pid: pid,
ppid: ppid,
}
end
|
#unfiltered_metrics ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/metrix/process_metric.rb', line 41
def unfiltered_metrics
{
minflt: minflt,
cminflt: cminflt,
majflt: majflt,
cmajflt: cmajflt,
utime: utime,
stime: stime,
cutime: cutime,
sctime: sctime,
num_threads: num_threads,
vsize: vsize,
rss: ,
}
end
|