Sha256: 15d1848e15222629b41e92d2fe4f7328a28c620eb09d43cd2233a346880e8fbe

Contents?: true

Size: 1 KB

Versions: 3

Compression:

Stored size: 1 KB

Contents

#!/usr/bin/env ruby
#
# Check Riak Ring Status Plugin
# ===
#
# Runs 'riak-admin ringready' to check that all nodes agree on ring
#
# riak-admin requires root permissions.
#
# Create a file named /etc/sudoers.d/riak-admin with this line inside:
# sensu ALL=(ALL) NOPASSWD: /usr/sbin/riak-admin ringready
#
# Copyright 2014 Alexander Bulimov <lazywolf0@gmail.com>
#
# Released under the same terms as Sensu (the MIT license); see LICENSE
# for details.

require 'sensu-plugin/check/cli'
require 'open3'

#
# Check Riak Ring Status
#
class CheckRiakRingStatus < Sensu::Plugin::Check::CLI
  def execute(cmd)
    captured_stdout = ''
    exit_status = Open3.popen2e(ENV, cmd) do |stdin, stdout, wait_thr|
      stdin.close
      captured_stdout = stdout.read
      wait_thr.value
    end
    [exit_status, captured_stdout]
  end

  def run
    exit_status, message = execute 'sudo -n -k riak-admin ringready'
    # #YELLOW
    if exit_status.success?
      ok message if /^TRUE/ =~ message
    end
    critical message
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
sensu-plugins-riak-1.0.0 bin/check-riak-ringready.rb
sensu-plugins-riak-0.0.5 bin/check-riak-ringready.rb
sensu-plugins-riak-0.0.4 bin/check-riak-ringready.rb