Skip to content

Commit

Permalink
Merge pull request #36 from nixwiz/add_bonsai_etc
Browse files Browse the repository at this point in the history
Mega PR for Bonsai, etc.
  • Loading branch information
Jef Spaleta authored Mar 25, 2020
2 parents 9588829 + cce006d commit 6b41507
Show file tree
Hide file tree
Showing 13 changed files with 163 additions and 63 deletions.
62 changes: 62 additions & 0 deletions .bonsai.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
---
description: "#{repo}"
builds:
- platform: "alpine"
arch: "amd64"
asset_filename: "#{repo}_#{version}_alpine_linux_amd64.tar.gz"
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
filter:
- "entity.system.os == 'linux'"
- "entity.system.arch == 'amd64'"
- "entity.system.platform == 'alpine'"
- "entity.system.platform_version.split('.')[0] == '3'"
- platform: "alpine3.8"
arch: "amd64"
asset_filename: "#{repo}_#{version}_alpine3.8_linux_amd64.tar.gz"
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
filter:
- "entity.system.os == 'linux'"
- "entity.system.arch == 'amd64'"
- "entity.system.platform == 'alpine'"
- platform: "centos"
arch: "amd64"
asset_filename: "#{repo}_#{version}_centos_linux_amd64.tar.gz"
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
filter:
- "entity.system.os == 'linux'"
- "entity.system.arch == 'amd64'"
- "entity.system.platform_family == 'rhel'"
- platform: "centos6"
arch: "amd64"
asset_filename: "#{repo}_#{version}_centos6_linux_amd64.tar.gz"
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
filter:
- "entity.system.os == 'linux'"
- "entity.system.arch == 'amd64'"
- "entity.system.platform_family == 'rhel'"
- "entity.system.platform_version.split('.')[0] == '6'"
- platform: "centos7"
arch: "amd64"
asset_filename: "#{repo}_#{version}_centos7_linux_amd64.tar.gz"
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
filter:
- "entity.system.os == 'linux'"
- "entity.system.arch == 'amd64'"
- "entity.system.platform_family == 'rhel'"
- "entity.system.platform_version.split('.')[0] == '7'"
- platform: "debian"
arch: "amd64"
asset_filename: "#{repo}_#{version}_debian_linux_amd64.tar.gz"
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
filter:
- "entity.system.os == 'linux'"
- "entity.system.arch == 'amd64'"
- "entity.system.platform_family == 'debian'"
- platform: "debian9"
arch: "amd64"
asset_filename: "#{repo}_#{version}_debian9_linux_amd64.tar.gz"
sha_filename: "#{repo}_#{version}_sha512-checksums.txt"
filter:
- "entity.system.os == 'linux'"
- "entity.system.arch == 'amd64'"

17 changes: 12 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
language: ruby
services:
- docker
cache:
- bundler
install:
- bundle install
rvm:
- 2.1
- 2.2
- 2.3.0
- 2.4.1
notifications:
Expand All @@ -18,16 +18,23 @@ script:
- bundle exec rake default
- gem build sensu-plugins-puppet.gemspec
- gem install sensu-plugins-puppet-*.gem
- bash -c "[ ! -d bonsai/ ] && git clone https://github.com/sensu/sensu-go-bonsai-asset.git bonsai || echo 'bonsai/ exists, skipping git clone'"
deploy:
provider: rubygems
- provider: rubygems
api_key:
secure: i6RFvnFPoE21r7Cglk2vQ4KgZyP6hsG53YtdBmyXKofvHwL3nlIc+WCInLSOLOaJH8fbT+NAIcpQQehDwL0WQH9J0bp3Lkp4DoLxCcyNKrztkNcVkeo8kYp9TCqDRS6vBtdkASoykO0dxeEtfk2Wa9yC9yS24o4xHlB5vdKZB1NC3W5P6S151aiizyb3NDlYc+Rp/1Grd9BETDrJvglhh7OwbFbtrEo28FSTjaoUsim2vW+622pIJps7pCwDf5Zc/lID/s0VPrUo8+JmwE/fb8TToj9nd88KFRPTT1EEC3tkUQMb93NuTjiYV9OSAAtFTTS8EBqQwUcr4rO4ikdybqwDcoYZm2v2Z0tQv2vJVRfIdl7WWMNoaMFS6L1m0oxofMOX5uaBZ09ujoH7av9RkmQZxpizfYNT8gf8umpVnSVe0myyVr08EmqppBbOaG1aa388fT4fFM8DnqPRHa1LHJHwFhW4ab//a/fiFSCR1xeSMwDFH3Op7znEYkp9Il6QMZcMflJlVHowx+9zyHfZalKujFtXdX7XE6JOGjdrzP7RkQoRONLNpYAgSytk2PBY42EZS7NprW21IrrGD51SwoB/lf1c25uEVcZvsHtvni7KSBYVHHJ0iW/jA4tR4Q386x3puzmYVcJHFznYnnd15p4dBmFcFI59tirhEZWgKpE=
gem: sensu-plugins-puppet
on:
tags: true
all_branches: true
rvm: 2.1
rvm: 2.2
rvm: 2.3.0
rvm: 2.4.1
repo: sensu-plugins/sensu-plugins-puppet
- provider: script
script: bonsai/ruby-runtime/travis-build-ruby-plugin-assets.sh sensu-plugins-puppet
skip_cleanup: true
on:
tags: true
all_branches: true
rvm: 2.4.1

