-
Notifications
You must be signed in to change notification settings - Fork 1
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 afa1fc5
Showing
15 changed files
with
439 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,53 @@ | ||
## Sensu-Plugins-bluepill | ||
|
||
[![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-bluepill.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-bluepill) | ||
[![Gem Version](https://badge.fury.io/rb/sensu-plugins-bluepill.svg)](http://badge.fury.io/rb/sensu-plugins-bluepill) | ||
[![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-bluepill/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-bluepill) | ||
[![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-bluepill/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-bluepill) | ||
[![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-bluepill.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-bluepill) | ||
|
||
## Functionality | ||
|
||
## Files | ||
* bin/check-bluepill-procs | ||
|
||
## 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-bluepill -P MediumSecurity | ||
``` | ||
|
||
You can also download the key from /certs/ within each repository. | ||
|
||
#### Rubygems | ||
|
||
`gem install sensu-plugins-bluepill` | ||
|
||
#### 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-bluepill' do | ||
options('--prerelease') | ||
version '0.0.1' | ||
end | ||
``` | ||
|
||
Using the Chef **gem_package** resource | ||
``` | ||
gem_package 'sensu-plugins-bluepill' 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,156 @@ | ||
#! /usr/bin/env ruby | ||
# | ||
# check-bluepill-procs | ||
# | ||
# DESCRIPTION: | ||
# This plugin monitors the status of applications and processes | ||
# running under the bluepill process supervisor. | ||
# | ||
# Specify applications to monitor with -a [APP1,APP2] | ||
# If this option is not provided, this check will monitor the processes | ||
# of all the applications that bluepill has loaded. | ||
# | ||
# OUTPUT: | ||
# plain text | ||
# Returns CRITICAL if any process is down or if a manually specified | ||
# application has no processes loaded | ||
# Returns WARNING if any process is starting or unmonitored | ||
# Returns OK if all processes for all specified applications are 'up' | ||
# or bluepill is not in $PATH | ||
# | ||
# PLATFORMS: | ||
# Linux | ||
# | ||
# DEPENDENCIES: | ||
# gem: sensu-plugin | ||
# gem: English | ||
# | ||
# USAGE: | ||
# | ||
# NOTES: | ||
# | ||
# LICENSE: | ||
# James Legg [email protected] | ||
# Matt Greensmith [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 'English' | ||
|
||
# Check application processes running under bluepill control | ||
class CheckBluepill < Sensu::Plugin::Check::CLI | ||
# a single application to monitor, or multiple applications, comma-separated. | ||
# check all applications if option not provided. | ||
option :apps, | ||
short: '-a [APPS]', | ||
long: '--applications [APPS]' | ||
|
||
option :debug, | ||
long: '--debug', | ||
description: 'Verbose output' | ||
|
||
option :sudo, | ||
short: '-s', | ||
long: '--sudo', | ||
description: 'exec bluepill with sudo (needs passwordless)' | ||
|
||
def merge_output(orig, add) | ||
orig.keys.each { |k| orig[k].push(*add[k]) } | ||
orig | ||
end | ||
|
||
def bluepill_application_status(name) | ||
out = { name: [], ok: [], warn: [], crit: [], err: [] } | ||
app_status = `#{config[:sudo] ? 'sudo ' : nil }bluepill #{name} status 2<&1` | ||
name = 'Unknown' if name == '' | ||
out[:name] << name | ||
puts "***** DEBUG: bluepill #{name} status *****\n#{app_status}" if config[:debug] | ||
processes_found = 0 | ||
# #YELLOW | ||
app_status.each_line do |line| # rubocop:disable Style/Next | ||
if line =~ /(pid:)/ | ||
processes_found += 1 | ||
case line | ||
when /unmonitored$/ | ||
out[:warn] << "#{name}::#{line}".strip | ||
next | ||
when /starting$/ | ||
out[:warn] << "#{name}::#{line}".strip | ||
next | ||
when /down$/ | ||
out[:crit] << "#{name}::#{line}".strip | ||
next | ||
when /up$/ | ||
out[:ok] << "#{name}::#{line}".strip | ||
next | ||
end | ||
end | ||
end | ||
out[:err] << name if processes_found == 0 | ||
puts "***** DEBUG: bluepill #{name} status parsed ******\n#{out.inspect}" if config[:debug] | ||
out | ||
end | ||
|
||
def parse_output(out) | ||
puts "***** DEBUG: Full output hash ******\n#{out.inspect}" if config[:debug] | ||
if !out[:crit].empty? | ||
critical "Bluepill process(es) critical:\n#{out[:crit].join("\n")}" | ||
elsif !out[:err].empty? | ||
critical "Bluepill process(es) not found for applications: #{out[:err].join(',')}" | ||
elsif !out[:warn].empty? | ||
warning "Bluepill process(es) warning:\n#{out[:warn].join("\n")}" | ||
else | ||
ok "Bluepill normal, #{out[:name].count} application(s) with #{out[:ok].count} process(es) up." | ||
end | ||
end | ||
|
||
def run | ||
# Check if Bluepill is installed | ||
`which bluepill` | ||
# #YELLOW | ||
unless $CHILD_STATUS.success? # rubocop:disable IfUnlessModifier | ||
ok 'bluepill not installed' | ||
end | ||
|
||
out = { name: [], ok: [], warn: [], crit: [], err: [] } | ||
|
||
if config[:apps] | ||
requested_apps = config[:apps].split(',').map(&:strip) || [] | ||
puts "***** DEBUG: requested applications: #{requested_apps }*****" if config[:debug] | ||
requested_apps.each do |a| | ||
out = merge_output(out, bluepill_application_status(a)) | ||
end | ||
else | ||
puts '***** DEBUG: checking all applications *****' if config[:debug] | ||
bluepill_status = `#{config[:sudo] ? 'sudo ' : nil }bluepill status 2>&1` | ||
if $CHILD_STATUS.success? | ||
# we have only one application loaded and bluepill is | ||
# 'helpfully' showing us only the status of that | ||
# application's processes. We can't get the name of the | ||
# application, however. | ||
puts '***** DEBUG: bluepill status short-circuited to show status of a single unknown application *****' if config[:debug] | ||
out = merge_output(out, bluepill_application_status('')) | ||
else | ||
# We either have multiple applications or no applications, | ||
# or maybe bluepill is completely borked. | ||
# (Returning non-zero when there are multiple applications | ||
# loaded seems bizarre, but hey, that's just me.) | ||
# We assume that no found applications is OK, since we only | ||
# get here if -a option is unset. | ||
# #YELLOW | ||
bluepill_status.each_line do |line| # rubocop:disable Style/Next | ||
if line =~ /^\s \d\.\s/ | ||
app_name = line.split(/^\s \d\.\s/)[1].strip | ||
# #YELLOW | ||
puts "***** DEBUG: found an application: #{app_name} *****" if config[:debug] # rubocop:disable BlockNesting | ||
out = merge_output(out, bluepill_application_status(app_name)) | ||
end | ||
end | ||
end | ||
end | ||
parse_output(out) | ||
end | ||
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,21 @@ | ||
-----BEGIN CERTIFICATE----- | ||
MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRIwEAYDVQQDDAltYXR0 | ||
am9uZXMxGDAWBgoJkiaJk/IsZAEZFgh5aWVsZGJvdDETMBEGCgmSJomT8ixkARkW | ||
A2NvbTAeFw0xNTAxMjgyMTAyNTFaFw0xNjAxMjgyMTAyNTFaMEMxEjAQBgNVBAMM | ||
CW1hdHRqb25lczEYMBYGCgmSJomT8ixkARkWCHlpZWxkYm90MRMwEQYKCZImiZPy | ||
LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyTSzVYnO | ||
CLgyrIyT1mBQakArQyW8xhi6MlDqyzXHJGeERT790U6EgoBVeS4XoK0ptFZNR8Tf | ||
zko0w+Nv47TarSCgkPOaxY+mxWnAVR10dOmfeLr7huiMyps+YD56/EF2FqQ3jf/+ | ||
qohENfKD91qy1ieEy+Fn7Pf74ltbNKUdkb9a9eFXQ0DQ4ip5vik7DzjQkUTj4lca | ||
k6ArwnmHX4YDhZoYtrQJ8jVktN0/+NtA40M5qkCYHNe5tUW25b/tKVYuioxG6b2Z | ||
oIzaZxRLxf6HVAWpCVRT/F5+/yjigkX4u++eYacfLGleXQzoK7BL65vHGMJygWEE | ||
0TKGqFOrl/L0AQIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV | ||
HQ4EFgQUEf6a8Td7MrSZc8ImbLFZAENPbz0wIQYDVR0RBBowGIEWbWF0dGpvbmVz | ||
QHlpZWxkYm90LmNvbTAhBgNVHRIEGjAYgRZtYXR0am9uZXNAeWllbGRib3QuY29t | ||
MA0GCSqGSIb3DQEBBQUAA4IBAQBbzXAYA3BVGw8DZ0YYoY1VHPNEcH5qPIApmHO8 | ||
rvSmuUT0yMEi7u00H/5uHRFf4LleGT/+sTdyXKsNPGT9kdRuQEgwi+vf7Zfvd8aX | ||
UF/+4VkEYf/8rV8Ere6u2QaWPgApdMV6JjKr1fAwCTd8AuGXNaWItiPPMseSQzLJ | ||
JKP4hVvbc1d+oS925B1lcBiqn2aYvElbyNAVmQPywNNqkWmvtlqj9ZVJfV5HQLdu | ||
8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk | ||
HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr | ||
-----END CERTIFICATE----- |
Oops, something went wrong.