Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added plugins/gluster/check-gluster-status.rb #1236

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 65 additions & 0 deletions plugins/gluster/check-gluster-status.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
#! /usr/bin/env ruby
#
# check-guster-status
#
# DESCRIPTION:
# Verifies Gluster's volume replication status#
#
# OUTPUT:
# plain text
#
# PLATFORMS:
# Linux
#
# DEPENDENCIES:
# gem: sensu-plugin
#
# USAGE:
# #YELLOW
#
# NOTES:
#
# LICENSE:
# Samuel Terburg <[email protected]>
# Released under the same terms as Sensu (the MIT license); see LICENSE
# for details.
#

require 'rubygems' if RUBY_VERSION < '1.9.0'
require 'sensu-plugin/check/cli'

class GlusterReplStatus < Sensu::Plugin::Check::CLI
option :ignore_nfs,
short: '-n',
long: '--ignore-nfs',
description: 'Ignore builtin NFS server',
boolean: true,
default: false

option :ignore_selfheal,
short: '-s',
long: '--ignore-selfheal',
description: 'Ignore selfheal service',
boolean: true,
default: false

def run
errors = []
# #YELLOW
`sudo gluster volume status`.each_line do |l| # rubocop:disable Style/Next
# Don't match those lines or conditions.
if l =~ / N /
unless (config[:ignore_nfs] && 'NFS'.include?(l.split[0])) \
|| (config[:ignore_selfheal] && 'Self-heal'.include?(l.split[0]))
errors << "#{l.split[0]} #{l.split[1]} is DOWN"
end
end
end

if errors.empty?
ok
else
critical errors
end
end
end