Class: Solanum::Source::Load
- Inherits:
-
Solanum::Source
- Object
- Solanum::Source
- Solanum::Source::Load
- Defined in:
- lib/solanum/source/load.rb
Constant Summary collapse
- STAT_FILE =
'/proc/loadavg'
Instance Attribute Summary collapse
-
#load_states ⇒ Object
readonly
Returns the value of attribute load_states.
Attributes inherited from Solanum::Source
Instance Method Summary collapse
- #collect! ⇒ Object
-
#initialize(opts) ⇒ Load
constructor
A new instance of Load.
Methods inherited from Solanum::Source
Constructor Details
#initialize(opts) ⇒ Load
Returns a new instance of Load.
10 11 12 13 |
# File 'lib/solanum/source/load.rb', line 10 def initialize(opts) super(opts) @load_states = opts['load_states'] || {} end |
Instance Attribute Details
#load_states ⇒ Object (readonly)
Returns the value of attribute load_states.
5 6 7 |
# File 'lib/solanum/source/load.rb', line 5 def load_states @load_states end |
Instance Method Details
#collect! ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/solanum/source/load.rb', line 16 def collect! events = [] loadavg = File.read(STAT_FILE).chomp.split(' ') load1m = loadavg[0].to_f events << { service: 'process load', metric: load1m, state: state_over(@load_states, load1m), } running, count = *loadavg[3].split('/') events << { service: 'process running', metric: running.to_i, } events << { service: 'process count', metric: count.to_i, } events end |