Class: Cassandra::Utils::Stats::Health

Inherits:
CLI::Base
  • Object
show all
Defined in:
lib/cassandra/utils/stats/health.rb

Instance Attribute Summary

Attributes inherited from CLI::Base

#command, #stdout

Instance Method Summary collapse

Methods inherited from CLI::Base

#cwd, #output, #runner, #timeout

Instance Method Details

#gossipstateString?

Return the state of nodetool info gossip

The returned state is reported by “nodetool info”.

Returns:

  • (String, nil)


24
25
26
27
28
29
30
31
32
# 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_nameObject



15
16
17
# File 'lib/cassandra/utils/stats/health.rb', line 15

def metric_name
  'cassandra.service.running'
end

#run!Object



5
6
7
8
9
10
11
12
13
# 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

#stateSymbol?

Return the state of the Cassandra node

The returned state is reported by “nodetool netstats”.

Returns:

  • (Symbol, nil)


56
57
58
59
60
61
62
63
64
# 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_idObject



66
67
68
# File 'lib/cassandra/utils/stats/health.rb', line 66

def task_id
  ['health', 'nodetool']
end

#thriftstateString?

Return the state of nodetool info thrift

The returned state is reported by “nodetool info”.

Returns:

  • (String, nil)


40
41
42
43
44
45
46
47
48
# 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