-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matt Jones
committed
Feb 16, 2015
0 parents
commit 87f280b
Showing
16 changed files
with
525 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/.bundle/ | ||
/.yardoc | ||
/Gemfile.lock | ||
/_yardoc/ | ||
/coverage/ | ||
/doc/ | ||
/pkg/ | ||
/spec/reports/ | ||
/tmp/ | ||
*.bundle | ||
*.so | ||
*.o | ||
*.a | ||
mkmf.log | ||
.vagrant/* | ||
.DS_Store | ||
.idea/* | ||
*.gem |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
|
||
MethodLength: | ||
Max: 200 | ||
|
||
LineLength: | ||
Max: 160 | ||
|
||
FileName: | ||
Enabled: false | ||
|
||
PerceivedComplexity: | ||
Enabled: false | ||
|
||
CyclomaticComplexity: | ||
Enabled: false | ||
|
||
ClassLength: | ||
Enabled: false | ||
|
||
IfUnlessModifier: | ||
Enabled: false | ||
|
||
RegexpLiteral: | ||
Enabled: false | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
language: ruby | ||
cache: | ||
- bundler | ||
install: | ||
- bundle install | ||
rvm: | ||
- 1.9.3 | ||
- 2.0 | ||
- 2.1 | ||
notifications: | ||
email: | ||
recipients: | ||
- [email protected] | ||
on_success: change | ||
on_failure: always | ||
|
||
script: | ||
- 'bundle exec rake default' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#### 0.0.1.alpha.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[Development Documentation](http://sensu-plugins.github.io/development/) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
source 'https://rubygems.org' | ||
|
||
gemspec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Copyright (c) 2015 [email protected] | ||
|
||
MIT License | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
## Sensu-Plugins-ceph | ||
|
||
[![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-ceph.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-ceph) | ||
[![Gem Version](https://badge.fury.io/rb/sensu-plugins-ceph.svg)](http://badge.fury.io/rb/sensu-plugins-ceph) | ||
[![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-ceph/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-ceph) | ||
[![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-ceph/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-ceph) | ||
[![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-ceph.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-ceph) | ||
|
||
## Functionality | ||
|
||
## Files | ||
* bin/check-ceph | ||
* bin/metrics-ceph-osd | ||
|
||
## Usage | ||
|
||
## Installation | ||
|
||
Add the public key (if you haven’t already) as a trusted certificate | ||
|
||
``` | ||
gem cert --add <(curl -Ls https://raw.githubusercontent.com/sensu-plugins/sensu-plugins.github.io/master/certs/sensu-plugins.pem) | ||
gem install sensu-plugins-ceph -P MediumSecurity | ||
``` | ||
|
||
You can also download the key from /certs/ within each repository. | ||
|
||
#### Rubygems | ||
|
||
`gem install sensu-plugins-ceph` | ||
|
||
#### Bundler | ||
|
||
Add *sensu-plugins-disk-checks* to your Gemfile and run `bundle install` or `bundle update` | ||
|
||
#### Chef | ||
|
||
Using the Sensu **sensu_gem** LWRP | ||
``` | ||
sensu_gem 'sensu-plugins-ceph' do | ||
options('--prerelease') | ||
version '0.0.1' | ||
end | ||
``` | ||
|
||
Using the Chef **gem_package** resource | ||
``` | ||
gem_package 'sensu-plugins-ceph' do | ||
options('--prerelease') | ||
version '0.0.1' | ||
end | ||
``` | ||
|
||
## Notes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
require 'bundler/gem_tasks' | ||
require 'rspec/core/rake_task' | ||
require 'yard' | ||
require 'github/markup' | ||
require 'rubocop/rake_task' | ||
require 'redcarpet' | ||
require 'yard/rake/yardoc_task' | ||
|
||
desc 'Don\'t run Rubocop for unsupported versions' | ||
begin | ||
if RUBY_VERSION >= '2.0.0' | ||
args = [:spec, :make_bin_executable, :yard, :rubocop] | ||
else | ||
args = [:spec, :make_bin_executable, :yard] | ||
end | ||
end | ||
|
||
YARD::Rake::YardocTask.new do |t| | ||
OTHER_PATHS = %w() | ||
t.files = ['lib/**/*.rb', 'bin/**/*.rb', OTHER_PATHS] | ||
t.options = %w(--markup-provider=redcarpet --markup=markdown --main=README.md --files CHANGELOG.md) | ||
end | ||
|
||
Rubocop::RakeTask.new | ||
|
||
RSpec::Core::RakeTask.new(:spec) do |r| | ||
r.pattern = FileList['**/**/*_spec.rb'] | ||
end | ||
|
||
desc 'Make all plugins executable' | ||
task :make_bin_executable do | ||
`chmod -R +x bin/***/*.rb` | ||
end | ||
|
||
task default: args |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
VAGRANTFILE_API_VERSION = '2' | ||
|
||
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| | ||
|
||
config.vm.box = 'chef/centos-6.6' | ||
config.vm.box_download_checksum = true | ||
config.vm.box_download_checksum_type = 'md5' | ||
config.vm.hostname = 'sensu-plugins-dev' | ||
|
||
script = <<EOF | ||
sudo yum update -y | ||
sudo yum groupinstall -y development | ||
sudo yum install -y vim nano | ||
#sudo yum install -y ImagicMagic ImageMagick-devel mysql-devel # needed for bundle install | ||
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3 | ||
curl -L get.rvm.io | bash -s stable | ||
source /home/vagrant/.rvm/scripts/rvm | ||
rvm reload | ||
#rvm install 1.9.3 | ||
rvm install 2.1.4 | ||
#rvm install 2.0.0 | ||
#rvm use 1.9.3@sensu_plugins --create | ||
#rvm use 2.0.0@sensu_plugins --create | ||
rvm use 2.1.4@sensu_plugins --create | ||
rvm use 2.1.4@sensu_plugins --default | ||
EOF | ||
|
||
config.vm.provision 'shell', inline: script, privileged: false | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
#! /usr/bin/env ruby | ||
# | ||
# check-ceph | ||
# | ||
# DESCRIPTION: | ||
# #YELLOW | ||
# | ||
# OUTPUT: | ||
# plain text | ||
# | ||
# PLATFORMS: | ||
# Linux | ||
# | ||
# DEPENDENCIES: | ||
# gem: sensu-plugin | ||
# ceph client | ||
# | ||
# USAGE: | ||
# #YELLOW | ||
# | ||
# NOTES: | ||
# Runs 'ceph health' command(s) to report health status of ceph | ||
# cluster. May need read access to ceph keyring and/or root access | ||
# for authentication. | ||
# | ||
# Using -i (--ignore-flags) option allows specific options that are | ||
# normally considered Ceph warnings to be overlooked and considered | ||
# as 'OK' (e.g. noscrub,nodeep-scrub). | ||
# | ||
# Using -d (--detailed) and/or -o (--osd-tree) will dramatically increase | ||
# verboseness during warning/error reports, however they may add | ||
# additional insights to cluster-related problems during notification. | ||
# | ||
# LICENSE: | ||
# Copyright 2013 Brian Clark <[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' | ||
require 'timeout' | ||
require 'English' | ||
|
||
class CheckCephHealth < Sensu::Plugin::Check::CLI | ||
option :keyring, | ||
description: 'Path to cephx authentication keyring file', | ||
short: '-k KEY', | ||
long: '--keyring', | ||
proc: proc { |k| " -k #{k}" } | ||
|
||
option :monitor, | ||
description: 'Optional monitor IP', | ||
short: '-m MON', | ||
long: '--monitor', | ||
proc: proc { |m| " -m #{m}" } | ||
|
||
option :cluster, | ||
description: 'Optional cluster name', | ||
short: '-c NAME', | ||
long: '--cluster', | ||
proc: proc { |c| " --cluster=#{c}" } | ||
|
||
option :timeout, | ||
description: 'Timeout (default 10)', | ||
short: '-t SEC', | ||
long: '--timeout', | ||
proc: proc(&:to_i), | ||
default: 10 | ||
|
||
option :ignore_flags, | ||
description: 'Optional ceph warning flags to ignore', | ||
short: '-i FLAG[,FLAG]', | ||
long: '--ignore-flags', | ||
proc: proc { |f| f.split(',') } | ||
|
||
option :show_detail, | ||
description: 'Show ceph health detail on warns/errors (verbose!)', | ||
short: '-d', | ||
long: '--detailed', | ||
boolean: true, | ||
default: false | ||
|
||
option :osd_tree, | ||
description: 'Show OSD tree on warns/errors (verbose!)', | ||
short: '-o', | ||
long: '--osd-tree', | ||
boolean: true, | ||
default: false | ||
|
||
def run_cmd(cmd) | ||
pipe, status = nil | ||
begin | ||
cmd += config[:cluster] if config[:cluster] | ||
cmd += config[:keyring] if config[:keyring] | ||
cmd += config[:monitor] if config[:monitor] | ||
cmd += ' 2>&1' | ||
Timeout.timeout(config[:timeout]) do | ||
pipe = IO.popen(cmd) | ||
Process.wait(pipe.pid) | ||
status = $CHILD_STATUS.exitstatus | ||
end | ||
rescue Timeout::Error | ||
begin | ||
Process.kill(9, pipe.pid) | ||
Process.wait(pipe.pid) | ||
rescue Errno::ESRCH, Errno::EPERM | ||
# Catch errors from trying to kill the timed-out process | ||
# We must do something here to stop travis complaining | ||
critical 'Execution timed out' | ||
ensure | ||
critical 'Execution timed out' | ||
end | ||
end | ||
output = pipe.read | ||
critical "Command '#{cmd}' returned no output" if output.to_s == '' | ||
critical output unless status == 0 | ||
output | ||
end | ||
|
||
def strip_warns(result) | ||
r = result.dup | ||
r.gsub!(/HEALTH_WARN\ /, '') | ||
.gsub!(/\ ?flag\(s\) set/, '') | ||
.gsub!(/\n/, '') | ||
config[:ignore_flags].each do |f| | ||
r.gsub!(/,?#{f},?/, '') | ||
end | ||
if r.length == 0 | ||
result.gsub(/HEALTH_WARN/, 'HEALTH_OK') | ||
else | ||
result | ||
end | ||
end | ||
|
||
def run | ||
result = run_cmd('ceph health') | ||
unless result.start_with?('HEALTH_OK') | ||
result = strip_warns(result) if config[:ignore_flags] | ||
end | ||
ok result if result.start_with?('HEALTH_OK') | ||
|
||
result = run_cmd('ceph health detail') if config[:show_detail] | ||
result += run_cmd('ceph osd tree') if config[:osd_tree] | ||
if result.start_with?('HEALTH_WARN') | ||
warning result | ||
else | ||
critical result | ||
end | ||
end | ||
end |
Oops, something went wrong.