Class: Cassandra::Utils::Stats::Health
- Defined in:
- lib/cassandra/utils/stats/health.rb
Instance Attribute Summary
Attributes inherited from CLI::Base
Instance Method Summary collapse
-
#gossipstate ⇒ String?
Return the state of nodetool info gossip.
- #metric_name ⇒ Object
- #run! ⇒ Object
-
#state ⇒ Symbol?
Return the state of the Cassandra node.
- #task_id ⇒ Object
-
#thriftstate ⇒ String?
Return the state of nodetool info thrift.
Methods inherited from CLI::Base
#cwd, #output, #runner, #timeout
Instance Method Details
#gossipstate ⇒ String?
Return the state of nodetool info gossip
The returned state is reported by “nodetool info”.
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_name ⇒ Object
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 |
#state ⇒ Symbol?
Return the state of the Cassandra node
The returned state is reported by “nodetool netstats”.
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_id ⇒ Object
66 67 68 |
# File 'lib/cassandra/utils/stats/health.rb', line 66 def task_id ['health', 'nodetool'] end |
#thriftstate ⇒ String?
Return the state of nodetool info thrift
The returned state is reported by “nodetool info”.
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 |