sensu-plugins-puppet 1.2.0 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1b9a2e165b330e9a41397469f45e8e021e33b309
4
- data.tar.gz: 54853b54ec8e00454b56e6b61a89349fbb0d735f
2
+ SHA256:
3
+ metadata.gz: 913fac88835f5b35c47e2035cee725d00d5037bd8d214590053f786093250017
4
+ data.tar.gz: a4742868bd46a9ab584121cb5d63d6c0f97b5ccdb2e04246fc4ba011cecd71bb
5
5
  SHA512:
6
- metadata.gz: e2cb9889c112bb06f47e45c4d139ece3d28add0412a103b7beb3de85254550edd647eeba76ce224a4cb89895c3414c3d3c1e9db207ed5a8f4440f6388377a8a5
7
- data.tar.gz: 597bcbcec10b60a1d291c52f050477cf8581bdb34ed2370f95c5c13196f513f05722a0cc4c9d99da8bf85e93e5792281cb98d979417874e1854a5b4d1b4eb39d
6
+ metadata.gz: 0fb46a74c25a5139fc80ce46fd003f521ceca14993cd8fda9f51fe090d4966536c4cae7f0716fee223707cb393c2f5824e20d5a091b251d61d23ee8b276566fc
7
+ data.tar.gz: cd5920e72c9bbf79ff0bf82c118402741c9683b86f3d20b68f44b336cc641d24bdf2dfe93ce9d1c3782a2f1c4e56569b841eab9865a8465250ef2648aa3cfc18
data/CHANGELOG.md CHANGED
@@ -4,6 +4,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
4
4
  This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
5
 
6
6
  ## [Unreleased]
7
+
8
+ ## [1.3.0] - 2017-11-09
9
+ ### Added
10
+ - Testing for Ruby 2.4.1
11
+ - `check-puppet-errors.rb`: Added check for Puppet failures (@grem11n)
12
+ - `check-puppet-last-run.rb`: Added option for ignoring Puppet failure (@grem11n)
13
+
7
14
  ## [1.2.0] - 2017-05-30
8
15
  ### Added
9
16
  - `check-puppet-last-run.rb`: Added option for reporting failed restarts (@antonidabek)
@@ -34,7 +41,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
34
41
  ### Added
35
42
  - initial release
36
43
 
37
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-puppet/compare/1.2.0...HEAD
44
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-puppet/compare/1.3.0...HEAD
45
+ [1.3.0]: https://github.com/sensu-plugins/sensu-plugins-puppet/compare/1.2.0...1.3.0
38
46
  [1.2.0]: https://github.com/sensu-plugins/sensu-plugins-puppet/compare/1.1.0...1.2.0
39
47
  [1.1.0]: https://github.com/sensu-plugins/sensu-plugins-puppet/compare/1.0.0...1.1.0
40
48
  [1.0.0]: https://github.com/sensu-plugins/sensu-plugins-puppet/compare/0.0.2...1.0.0
data/README.md CHANGED
@@ -8,12 +8,17 @@
8
8
 
9
9
  ## Functionality
10
10
 
11
- **check-puppet-last-run.rb**
11
+ ### check-puppet-last-run.rb
12
+ Validates Puppet last run. Alerts if last Puppet run was later than threshold or it has errors
13
+
14
+ ### check-puppet-errors.rb
15
+ Validates only Puppet run errors regardless of the execution time
12
16
 
13
17
  ## Files
14
18
 
15
19
  * /bin/checkpuppet-last-run.rb
16
20
  * /bin/metrics-puppet-run.rb
21
+ * /bin/check-puppet-errors.rb
17
22
 
18
23
  ## Installation
19
24
 
@@ -0,0 +1,83 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-puppet-errors
4
+ #
5
+ # DESCRIPTION:
6
+ # Check if Puppet ran with errors
7
+ #
8
+ # OUTPUT:
9
+ # plain-text
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: sensu-plugin
16
+ #
17
+ # USAGE:
18
+ # Critical if last run had errors
19
+ #
20
+ # check-puppet-errors --summary-file /opt/puppetlabs/puppet/cache/state/last_run_summary.yaml
21
+ #
22
+ # NOTES:
23
+ #
24
+ # LICENSE:
25
+ # Copyright 2014 Sonian, Inc. and contributors. <support@sensuapp.org>
26
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
27
+ # for details.
28
+ #
29
+
30
+ require 'sensu-plugin/check/cli'
31
+ require 'yaml'
32
+ require 'json'
33
+ require 'time'
34
+
35
+ class PuppetErrors < Sensu::Plugin::Check::CLI
36
+ option :summary_file,
37
+ short: '-s PATH',
38
+ long: '--summary-file PATH',
39
+ default: '/opt/puppetlabs/puppet/cache/state/last_run_summary.yaml',
40
+ description: 'Location of last_run_summary.yaml file'
41
+
42
+ option :agent_disabled_file,
43
+ short: '-a PATH',
44
+ long: '--agent-disabled-file PATH',
45
+ default: '/opt/puppetlabs/puppet/cache/state/agent_disabled.lock',
46
+ description: 'Path to agent disabled lock file'
47
+
48
+ def run
49
+ unless File.exist?(config[:summary_file])
50
+ unknown "File #{config[:summary_file]} not found"
51
+ end
52
+
53
+ begin
54
+ summary = YAML.load_file(config[:summary_file])
55
+ if summary['events']
56
+ @failures = summary['events']['failure'].to_i
57
+ else
58
+ critical "#{config[:summary_file]} is missing information about the events"
59
+ end
60
+ rescue
61
+ unknown "Could not process #{config[:summary_file]}"
62
+ end
63
+
64
+ @message = 'Puppet run'
65
+
66
+ if File.exist?(config[:agent_disabled_file])
67
+ begin
68
+ disabled_message = JSON.parse(File.read(config[:agent_disabled_file]))['disabled_message']
69
+ @message += " (disabled reason: #{disabled_message})"
70
+ rescue => e
71
+ unknown "Could not get disabled message. Reason: #{e.message}"
72
+ end
73
+ end
74
+
75
+ if @failures > 0
76
+ @message += " had #{@failures} failures"
77
+ critical @message
78
+ else
79
+ @message += ' was successful'
80
+ ok @message
81
+ end
82
+ end
83
+ end
@@ -66,6 +66,13 @@ class PuppetLastRun < Sensu::Plugin::Check::CLI
66
66
  default: false,
