Sha256: 8cb40a251208887f3f3197c1a9f1f0b889ad21731faf34d99e6095ca448dcc8e

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 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? # rubocop:disable IfUnlessModifier
      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-0.0.3 bin/check-riak-ringready.rb
sensu-plugins-riak-0.0.2 bin/check-riak-ringready.rb
sensu-plugins-riak-0.0.1 bin/check-riak-ringready.rb