Class: LS4::StatService

Inherits:
Service show all
Defined in:
lib/ls4/service/stat.rb

Direct Known Subclasses

CSStatService, GWStatService

Instance Method Summary collapse

Methods inherited from Service

init

Methods included from EventBus::SingletonMixin

#ebus_bind!, #ebus_connect, extended

Methods included from EventBus::BusMixin

#ebus_all_slots, #ebus_disconnect!

Methods included from EventBus::DeclarerBase::Methods

#connect, #ebus_all_slots, #ebus_call_log, #ebus_call_slots, #ebus_signal_error, #ebus_signal_log, #ebus_signal_slots

Methods included from EventBus::DeclarerBase

#call_slot, #signal_slot

Constructor Details

#initializeStatService

Returns a new instance of StatService.



34
35
36
37
38
39
40
41
42
43
# File 'lib/ls4/service/stat.rb', line 34

def initialize
	@methods = {}
	public_methods.each {|name|
		if name =~ /^stat_(.*)$/
			@methods[$~[1]] = method(name)
		end
	}

	@start_time = Time.now
end

Instance Method Details

#rpc_stat(cmd) ⇒ Object



45
46
47
48
49
50
51
# File 'lib/ls4/service/stat.rb', line 45

def rpc_stat(cmd)
	if m = @methods[cmd]
		m.call
	else
		raise "no such status"
	end
end

#stat_cs_addressObject



70
71
72
# File 'lib/ls4/service/stat.rb', line 70

def stat_cs_address
	ConfigBus.get_cs_address
end

#stat_faultObject



78
79
80
# File 'lib/ls4/service/stat.rb', line 78

def stat_fault
	StatBus.fault_info
end

#stat_nodesObject



74
75
76
# File 'lib/ls4/service/stat.rb', line 74

def stat_nodes
	StatBus.membership_info
end

#stat_pidObject



62
63
64
# File 'lib/ls4/service/stat.rb', line 62

def stat_pid
	Process.pid
end

#stat_replsetObject



82
83
84
# File 'lib/ls4/service/stat.rb', line 82

def stat_replset
	StatBus.replset_info
end

#stat_timeObject



58
59
60
# File 'lib/ls4/service/stat.rb', line 58

def stat_time
	Time.now.utc.to_i
end

#stat_uptimeObject



53
54
55
56
# File 'lib/ls4/service/stat.rb', line 53

def stat_uptime
	uptime = Time.now - @start_time
	uptime.to_i
end

#stat_versionObject



66
67
68
# File 'lib/ls4/service/stat.rb', line 66

def stat_version
	VERSION
end