Module: Custodian::Samplers
- Defined in:
- lib/custodian/samplers.rb,
lib/custodian/samplers/sampler.rb,
lib/custodian/samplers/linux/cpu.rb,
lib/custodian/samplers/linux/ram.rb,
lib/custodian/samplers/utilities.rb,
lib/custodian/samplers/darwin/cpu.rb,
lib/custodian/samplers/darwin/ram.rb,
lib/custodian/samplers/darwin/who.rb,
lib/custodian/samplers/linux/load.rb,
lib/custodian/samplers/darwin/load.rb
Overview
The Samplers module encapsulates a collection of samplers for various metrics.
Defined Under Namespace
Modules: Utilities Classes: CPU, Load, RAM, Sampler, Who
Class Method Summary collapse
-
.clear ⇒ Object
Clear all samplers.
-
.compatible ⇒ Object
List compatible samplers.
-
.incompatible ⇒ Object
List incompatible samplers.
-
.list ⇒ Object
List all samplers.
-
.load(directory) ⇒ Object
Load samplers from the given directory.
-
.register(sampler) ⇒ Object
Register the given sampler.
-
.remove(sampler) ⇒ Object
Remove the given sampler.
-
.replace(a, b) ⇒ Object
Replace one sampler with another.
-
.stock ⇒ Object
Restore stock samplers.
Class Method Details
.clear ⇒ Object
Clear all samplers.
64 65 66 |
# File 'lib/custodian/samplers.rb', line 64 def self.clear @samplers = [] end |
.compatible ⇒ Object
List compatible samplers.
Returns an Array of Sampler objects that are compatible with this system.
24 25 26 |
# File 'lib/custodian/samplers.rb', line 24 def self.compatible @samplers.select { |s| s.compatible? } end |
.incompatible ⇒ Object
List incompatible samplers.
Returns an Array of Sampler objects that are incompatible with this system.
32 33 34 |
# File 'lib/custodian/samplers.rb', line 32 def self.incompatible @samplers.reject { |s| s.compatible? } end |
.list ⇒ Object
List all samplers.
Returns an Array of Sampler objects.
16 17 18 |
# File 'lib/custodian/samplers.rb', line 16 def self.list @samplers end |
.load(directory) ⇒ Object
Load samplers from the given directory.
directory - A String describing a path to a directory. If the path is relative,
it will be expanded from the current working directory. If the path
is prefixed with a tilde, it will be expanded from the current user's
home directory. If the path is prefixed with a tilde immediately followed
by a username, it will be expanded from that user's home directory.
Returns nothing.
83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/custodian/samplers.rb', line 83 def self.load(directory) path = Pathname.new directory # Allow referencing directories by relative and home path. path = path. unless path.absolute? unless path.directory? raise StandardError, "#{directory} is not a directory" end path.each_child do |child| require child if child.file? end end |
.register(sampler) ⇒ Object
Register the given sampler.
sampler - An object that inherits from Sampler.
Returns nothing.
41 42 43 |
# File 'lib/custodian/samplers.rb', line 41 def self.register(sampler) @samplers << sampler end |
.remove(sampler) ⇒ Object
Remove the given sampler.
sampler - An object that inherits from Sampler.
48 49 50 |
# File 'lib/custodian/samplers.rb', line 48 def self.remove(sampler) @samplers.delete(sampler) end |
.replace(a, b) ⇒ Object
Replace one sampler with another.
a - An object that inherits from Sampler. b - Another object that inherits from Sampler.
Returns nothing.
58 59 60 61 |
# File 'lib/custodian/samplers.rb', line 58 def self.replace(a, b) remove a register b end |