67
67
  description: 'Raise alerts if restart failures have happened'
68
68
 
69
+ option :ignore_failures,
70
+ short: '-i',
71
+ long: '--ignore-failures',
72
+ boolean: true,
73
+ default: false,
74
+ description: 'Ignore Puppet failures'
75
+
69
76
  def run
70
77
  unless File.exist?(config[:summary_file])
71
78
  unknown "File #{config[:summary_file]} not found"
@@ -80,27 +87,31 @@ class PuppetLastRun < Sensu::Plugin::Check::CLI
80
87
  else
81
88
  critical "#{config[:summary_file]} is missing information about the last run timestamp"
82
89
  end
83
- if summary['events']
84
- @failures = summary['events']['failure'].to_i
85
- else
86
- critical "#{config[:summary_file]} is missing information about the events"
90
+ unless config[:ignore_failures]
91
+ if summary['events']
92
+ @failures = summary['events']['failure'].to_i
93
+ else
94
+ critical "#{config[:summary_file]} is missing information about the events"
95
+ end
96
+ @restart_failures = if config[:report_restart_failures] && summary['resources']
97
+ summary['resources']['failed_to_restart'].to_i
98
+ else
99
+ 0
100
+ end
87
101
  end
88
- @restart_failures = if config[:report_restart_failures] && summary['resources']
89
- summary['resources']['failed_to_restart'].to_i
90
- else
91
- 0
92
- end
93
102
  rescue
94
103
  unknown "Could not process #{config[:summary_file]}"
95
104
  end
96
105
 
97
106
  @message = "Puppet last run #{formatted_duration(@now - @last_run)} ago"
98
107
 
99
- begin
100
- disabled_message = JSON.parse(File.read(config[:agent_disabled_file]))['disabled_message']
101
- @message += " (disabled reason: #{disabled_message})"
102
- rescue # rubocop:disable HandleExceptions
103
- # fail silently
108
+ if File.exist?(config[:agent_disabled_file])
109
+ begin
110
+ disabled_message = JSON.parse(File.read(config[:agent_disabled_file]))['disabled_message']
111
+ @message += " (disabled reason: #{disabled_message})"
112
+ rescue => e
113
+ unknown "Could not get disabled message. Reason: #{e.message}"
114
+ end
104
115
  end
105
116
 
106
117
  if @failures > 0
@@ -3,7 +3,7 @@ module SensuPluginsPuppet
3
3
  # This defines the version of the gem
4
4
  module Version
5
5
  MAJOR = 1
6
- MINOR = 2
6
+ MINOR = 3
7
7
  PATCH = 0
8
8
 
9
9
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-puppet
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-31 00:00:00.000000000 Z
11
+ date: 2017-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -156,6 +156,7 @@ description: |-
156
156
  Puppet run.
157
157
  email: "<sensu-users@googlegroups.com>"
158
158
  executables:
159
+ - check-puppet-errors.rb
159
160
  - check-puppet-last-run.rb
160
161
  - metrics-puppet-run.rb
161
162
  extensions: []
@@ -164,6 +165,7 @@ files:
164
165
  - CHANGELOG.md
165
166
  - LICENSE
166
167
  - README.md
168
+ - bin/check-puppet-errors.rb
167
169
  - bin/check-puppet-last-run.rb
168
170
  - bin/metrics-puppet-run.rb
169
171
  - lib/sensu-plugins-puppet.rb
@@ -194,7 +196,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
194
196
  version: '0'
195
197
  requirements: []
196
198
  rubyforge_project:
197
- rubygems_version: 2.4.5
199
+ rubygems_version: 2.7.2
198
200
  signing_key:
199
201
  specification_version: 4
200
202
  summary: Sensu plugins for puppet