sensu-plugins-minio 0.0.2 → 0.0.3

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
2
  SHA256:
3
- metadata.gz: f4bc8d2f5ad0c544a432fde71de635b0e33dacede694d26a93c6dcab39571a6d
4
- data.tar.gz: 81c09b508442e42f6226edc88a14bb6f629bff448b15663a20f6f48d93a4c571
3
+ metadata.gz: d74061e15df08517fa18fd66022c63eed26d23141f0cc60699e907f949bccd7f
4
+ data.tar.gz: 161197e9bcc9ed4a0cccc89af3d3ca6b5c9996432e0429d80d6326c1ce9d15a6
5
5
  SHA512:
6
- metadata.gz: 1acb7a14b304de0be3c3d465ff76c909ab17e5ae281e7bb5201173731f7c8ed9fba8d738c3911604f1b6de843126120a56c2e7ba1caba11a6efe3e239164fbc4
7
- data.tar.gz: 6c3c5b323a7adada77dd91e9fe2910cf8dbcf1aecf277f4f4127dd3fa95df91d98894377b3a0eb0f67d54a9fc61d26aaab8a508d29757d1f2b45f4be2f9f00b1
6
+ metadata.gz: a1995cc2b3453c2d40bd22017dad9af13bc60dbc487cee5093a575fb5cb64a59302f864eedda2fa1d793c3029704cd80e1a98224ffe9e8ef0325052e9f9917e4
7
+ data.tar.gz: c139954f08cb4fc7fe9c8fc84af54c4ea76c78435ce1c69965290695c17583fc40556d60cbb28810ceeef021a12e1c42562b95d95bc4edbece5aa0d6147e9558
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- sensu-plugins-minio (0.0.2)
4
+ sensu-plugins-minio (0.0.3)
5
5
  sensu-plugin (~> 2.1)
6
6
 
7
7
  GEM
@@ -45,34 +45,38 @@ class CheckMinioUpdate < Sensu::Plugin::Check::CLI
45
45
 
46
46
  begin
47
47
  Timeout.timeout(timeout) do
48
- check_update(checkurl, platform)
48
+ latest_version = get_latest_version(checkurl, platform)
49
+ local_version = get_local_version
50
+
51
+ if local_version == latest_version
52
+ ok 'No new minio version available'
53
+ else
54
+ critical "New minio version available #{latest_version}"
55
+ end
49
56
  end
57
+ rescue IOError => e
58
+ unknown "#{e.message}"
50
59
  rescue Timeout::Error
51
60
  unknown 'Connection timed out'
52
61
  end
53
62
  end
54
63
 
55
- def check_update(checkurl, platform)
64
+ def get_latest_version(checkurl, platform)
56
65
  uri = URI.parse("#{checkurl}/#{platform}/minio.shasum")
57
66
  response = Net::HTTP.get_response(uri)
58
67
 
59
- if response.is_a?(Net::HTTPSuccess)
60
- latest_version = response.body.split.last.split('.', 2).last
61
- else
62
- unknown "Unable to gather latest minio version: #{response.body}"
68
+ unless response.is_a?(Net::HTTPSuccess)
69
+ raise IOError, "Unable to gather latest minio version: #{response.body}"
63
70
  end
64
71
 
65
- stdout_str, error_str, status = Open3.capture3('minio')
66
- if status.success?
67
- local_version = stdout_str.split.last
68
- else
69
- unknown "Unable to gather local minio version: #{error_str}"
70
- end
72
+ return response.body.split.last.split('.', 2).last
73
+ end
71
74
 
72
- if latest_version.split('.').last == local_version.tr(':', '-')
73
- ok 'No new minio version available'
74
- else
75
- critical "New minio version available #{latest_version}"
76
- end
75
+ def get_local_version
76
+ stdout, stderr, status = Open3.capture3('minio --version', unsetenv_others: true)
77
+
78
+ raise IOError, "Unable to gather local minio version: #{stderr}" unless status.success?
79
+
80
+ return stdout.split.last
77
81
  end
78
82
  end
@@ -3,7 +3,7 @@
3
3
  module Sensu
4
4
  module Plugins
5
5
  module Minio
6
- VERSION = '0.0.2'
6
+ VERSION = '0.0.3'
7
7
  end
8
8
  end
9
9
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-minio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hauke Altmann
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-23 00:00:00.000000000 Z
11
+ date: 2020-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin