Top Level Namespace

Defined Under Namespace

Modules: Htmon

Instance Method Summary collapse

Instance Method Details

#check(interval: 60, &block) ⇒ Object

config related methods



44
45
46
# File 'lib/htmon/agent.rb', line 44

def check interval: 60, &block
  Htmon::Agent.checks << Htmon::Agent::Check.new(block, interval)
end

#load_schema(hostname: `hostname`) ⇒ Object



48
49
50
51
# File 'lib/htmon/agent.rb', line 48

def load_schema hostname: `hostname`
  JSON.parse RestClient.get(Htmon::Agent.remote+
                            "schema?"+({hostname: hostname}).to_param)
end

#push(url: nil, metric: nil, expires_after: nil, value: nil, hostname: `hostname`.strip) ⇒ Object



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/htmon/agent.rb', line 53

def push url: nil, metric: nil, expires_after: nil, value: nil, 
  hostname: `hostname`.strip
  logger = Logger.new(STDOUT)
  
  url = "#{Htmon::Agent.remote}#{url}?"+({hostname: hostname,
                                          value: value,
                                          expire: expires_after,
                                          metric: metric }).to_param
  begin
    RestClient.post url, nil
  rescue RestClient::ExceptionWithResponse => err
    logger.error "Push to #{url.inspect} failed ..."
    logger.error err.response
  end
end