sensu-plugins-barman-checks 0.0.5 → 0.0.6

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: b81b372aaffa116262d0e7513a82fff5fca4e1d7
4
- data.tar.gz: 38d785b4dad4994c3625e04fa9d150619b73c103
3
+ metadata.gz: ec819915c39c84e17b07a19c07a12b73a5ecb596
4
+ data.tar.gz: 8a4e38db7934ee6256d1d82bf37d3feb6607f62c
5
5
  SHA512:
6
- metadata.gz: 87a4910384d302ebebc37327a42a90d2dfdd66512d4e24168037caf93cffb60091ee67d930bf616a9ce414b89e8b36a3d5cafcaee636b7df724ac344022b09e8
7
- data.tar.gz: a2d87b0dd6707eb00f1a04a338cf87bf38d0fd0a4b50d1a2657617eafcc72bd70e4bbbf92ee0734de74f41468c1ec3c7f42c10cd8eebc2680f529c1af6401593
6
+ metadata.gz: 6f40c89144542f201f1c563c473aab631c2ec2237f07c6e2365908f44f44baf0dcae706cab5110c6f15dfc3dd52d18301f713ccb973e9694a4ecd9327c98fc3e
7
+ data.tar.gz: 8a2c4305e44f14b226ad0768fae00da6b40d1abd408e03c7929001339d98522fe3b01ee8eed27fdf075d493cd6a7ee082c715ebc2c4d076fa190c67e7cf2afb3
data/CHANGELOG.md CHANGED
@@ -5,6 +5,13 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## 0.0.6 - 2016-11-30
9
+ ### Fixed
10
+ - Fix another race condition caused by barman cli relating to backup availability
11
+
12
+ ### Removed
13
+ - Remove warning option
14
+
8
15
  ## 0.0.5 - 2016-11-30
9
16
  ### Fixed
10
17
  - Fix race condition caused by barman cli where status for a backup is not available if it is in progress or failed.
data/README.md CHANGED
@@ -22,7 +22,7 @@ This plugin requires the use of sudo, as barman requires either the barman user
22
22
 
23
23
  `Defaults:sensu !requiretty`
24
24
 
25
- `/path_to_sensu/embedded/bin/ruby /path_to_sensu/embedded/bin/check-barman-backup-status.rb [-m MIN_NUMBER_BACKUPS] [--max-age MAX_AGE_IN_HOURS_OF_LATEST_BACKUP] [--warn WARN_AGE_IN_HOURS_OF_LATEST_BACKUP]`
25
+ `/path_to_sensu/embedded/bin/ruby /path_to_sensu/embedded/bin/check-barman-backup-status.rb [-m MIN_NUMBER_BACKUPS] [--max-age MAX_AGE_IN_HOURS_OF_LATEST_BACKUP]`
26
26
 
27
27
  ## Installation
28
28
 
@@ -37,13 +37,6 @@ class CheckBarmanBackupStatus < Sensu::Plugin::Check::CLI
37
37
  required: true,
38
38
  default: 1
39
39
 
40
- option :warn_age,
41
- description: 'The maximum age of backup before warning (in hours)',
42
- short: '-w',
43
- long: '--warn-age',
44
- required: true,
45
- default: 24
46
-
47
40
  option :max_age,
48
41
  description: 'The maximum age of backup before critical alert (in hours)',
49
42
  long: '--max-age',
@@ -65,7 +58,6 @@ class CheckBarmanBackupStatus < Sensu::Plugin::Check::CLI
65
58
  def run
66
59
  start_time = Time.now
67
60
  @crit = []
68
- @warn = []
69
61
 
70
62
  servers = `sudo barman list-server | awk '{print $1}'`.split(/\n/).map(&:strip)
71
63
 
@@ -77,10 +69,6 @@ class CheckBarmanBackupStatus < Sensu::Plugin::Check::CLI
77
69
  }
78
70
  }
79
71
 
80
- @backup_hash = {
81
- server.to_s => {}
82
- }
83
-
84
72
  # No YAML or other supported output to parse so we'll have to do it manually
85
73
  server_attrs = `sudo barman show-server #{server}`.split(/\n/).map(&:strip)
86
74
  server_attrs.each do |attr|
@@ -113,13 +101,17 @@ class CheckBarmanBackupStatus < Sensu::Plugin::Check::CLI
113
101
  next
114
102
  elsif backups.count < config[:min_backups].to_i && backups.count > 0
115
103
  @crit << "Minimum backups not met for server #{server}. Count is #{backups.count}"
116
- else
117
- puts "Number of backups for server #{server}: #{backups.count}"
118
104
  end
105
+ puts "Number of backups for server #{server}: #{backups.count}"
106
+
107
+ @latest = @server_hash[server]['status']['Last available backup']
119
108
 
120
109
  backups.each do |backup|
121
110
  stupid_barman_cli = `sudo barman list-backup #{server} | grep #{backup} | awk '{print $4}'`.strip
122
111
  if stupid_barman_cli.casecmp('started')
112
+ if backup == @latest
113
+ @skip_latest = true
114
+ end
123
115
  puts "Backup ID #{backup} for server #{server} is in progress. Skipping further checking on it"
124
116
  next
125
117
  elsif stupid_barman_cli.casecmp('failed')
@@ -133,28 +125,25 @@ class CheckBarmanBackupStatus < Sensu::Plugin::Check::CLI
133
125
  end
134
126
  end
135
127
 
136
- latest = @server_hash[server]['status']['Last available backup']
137
- latest_time = Time.parse(`sudo barman show-backup #{server} #{latest} | grep 'Begin time' | awk '{print $4,$5}'`.strip)
138
- backup_age = time_diff(latest_time, start_time).to_i
128
+ if @skip_latest == true
129
+ puts 'Latest backup is in progress. Skipping age check.'
130
+ else
131
+ latest_time = Time.parse(`sudo barman show-backup #{server} #{@latest} | grep 'Begin time' | awk '{print $4,$5}'`.strip)
139
132
 
140
- if backup_age > config[:warn_age].to_i
141
- @warn << "Warning threshold for backup age exceeded for latest backup on server #{server}. Age is #{backup_age} hour(s)"
142
- end
133
+ backup_age = time_diff(latest_time, start_time).to_i
143
134
 
144
- if backup_age > config[:max_age].to_i
145
- @crit << "Maximum age exceeded for latest backup on server #{server}. Age is: #{backup_age} hour(s)"
146
- else
135
+ if backup_age > config[:max_age].to_i
136
+ @crit << "Maximum age exceeded for latest backup on server #{server}. Age is: #{backup_age} hour(s)"
137
+ end
147
138
  puts "Age of latest backup for server #{server}: #{backup_age} hour(s)"
148
139
  end
149
140
  end
150
141
 
151
142
  # Assuming we got this far, exit cleanly
152
- if @crit.empty? && @warn.empty?
143
+ if @crit.empty?
153
144
  ok 'Recent backups exist for each configured server. Each configured server is also active and in a good state.'
154
- elsif !@crit.empty?
145
+ else
155
146
  critical "critical: #{@crit}"
156
- elsif !@warn.empty?
157
- warning "warning: #{@warn}"
158
147
  end
159
148
  end
160
149
  end
@@ -2,7 +2,7 @@ module SensuPluginsBarmanChecks
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- PATCH = 5
5
+ PATCH = 6
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-barman-checks
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Scott Brimhall
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-11-30 00:00:00.000000000 Z
12
+ date: 2016-12-01 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sensu-plugin