Class: PCPEasy::Agent

Inherits:
Object
  • Object
show all
Defined in:
lib/pcp_easy/agent.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host) ⇒ Agent

Returns a new instance of Agent.



8
9
10
# File 'lib/pcp_easy/agent.rb', line 8

def initialize(host)
  @host = host
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



6
7
8
# File 'lib/pcp_easy/agent.rb', line 6

def host
  @host
end

Instance Method Details

#metric(name) ⇒ Object



12
13
14
# File 'lib/pcp_easy/agent.rb', line 12

def metric(name)
  metrics([name]).first
end

#metrics(names) ⇒ Object

Raises:

  • (ArgumentError)


16
17
18
19
20
21
# File 'lib/pcp_easy/agent.rb', line 16

def metrics(names)
  raise ArgumentError, "array required for metrics" unless names.is_a? Array
  pmids = pmapi.pmLookupName(names)
  pmids_names = Hash[pmids.zip(names)]
  pmapi.pmFetch(pmids).vset.collect {|v| metric_from_vset(v, pmids_names)}
end