Class: Bosh::Monitor::Agent
- Inherits:
-
Object
- Object
- Bosh::Monitor::Agent
- Defined in:
- lib/bosh/monitor/agent.rb
Constant Summary collapse
- ATTRIBUTES =
[ :deployment, :job, :index, :cid ]
Instance Attribute Summary collapse
-
#discovered_at ⇒ Object
readonly
Returns the value of attribute discovered_at.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#updated_at ⇒ Object
Returns the value of attribute updated_at.
Instance Method Summary collapse
-
#initialize(id, opts = {}) ⇒ Agent
constructor
A new instance of Agent.
- #name ⇒ Object
- #rogue? ⇒ Boolean
- #timed_out? ⇒ Boolean
Constructor Details
#initialize(id, opts = {}) ⇒ Agent
Returns a new instance of Agent.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/bosh/monitor/agent.rb', line 14 def initialize(id, opts={}) raise ArgumentError, "Agent must have an id" if id.nil? @id = id @discovered_at = Time.now @updated_at = Time.now @logger = Bhm.logger @intervals = Bhm.intervals @deployment = opts[:deployment] @job = opts[:job] @index = opts[:index] @cid = opts[:cid] end |
Instance Attribute Details
#discovered_at ⇒ Object (readonly)
Returns the value of attribute discovered_at.
5 6 7 |
# File 'lib/bosh/monitor/agent.rb', line 5 def discovered_at @discovered_at end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/bosh/monitor/agent.rb', line 4 def id @id end |
#updated_at ⇒ Object
Returns the value of attribute updated_at.
6 7 8 |
# File 'lib/bosh/monitor/agent.rb', line 6 def updated_at @updated_at end |
Instance Method Details
#name ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bosh/monitor/agent.rb', line 29 def name if @deployment && @job && @index "#{@deployment}: #{@job}(#{@index}) [id=#{@id}, cid=#{@cid}]" else state = ATTRIBUTES.inject([]) do |acc, attribute| value = send(attribute) acc << "#{attribute}=#{value}" if value acc end "agent #{@id} [#{state.join(", ")}]" end end |
#rogue? ⇒ Boolean
47 48 49 |
# File 'lib/bosh/monitor/agent.rb', line 47 def rogue? (Time.now - @discovered_at) > @intervals.rogue_agent_alert && @deployment.nil? end |
#timed_out? ⇒ Boolean
43 44 45 |
# File 'lib/bosh/monitor/agent.rb', line 43 def timed_out? (Time.now - @updated_at) > @intervals.agent_timeout end |