sensu-plugins-restic 0.2.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 +7 -0
- data/CHANGELOG.md +9 -0
- data/LICENSE +22 -0
- data/README.md +48 -0
- data/bin/check-restic-snapshot.rb +83 -0
- data/lib/sensu-plugins-restic.rb +1 -0
- data/lib/sensu-plugins-restic/version.rb +9 -0
- metadata +257 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3040f21918c252212b29a508c07aefbb7fc9a8b90b36346713c0b4ac5d10a708
|
4
|
+
data.tar.gz: f639061282c9ad44440762e7af85af1a9968907b342865012d5654a17d26057a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: f82c76f754963de4543c95c53bce14b1ba458713aea27b283f99e1b4c30ad5d95313a6ee30f6098686550636480809ce873ab96a59a333e79bd73eec4ed53421
|
7
|
+
data.tar.gz: 1578bb4b4b6a87309d1b3015536d97777f5707bfa404c6448357572e5a9e033ff7a0c02a5fe2ed6a2988da7439a2b1ead7c35d1c6033789d06234fb77cc0e7c4
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
# Change Log
|
2
|
+
This project adheres to [Semantic Versioning](http://semver.org/).
|
3
|
+
|
4
|
+
This CHANGELOG follows the format located [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)
|
5
|
+
|
6
|
+
## [Unreleased]
|
7
|
+
|
8
|
+
### Added
|
9
|
+
- Check to test for restic snapshot age
|
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Sensu Community Plugins
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
# sensu-plugins-restic
|
2
|
+
|
3
|
+
[](https://travis-ci.org/erasys/sensu-plugins-restic)
|
4
|
+
[](http://badge.fury.io/rb/sensu-plugins-restic)
|
5
|
+
[](https://gemnasium.com/erasys/sensu-plugins-restic)
|
6
|
+
[](https://slack.sensu.io/badge)
|
7
|
+
|
8
|
+
## Functionality
|
9
|
+
|
10
|
+
## Files
|
11
|
+
|
12
|
+
* bin/check-restic-snapshot.rb
|
13
|
+
|
14
|
+
## Usage
|
15
|
+
|
16
|
+
### check-restic-snapshot
|
17
|
+
|
18
|
+
Checks the presence and the age of the latest restic backup snapshot.
|
19
|
+
|
20
|
+
By default it expects the restic binary to be installed at `/usr/bin/restic`. Repository location and password are passed into the check
|
21
|
+
through the environment variables `$RESTIC_REPOSITORY` and `$RESTIC_PASSWORD_FILE`. Please check the
|
22
|
+
[restic documentation](https://restic.readthedocs.io/en/latest/manual_rest.html) for details.
|
23
|
+
|
24
|
+
This example checks the repository configured through the environment variables mentioned before. It warns if the last backup is older
|
25
|
+
than 1 day + 1 hour, and becomes critical after 2 days + 1 hour:
|
26
|
+
|
27
|
+
```
|
28
|
+
check-restic-snapshot.rb -w 90000 -c 176400
|
29
|
+
```
|
30
|
+
|
31
|
+
If your restic binary is in a different location and/or you prefer to pass repository location and password via parameters, use the `-p`
|
32
|
+
option to specify how the restic binary is invoked:
|
33
|
+
|
34
|
+
```
|
35
|
+
check-restic-snapshot.rb -w 90000 -c 176400 -p '/opt/bin/restic -r /mnt/backups -p /etc/restic/password'
|
36
|
+
```
|
37
|
+
|
38
|
+
The `--missing-status` allows you to specify the check's result if no backup has been created so far (defaults to `critical`).
|
39
|
+
|
40
|
+
```
|
41
|
+
check-restic-snapshot.rb -w 90000 -c 176400 --missing-status warning
|
42
|
+
```
|
43
|
+
|
44
|
+
## Installation
|
45
|
+
|
46
|
+
[Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
|
47
|
+
|
48
|
+
## Notes
|
@@ -0,0 +1,83 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-snapshot
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# Check the age of the last restic snapshot
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# Plain text
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Any platform with restic client
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: sensu-plugin
|
16
|
+
#
|
17
|
+
# USAGE:
|
18
|
+
# ./check-snapshot.rb [-p path_to_restic] -w warn -c crit
|
19
|
+
#
|
20
|
+
# LICENSE:
|
21
|
+
# Jan Kunzmann <jan.kunzmann@erasys.de>
|
22
|
+
# Released under the same terms as Sensu (the MIT license); see LICENSE
|
23
|
+
# for details.
|
24
|
+
#
|
25
|
+
|
26
|
+
require 'json'
|
27
|
+
require 'time'
|
28
|
+
require 'sensu-plugin/check/cli'
|
29
|
+
|
30
|
+
class ResticSnapshot < Sensu::Plugin::Check::CLI
|
31
|
+
|
32
|
+
option :path,
|
33
|
+
short: '-p RESTIC_PATH',
|
34
|
+
long: '--path RESTIC_PATH',
|
35
|
+
description: 'Path to the restic client binary. Defaults to /usr/bin/restic',
|
36
|
+
default: '/usr/bin/restic'
|
37
|
+
|
38
|
+
option :missing_status,
|
39
|
+
long: '--missing-status STATUS',
|
40
|
+
description: 'Returns this exit status there there is no snapshot',
|
41
|
+
default: 'critical',
|
42
|
+
in: %w[unknown ok warning critical]
|
43
|
+
|
44
|
+
option :warning_age,
|
45
|
+
short: '-w SECONDS',
|
46
|
+
long: '--warning SECONDS',
|
47
|
+
description: 'Warn if latest snapshot is older than provided age in seconds',
|
48
|
+
proc: proc(&:to_i),
|
49
|
+
required: true
|
50
|
+
|
51
|
+
option :critical_age,
|
52
|
+
short: '-c SECONDS',
|
53
|
+
long: '--critical SECONDS',
|
54
|
+
description: 'Critical if latest snapshot is older than provided age in seconds',
|
55
|
+
proc: proc(&:to_i),
|
56
|
+
required: true
|
57
|
+
|
58
|
+
def run
|
59
|
+
snapshots = available_snapshots
|
60
|
+
if snapshots.length == 0
|
61
|
+
send(config[:missing_status], 'No backup found')
|
62
|
+
end
|
63
|
+
last_snap = Time.parse(snapshots[-1][:time])
|
64
|
+
age = (Time.now - last_snap).to_i
|
65
|
+
|
66
|
+
msg = "Last backup was at #{last_snap}"
|
67
|
+
if age >= config[:critical_age]
|
68
|
+
critical msg
|
69
|
+
elsif age >= config[:warning_age]
|
70
|
+
warning msg
|
71
|
+
else
|
72
|
+
ok msg
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
#
|
77
|
+
# Return an array of hashes with details about the snapshots
|
78
|
+
#
|
79
|
+
def available_snapshots
|
80
|
+
snapshot_info = `#{config[:path]} --json snapshots`
|
81
|
+
JSON.parse(snapshot_info, { symbolize_names: true })
|
82
|
+
end
|
83
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'sensu-plugins-restic/version'
|
metadata
ADDED
@@ -0,0 +1,257 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sensu-plugins-restic
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sensu-Plugins and contributors
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2019-10-29 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: sensu-plugin
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.15'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.15'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: github-markup
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.3'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.3'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: kitchen-docker
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.6'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.6'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: kitchen-localhost
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.3'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.3'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: mixlib-shellout
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.2'
|
90
|
+
- - "<"
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: 2.3.0
|
93
|
+
type: :development
|
94
|
+
prerelease: false
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - "~>"
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '2.2'
|
100
|
+
- - "<"
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: 2.3.0
|
103
|
+
- !ruby/object:Gem::Dependency
|
104
|
+
name: pry
|
105
|
+
requirement: !ruby/object:Gem::Requirement
|
106
|
+
requirements:
|
107
|
+
- - "~>"
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0.10'
|
110
|
+
type: :development
|
111
|
+
prerelease: false
|
112
|
+
version_requirements: !ruby/object:Gem::Requirement
|
113
|
+
requirements:
|
114
|
+
- - "~>"
|
115
|
+
- !ruby/object:Gem::Version
|
116
|
+
version: '0.10'
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: rake
|
119
|
+
requirement: !ruby/object:Gem::Requirement
|
120
|
+
requirements:
|
121
|
+
- - "~>"
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
version: '12.0'
|
124
|
+
type: :development
|
125
|
+
prerelease: false
|
126
|
+
version_requirements: !ruby/object:Gem::Requirement
|
127
|
+
requirements:
|
128
|
+
- - "~>"
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: '12.0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: redcarpet
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '3.2'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '3.2'
|
145
|
+
- !ruby/object:Gem::Dependency
|
146
|
+
name: rspec
|
147
|
+
requirement: !ruby/object:Gem::Requirement
|
148
|
+
requirements:
|
149
|
+
- - "~>"
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '3.4'
|
152
|
+
type: :development
|
153
|
+
prerelease: false
|
154
|
+
version_requirements: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - "~>"
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '3.4'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: rubocop
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - "~>"
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: 0.49.0
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - "~>"
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: 0.49.0
|
173
|
+
- !ruby/object:Gem::Dependency
|
174
|
+
name: serverspec
|
175
|
+
requirement: !ruby/object:Gem::Requirement
|
176
|
+
requirements:
|
177
|
+
- - "~>"
|
178
|
+
- !ruby/object:Gem::Version
|
179
|
+
version: 2.36.1
|
180
|
+
type: :development
|
181
|
+
prerelease: false
|
182
|
+
version_requirements: !ruby/object:Gem::Requirement
|
183
|
+
requirements:
|
184
|
+
- - "~>"
|
185
|
+
- !ruby/object:Gem::Version
|
186
|
+
version: 2.36.1
|
187
|
+
- !ruby/object:Gem::Dependency
|
188
|
+
name: test-kitchen
|
189
|
+
requirement: !ruby/object:Gem::Requirement
|
190
|
+
requirements:
|
191
|
+
- - "~>"
|
192
|
+
- !ruby/object:Gem::Version
|
193
|
+
version: '1.6'
|
194
|
+
type: :development
|
195
|
+
prerelease: false
|
196
|
+
version_requirements: !ruby/object:Gem::Requirement
|
197
|
+
requirements:
|
198
|
+
- - "~>"
|
199
|
+
- !ruby/object:Gem::Version
|
200
|
+
version: '1.6'
|
201
|
+
- !ruby/object:Gem::Dependency
|
202
|
+
name: yard
|
203
|
+
requirement: !ruby/object:Gem::Requirement
|
204
|
+
requirements:
|
205
|
+
- - "~>"
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: 0.9.11
|
208
|
+
type: :development
|
209
|
+
prerelease: false
|
210
|
+
version_requirements: !ruby/object:Gem::Requirement
|
211
|
+
requirements:
|
212
|
+
- - "~>"
|
213
|
+
- !ruby/object:Gem::Version
|
214
|
+
version: 0.9.11
|
215
|
+
description: Sensu restic plugins
|
216
|
+
email: "<jan.kunzmann@erasys.de>"
|
217
|
+
executables:
|
218
|
+
- check-restic-snapshot.rb
|
219
|
+
extensions: []
|
220
|
+
extra_rdoc_files: []
|
221
|
+
files:
|
222
|
+
- CHANGELOG.md
|
223
|
+
- LICENSE
|
224
|
+
- README.md
|
225
|
+
- bin/check-restic-snapshot.rb
|
226
|
+
- lib/sensu-plugins-restic.rb
|
227
|
+
- lib/sensu-plugins-restic/version.rb
|
228
|
+
homepage: https://github.com/erasys/sensu-plugins-restic
|
229
|
+
licenses:
|
230
|
+
- MIT
|
231
|
+
metadata:
|
232
|
+
maintainer: sensu-plugin
|
233
|
+
development_status: active
|
234
|
+
production_status: unstable - testing recommended
|
235
|
+
release_draft: 'false'
|
236
|
+
release_prerelease: 'false'
|
237
|
+
post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
|
238
|
+
in /etc/default/sensu
|
239
|
+
rdoc_options: []
|
240
|
+
require_paths:
|
241
|
+
- lib
|
242
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
243
|
+
requirements:
|
244
|
+
- - ">="
|
245
|
+
- !ruby/object:Gem::Version
|
246
|
+
version: 2.3.0
|
247
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
248
|
+
requirements:
|
249
|
+
- - ">="
|
250
|
+
- !ruby/object:Gem::Version
|
251
|
+
version: '0'
|
252
|
+
requirements: []
|
253
|
+
rubygems_version: 3.0.3
|
254
|
+
signing_key:
|
255
|
+
specification_version: 4
|
256
|
+
summary: Sensu plugins for restic backups
|
257
|
+
test_files: []
|