12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,18 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins

## [Unreleased]

### Breaking Change
- Removed Ruby 2.1 and 2.2

### Added
- Bonsai asset build bits

### Changed
- Updated bundler to '~> 2.1'
- Updated rubocop to '~> 0.80.1'
- Updated sensu-plugin to '~> 4.0'
- Remediated rubocop warnings

## [2.2.0] - 2019-12-17
### Added
- Adding support windows by default without overriding options by checking the platform and adjusting the paths automatically (@bodgit)
Expand Down
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

source 'https://rubygems.org'

# Specify your gem's dependencies in sensu-plugins-puppet.gemspec
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Sensu-Plugins-puppet

[![Sensu Bonsai Asset](https://img.shields.io/badge/Bonsai-Download%20Me-brightgreen.svg?colorB=89C967&logo=sensu)](https://bonsai.sensu.io/assets/sensu-plugins/sensu-plugins-puppet)
[![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-puppet.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-puppet)
[![Gem Version](https://badge.fury.io/rb/sensu-plugins-puppet.svg)](http://badge.fury.io/rb/sensu-plugins-puppet)
[![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-puppet/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-puppet)
Expand Down
4 changes: 3 additions & 1 deletion Rakefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

require 'bundler/gem_tasks'
require 'github/markup'
require 'redcarpet'
Expand Down Expand Up @@ -27,7 +29,7 @@ desc 'Test for binstubs'
task :check_binstubs do
bin_list = Gem::Specification.load('sensu-plugins-puppet.gemspec').executables
bin_list.each do |b|
`which #{ b }`
`which #{b}`
unless $CHILD_STATUS.success?
puts "#{b} was not a binstub"
exit
Expand Down
16 changes: 9 additions & 7 deletions bin/check-puppet-errors.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#! /usr/bin/env ruby
# frozen_string_literal: true

#
# check-puppet-errors
#
Expand Down Expand Up @@ -35,15 +37,15 @@

class PuppetErrors < Sensu::Plugin::Check::CLI
option :summary_file,
short: '-s PATH',
long: '--summary-file PATH',
default: SensuPluginsPuppet::SUMMARY_FILE,
short: '-s PATH',
long: '--summary-file PATH',
default: SensuPluginsPuppet::SUMMARY_FILE,
description: 'Location of last_run_summary.yaml file'

option :agent_disabled_file,
short: '-a PATH',
long: '--agent-disabled-file PATH',
default: SensuPluginsPuppet::AGENT_DISABLED_FILE,
short: '-a PATH',
long: '--agent-disabled-file PATH',
default: SensuPluginsPuppet::AGENT_DISABLED_FILE,
description: 'Path to agent disabled lock file'

def run
Expand Down Expand Up @@ -73,7 +75,7 @@ def run
end
end

if @failures > 0
if @failures > 0 # rubocop:disable Style/NumericPredicate
@message += " had #{@failures} failures"
critical @message
else
Expand Down
78 changes: 40 additions & 38 deletions bin/check-puppet-last-run.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#! /usr/bin/env ruby
# frozen_string_literal: true

#
# check-puppet-last-run
#
Expand Down Expand Up @@ -35,64 +37,64 @@

class PuppetLastRun < Sensu::Plugin::Check::CLI
option :summary_file,
short: '-s PATH',
long: '--summary-file PATH',
default: SensuPluginsPuppet::SUMMARY_FILE,
short: '-s PATH',
long: '--summary-file PATH',
default: SensuPluginsPuppet::SUMMARY_FILE,
description: 'Location of last_run_summary.yaml file'

option :warn_age,
short: '-w N',
long: '--warn-age SECONDS',
default: 3600,
proc: proc(&:to_i),
short: '-w N',
long: '--warn-age SECONDS',
default: 3600,
proc: proc(&:to_i),
description: 'Age in seconds to be a warning'

option :crit_age,
short: '-c N',
long: '--crit-age SECONDS',
default: 7200,
proc: proc(&:to_i),
short: '-c N',
long: '--crit-age SECONDS',
default: 7200,
proc: proc(&:to_i),
description: 'Age in seconds to be a critical'

option :agent_disabled_file,
short: '-a PATH',
long: '--agent-disabled-file PATH',
default: SensuPluginsPuppet::AGENT_DISABLED_FILE,
short: '-a PATH',
long: '--agent-disabled-file PATH',
default: SensuPluginsPuppet::AGENT_DISABLED_FILE,
description: 'Path to agent disabled lock file'

option :disabled_age_limits,
short: '-d',
long: '--disabled-age-limits',
boolean: true,
default: false,
short: '-d',
long: '--disabled-age-limits',
boolean: true,
default: false,
description: 'Consider disabled age limits, otherwise use main limits'

option :warn_age_disabled,
short: '-W N',
long: '--warn-age-disabled SECONDS',
default: 3600,
proc: proc(&:to_i),
short: '-W N',
long: '--warn-age-disabled SECONDS',
default: 3600,
proc: proc(&:to_i),
description: 'Age in seconds to warn when agent is disabled'

option :crit_age_disabled,
short: '-C N',
long: '--crit-age-disabled SECONDS',
default: 7200,
proc: proc(&:to_i),
short: '-C N',
long: '--crit-age-disabled SECONDS',
default: 7200,
proc: proc(&:to_i),
description: 'Age in seconds to crit when agent is disabled'

option :report_restart_failures,
short: '-r',
long: '--report-restart-failures',
boolean: true,
default: false,
short: '-r',
long: '--report-restart-failures',
boolean: true,
default: false,
description: 'Raise alerts if restart failures have happened'

option :ignore_failures,
short: '-i',
long: '--ignore-failures',
boolean: true,
default: false,
short: '-i',
long: '--ignore-failures',
boolean: true,
default: false,
description: 'Ignore Puppet failures'

def run
Expand Down Expand Up @@ -138,11 +140,11 @@ def run
end
end

if @failures > 0
if @failures > 0 # rubocop:disable Style/NumericPredicate
@message += " with #{@failures} failures"
end

if @restart_failures > 0
if @restart_failures > 0 # rubocop:disable Style/NumericPredicate
@message += " with #{@restart_failures} restart failures"
end

Expand All @@ -156,7 +158,7 @@ def run
end
end

if @now - @last_run > config[:crit_age] || @failures > 0 || @restart_failures > 0
if @now - @last_run > config[:crit_age] || @failures > 0 || @restart_failures > 0 # rubocop:disable Style/NumericPredicate
critical @message
elsif @now - @last_run > config[:warn_age]
warning @message
Expand All @@ -170,7 +172,7 @@ def formatted_duration(total_seconds)
minutes = (total_seconds / 60) % 60
seconds = total_seconds % 60

if hours <= 0 && minutes > 0
if hours <= 0 && minutes > 0 # rubocop:disable Style/NumericPredicate
"#{minutes}m #{seconds}s"
elsif minutes <= 0
"#{seconds}s"
Expand Down
8 changes: 5 additions & 3 deletions bin/metrics-puppet-run.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#! /usr/bin/env ruby
# frozen_string_literal: true

#
# metrics-puppet-run
#
Expand Down Expand Up @@ -31,9 +33,9 @@

class PuppetRun < Sensu::Plugin::Metric::CLI::Graphite
option :summary_file,
short: '-p PATH',
long: '--summary-file PATH',
default: SensuPluginsPuppet::SUMMARY_FILE,
short: '-p PATH',
long: '--summary-file PATH',
default: SensuPluginsPuppet::SUMMARY_FILE,
description: 'Location of last_run_summary.yaml file'

option :scheme,
Expand Down
2 changes: 2 additions & 0 deletions lib/sensu-plugins-puppet.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: false

require 'sensu-plugins-puppet/version'

module SensuPluginsPuppet
Expand Down
2 changes: 2 additions & 0 deletions lib/sensu-plugins-puppet/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# frozen_string_literal: true

module SensuPluginsPuppet
module Version
MAJOR = 2
Expand Down
Loading

0 comments on commit 6b41507

Please sign in to comment.