lib/heartbeat-client.rb in heartbeat-client-0.2.4 vs lib/heartbeat-client.rb in heartbeat-client-0.2.5
- old
+ new
@@ -1,10 +1,9 @@
require 'rubygems'
gem 'httparty'
require 'httparty'
require 'logger'
-require 'pp'
class Heartbeat
include HTTParty
base_uri 'http://heartbeat-server.herokuapp.com'
@@ -18,11 +17,11 @@
def self.log
Logger.new('/tmp/heartbeat.log')
end
- def self.create(apikey)
+ def self.create(apikey, name = nil)
procs = {'total' => 0, 'running' => 0, 'stuck' => 0, 'sleeping' => 0, 'threads' => 0, 'stopped' => 0, 'zombie' => 0}
load_avg = []
cpu_usage = {'user' => 0, 'sys' => 0, 'idle' => 0}
processes = []
memory = {'free' => 0, 'used' => 0}
@@ -73,9 +72,10 @@
options = {
:body => {
:heartbeat => {
:apikey => apikey,
:host => `hostname`.chomp,
+ :name => name,
:timestamp => Time.now.to_i,
:values => {
:process_stats => procs,
:load_avg => load_avg,
:cpu_usage => cpu_usage,