sensu-plugins-mofa 0.0.3 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 44f26402dc9c66313e7537c335c40cf502a78d25
4
- data.tar.gz: 1850162b053e9dd7921c13933777bd7d65c296cb
3
+ metadata.gz: ba8abb23f73feb549df1a072e2c49ccedc28a4f1
4
+ data.tar.gz: 3b4817c540114fc572343e9d499b819121af0937
5
5
  SHA512:
6
- metadata.gz: 109a9faf22bb01d62cb15e9ae01215374ee596cd96aa256bda0edb1ff2a9373c3351a279e8e975f8f1f4b07162ae78d70de8d95f62487490914c200c992ca0ef
7
- data.tar.gz: 2c0977288e7c81e8fa1674708ecdf10f4f3934c40056c7db7f9c0c384437749ff0b4343743298cb484fbf7178cb91d50c0da30563ce1d7318e91e6accadcc17e
6
+ metadata.gz: 5c1fd3cfa5518df99bf4828b73facaea0f6c4d48918b4db7df948bd00ccc673dc84ab7d47e2b07fc71d6347dda4f541e1087b432266b5ac978a64b421302a042
7
+ data.tar.gz: 703ae62daefee4e9bcae7efd41b6a1c52c337a2ddb58ff7a2ca516921b3d07edbf9bd4b804870678805cb665f2e8ee70c6a8f0ec6da2a1011317ee6f1109f2dc
@@ -29,35 +29,45 @@
29
29
  require 'sensu-plugin/check/cli'
30
30
 
31
31
  class MofaProvisioningChecker < Sensu::Plugin::Check::CLI
32
- option :mofa_status_file,
32
+ option :mofa_status_dir,
33
33
  description: 'Mofa Status dir - defaults to /var/lib/mofa',
34
34
  short: '-s /var/lib/mofa',
35
- long: '--mofa-status-file /var/lib/mofa',
35
+ long: '--mofa-status-dir /var/lib/mofa',
36
36
  default: '/var/lib/mofa'
37
37
 
38
38
  def process_mofa_status_dir(mofa_status_dir)
39
39
  data = { result: 'UNKNOWN' }
40
- if File.file?(mofa_status_dir)
41
- status = File.read(mofa_status_file).chomp
40
+ if File.file?("#{mofa_status_dir}/last_status")
41
+ status = File.read("#{mofa_status_dir}/last_status").chomp
42
42
  case
43
43
  when status =~ /SUCCESS/
44
- data.result = 'SUCCESS'
44
+ data['result'] = 'SUCCESS'
45
45
  when status =~ /FAIL/
46
- data.result = 'FAIL'
46
+ data['result'] = 'FAIL'
47
47
  end
48
48
  end
49
49
  data
50
50
  end
51
51
 
52
+ def read_mofa_status_file(mofa_status_dir, status_file)
53
+ content = ''
54
+ puts status_file
55
+ puts "#{mofa_status_dir}/#{status_file}"
56
+ if File.file?("#{mofa_status_dir}/#{status_file}")
57
+ content = File.read("#{mofa_status_dir}/#{status_file}").chomp
58
+ end
59
+ content
60
+ end
61
+
52
62
  def run
53
63
  data = process_mofa_status_dir(config[:mofa_status_dir])
54
- case data.result
55
- when 'UNKNOWN'
56
- unknown 'Cannot detect any mofa provisining (no cookbook info found).'
64
+ case data['result']
57
65
  when 'SUCCESS'
58
- ok 'Last mofa provisioning was successful ()'
66
+ ok "Last mofa provisioning was successful (#{read_mofa_status_file(config[:mofa_status_dir], 'last_cookbook_name')}@#{read_mofa_status_file(config[:mofa_status_dir], 'last_cookbook_version')})"
59
67
  when 'FAIL'
60
- critical 'Last mofa provisioning failed! ()'
68
+ critical "Last mofa provisioning failed! (#{read_mofa_status_file(config[:mofa_status_dir], 'last_cookbook_name')}@#{read_mofa_status_file(config[:mofa_status_dir], 'last_cookbook_version')})"
69
+ else
70
+ unknown 'Cannot detect any mofa provisining (no cookbook info found).'
61
71
  end
62
72
  end
63
73
  end
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsMofa
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 0
5
- PATCH = 3
4
+ MINOR = 1
5
+ PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-mofa
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.1.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-08-01 00:00:00.000000000 Z
11
+ date: 2017-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin