class Cassandra::Utils::Stats::Health
Public Instance Methods
gossipstate()
click to toggle source
Return the state of nodetool info gossip
The returned state is reported by “nodetool info”.
@return [String, nil]
# File lib/cassandra/utils/stats/health.rb, line 24 def gossipstate results = (nodetool_info || '').split("\n") results.map! { |line| line.strip } results.select! { |line| line.include? 'Gossip active' } results.map! { |line| line.split(':')[1] } results.compact! return nil if results.size != 1 results.first.strip.downcase end
metric_name()
click to toggle source
# File lib/cassandra/utils/stats/health.rb, line 15 def metric_name 'cassandra.service.running' end
run!()
click to toggle source
# File lib/cassandra/utils/stats/health.rb, line 5 def run! running = true if state == :normal running &&= gossipstate == 'true' running &&= thriftstate == 'true' end Utils::Statsd.new(metric_name).to_dd(running).push! running end
state()
click to toggle source
Return the state of the Cassandra
node
The returned state is reported by “nodetool netstats”.
@return [Symbol, nil]
# File lib/cassandra/utils/stats/health.rb, line 56 def state results = (nodetool_netstats || '').split("\n") results.map! { |line| line.strip } results.select! { |line| line.include? 'Mode:' } results.map! { |line| line.split(':')[1] } results.compact! return nil if results.size != 1 results.first.strip.downcase.to_sym end
task_id()
click to toggle source
# File lib/cassandra/utils/stats/health.rb, line 66 def task_id ['health', 'nodetool'] end
thriftstate()
click to toggle source
Return the state of nodetool info thrift
The returned state is reported by “nodetool info”.
@return [String, nil]
# File lib/cassandra/utils/stats/health.rb, line 40 def thriftstate results = (nodetool_info || '').split("\n") results.map! { |line| line.strip } results.select! { |line| line.include? 'Thrift active' } results.map! { |line| line.split(':')[1] } results.compact! return nil if results.size != 1 results.first.strip.downcase end
Private Instance Methods
nodetool_info()
click to toggle source
Shell out via DaemonRunner to run 'nodetool info'
The returned state is either true or false
@return [String, nil] Output from the “nodetool info” command
# File lib/cassandra/utils/stats/health.rb, line 77 def nodetool_info @nodetool_info ||= DaemonRunner::ShellOut.new(command: 'nodetool info') @nodetool_info.run! @nodetool_info.stdout end
nodetool_netstats()
click to toggle source
Run the “nodetool netstats' command and return the output
@return [String, nil] Output from the “nodetool netstats” command
# File lib/cassandra/utils/stats/health.rb, line 87 def nodetool_netstats @nodetool_netstats ||= DaemonRunner::ShellOut.new(command: 'nodetool netstats', timeout: 300) @nodetool_netstats.run! @nodetool_netstats.stdout end