sensu-plugins-mofa 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/check-mofa-provisioning.rb +21 -11
- data/lib/sensu-plugins-mofa/version.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ba8abb23f73feb549df1a072e2c49ccedc28a4f1
|
4
|
+
data.tar.gz: 3b4817c540114fc572343e9d499b819121af0937
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 :
|
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-
|
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(
|
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
|
44
|
+
data['result'] = 'SUCCESS'
|
45
45
|
when status =~ /FAIL/
|
46
|
-
data
|
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
|
55
|
-
when 'UNKNOWN'
|
56
|
-
unknown 'Cannot detect any mofa provisining (no cookbook info found).'
|
64
|
+
case data['result']
|
57
65
|
when 'SUCCESS'
|
58
|
-
ok
|
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
|
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
|
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
|
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-
|
11
|
+
date: 2017-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|