Sha256: fd2716b31f6a917ef40e42216eea9f411b259691fc21149c72f9714119c3512d
Contents?: true
Size: 1.98 KB
Versions: 3
Compression:
Stored size: 1.98 KB
Contents
#! /usr/bin/env ruby # frozen_string_literal: true # # check-cassandra-schema # # DESCRIPTION: # This plugin uses Apache Cassandra's `nodetool` to check to see # if any node in the cluster has run into a schema disagreement problem # # OUTPUT: # plain text # # PLATFORMS: # Linux # # DEPENDENCIES: # gem: sensu-plugin # gem: english # Cassandra's nodetool # # USAGE: # #YELLOW # # NOTES: # See http://www.datastax.com/documentation/cassandra/2.0/cassandra/dml/dml_handle_schema_disagree_t.html # for more details # # LICENSE: # Copyright 2014 Sonian, Inc. and contributors. <support@sensuapp.org> # Released under the same terms as Sensu (the MIT license); see LICENSE # for details. # require 'sensu-plugin/check/cli' require 'English' # # Check Cassandra Schema # class CheckCassandraSchema < Sensu::Plugin::Check::CLI option :hostname, short: '-h HOSTNAME', long: '--host HOSTNAME', description: 'cassandra hostname', default: 'localhost' option :port, short: '-P PORT', long: '--port PORT', description: 'cassandra JMX port', default: '7199' # execute cassandra's nodetool and return output as string def nodetool_cmd(cmd) out = `nodetool -h #{config[:hostname]} -p #{config[:port]} #{cmd} 2>&1` [out, $CHILD_STATUS] end def run out, rc = nodetool_cmd('describecluster') if rc != 0 critical(out) end bad_nodes = [] # #YELLOW out.each_line do |line| if m = line.match(/\s+UNREACHABLE:\s+(.*)\[(.*)\]\s+$/)# rubocop:disable all bad_nodes << m[2] next end if bad_nodes.count > 0 # rubocop: disable Style/NumericPredicate if m = line.match(/\s+(.*)\[(.*)\]\s+$/)# rubocop:disable all bad_nodes << m[2] end end end if bad_nodes.count > 0 # rubocop: disable Style/NumericPredicate critical('nodes ' + bad_nodes.join(', ') + ' are in schema disagreement') else ok end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
sensu-plugins-cassandra-3.0.2 | bin/check-cassandra-schema.rb |
sensu-plugins-cassandra-3.0.1 | bin/check-cassandra-schema.rb |
sensu-plugins-cassandra-3.0.0 | bin/check-cassandra-schema.rb |