riemann-bacula 1.2.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/CODEOWNERS +1 -4
- data/CHANGELOG.md +12 -0
- data/README.md +1 -1
- data/lib/riemann/tools/bacula/version.rb +1 -1
- data/lib/riemann/tools/bacula.rb +54 -39
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c7c2bdcd4f13414f04163482d874341b8771dbff7ecb84fe2c96d68ec75e8553
|
4
|
+
data.tar.gz: 22a3eb9612eeec5727e800a915dc534d47978baf7b055425efe0f24c13966c7c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cd99cf77b7e0ca07f2d8d4d48f408cdf7a134ff9e2f43ac512e5ddc9b75cc54dda3c120583983a32ca3d1824da2cf68df3ebfd4ded7efd75f6bdb9fbd11d382
|
7
|
+
data.tar.gz: 6929197169f1a28d3bfcf094120f8adde8a289a2e8cc2f89ca07a1b8659e1757c0f935488de75274d72a21fe9418365eb1d676a1a3b395b6e340d7b3334f2ce8
|
data/.github/CODEOWNERS
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## [v2.0.0](https://github.com/opus-codium/riemann-bacula/tree/v2.0.0) (2022-11-14)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/opus-codium/riemann-bacula/compare/v1.2.0...v2.0.0)
|
6
|
+
|
7
|
+
**Breaking changes:**
|
8
|
+
|
9
|
+
- Add parameters and make them mandatory [\#7](https://github.com/opus-codium/riemann-bacula/pull/7) ([smortex](https://github.com/smortex))
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Fix how we set the host of bacula events [\#8](https://github.com/opus-codium/riemann-bacula/pull/8) ([smortex](https://github.com/smortex))
|
14
|
+
|
3
15
|
## [v1.2.0](https://github.com/opus-codium/riemann-bacula/tree/v1.2.0) (2022-10-27)
|
4
16
|
|
5
17
|
[Full Changelog](https://github.com/opus-codium/riemann-bacula/compare/v1.1.0...v1.2.0)
|
data/README.md
CHANGED
@@ -17,7 +17,7 @@ In your Bacula Director configuration, add a Message resource like this (the pro
|
|
17
17
|
```
|
18
18
|
Messages {
|
19
19
|
Name = Standard
|
20
|
-
MailCommand = "riemann-bacula"
|
20
|
+
MailCommand = "riemann-bacula --event-host \"%h\" --job-name \"%n\" --backup-level \"%l\" --status \"%e\" --bytes \"%b\" --files \"%F\""
|
21
21
|
Mail = sysadmin@example.com = all, !skipped
|
22
22
|
}
|
23
23
|
```
|
data/lib/riemann/tools/bacula.rb
CHANGED
@@ -9,16 +9,54 @@ module Riemann
|
|
9
9
|
class Bacula
|
10
10
|
include Riemann::Tools
|
11
11
|
|
12
|
-
opt :
|
12
|
+
opt :job_name, 'Job name (%n)', short: :none, type: :string
|
13
|
+
opt :backup_level, 'Job Level (%l)', short: :none, type: :string
|
14
|
+
opt :status, 'Job Exit Status (%e)', short: :none, type: :string
|
15
|
+
|
16
|
+
opt :bytes, 'Job Bytes (%b)', short: :none, type: :integer
|
17
|
+
opt :files, 'Job Files (%F)', short: :none, type: :integer
|
18
|
+
|
19
|
+
opt :details, 'Send detailed metrics beyond overall status', short: :none, default: true
|
13
20
|
|
14
21
|
def self.process_stdin
|
15
22
|
new.process_stdin
|
16
23
|
end
|
17
24
|
|
18
25
|
def run
|
19
|
-
|
26
|
+
%i[job_name backup_level status].each do |name|
|
27
|
+
raise("Parameter #{name} is required") unless opts[name]
|
28
|
+
end
|
29
|
+
|
20
30
|
data = parse($stdin.read)
|
21
|
-
|
31
|
+
|
32
|
+
report({
|
33
|
+
service: "bacula backup #{opts[:job_name]}",
|
34
|
+
state: bacula_backup_state,
|
35
|
+
job_name: opts[:job_name],
|
36
|
+
backup_level: opts[:backup_level],
|
37
|
+
description: data['Termination'],
|
38
|
+
})
|
39
|
+
|
40
|
+
%i[bytes files].each do |metric|
|
41
|
+
next unless opts[metric]
|
42
|
+
|
43
|
+
report({
|
44
|
+
service: "bacula backup #{opts[:job_name]} #{opts[:backup_level].downcase} #{metric}",
|
45
|
+
metric: opts[metric],
|
46
|
+
job_name: opts[:job_name],
|
47
|
+
backup_level: opts[:backup_level],
|
48
|
+
})
|
49
|
+
end
|
50
|
+
|
51
|
+
send_details(data) if options[:details]
|
52
|
+
end
|
53
|
+
|
54
|
+
def bacula_backup_state
|
55
|
+
case opts[:status]
|
56
|
+
when 'OK' then 'ok'
|
57
|
+
else
|
58
|
+
'critical'
|
59
|
+
end
|
22
60
|
end
|
23
61
|
|
24
62
|
def parse(text)
|
@@ -43,19 +81,14 @@ module Riemann
|
|
43
81
|
line_continuation = (key if line.length == 998)
|
44
82
|
end
|
45
83
|
|
46
|
-
return nil unless valid?(data)
|
47
|
-
|
48
84
|
enhance(data)
|
49
85
|
end
|
50
86
|
|
51
|
-
def valid?(data)
|
52
|
-
%w[
|
53
|
-
Job
|
54
|
-
Termination
|
55
|
-
].all? { |key| data.key?(key) }
|
56
|
-
end
|
57
|
-
|
58
87
|
def enhance(data)
|
88
|
+
# If the message on stdin was trucated, the last item might not make
|
89
|
+
# sense.
|
90
|
+
data.delete(data.keys.last) if data.keys.last != 'Termination'
|
91
|
+
|
59
92
|
{
|
60
93
|
parse_size: [
|
61
94
|
'FD Bytes Written',
|
@@ -103,7 +136,6 @@ module Riemann
|
|
103
136
|
|
104
137
|
extract_client_info(data)
|
105
138
|
extract_backup_level_info(data)
|
106
|
-
extract_job_name(data)
|
107
139
|
|
108
140
|
data
|
109
141
|
end
|
@@ -126,10 +158,6 @@ module Riemann
|
|
126
158
|
data['Client Version'] = Regexp.last_match(2)
|
127
159
|
end
|
128
160
|
|
129
|
-
def extract_job_name(data)
|
130
|
-
data['Job Name'] = data['Job'].sub(/\.\d{4}-\d{2}-\d{2}_\d{2}\.\d{2}\.\d{2}_\d{2}\z/, '')
|
131
|
-
end
|
132
|
-
|
133
161
|
def extract_source(item, data)
|
134
162
|
return unless /\A"([^"]+)" \(From (Client|Job|Pool) resource\)\z/.match(data[item])
|
135
163
|
|
@@ -189,22 +217,7 @@ module Riemann
|
|
189
217
|
value.split('|')
|
190
218
|
end
|
191
219
|
|
192
|
-
def
|
193
|
-
event = {}
|
194
|
-
event[:service] = "bacula backup #{data['Job Name']}"
|
195
|
-
event[:state] = case data['Termination']
|
196
|
-
when /\A(Backup|Restore) OK\z/ then 'ok'
|
197
|
-
when 'Backup OK -- with warnings' then 'warning'
|
198
|
-
else
|
199
|
-
'critical'
|
200
|
-
end
|
201
|
-
event[:description] = data['Termination']
|
202
|
-
event[:job_name] = data['Job Name']
|
203
|
-
event[:backup_level] = data['Backup Level']
|
204
|
-
report(event)
|
205
|
-
|
206
|
-
return unless options[:details]
|
207
|
-
|
220
|
+
def send_details(data)
|
208
221
|
[
|
209
222
|
'Elapsed time',
|
210
223
|
'FD Files Written',
|
@@ -217,12 +230,14 @@ module Riemann
|
|
217
230
|
'Comm Line Compression',
|
218
231
|
'Non-fatal FD errors',
|
219
232
|
].each do |metric|
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
233
|
+
next unless data[metric]
|
234
|
+
|
235
|
+
report({
|
236
|
+
service: "bacula backup #{opts[:job_name]} #{opts[:backup_level].downcase} #{metric.downcase}",
|
237
|
+
metric: data[metric],
|
238
|
+
job_name: opts[:job_name],
|
239
|
+
backup_level: opts[:backup_level],
|
240
|
+
})
|
226
241
|
end
|
227
242
|
end
|
228
243
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: riemann-bacula
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Romain Tartière
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-11-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: riemann-tools
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
-
description:
|
125
|
+
description:
|
126
126
|
email:
|
127
127
|
- romain@blogreen.org
|
128
128
|
executables:
|
@@ -153,7 +153,7 @@ metadata:
|
|
153
153
|
source_code_uri: https://github.com/opus-codium/riemann-bacula
|
154
154
|
changelog_uri: https://github.com/opus-codium/riemann-bacula
|
155
155
|
rubygems_mfa_required: 'true'
|
156
|
-
post_install_message:
|
156
|
+
post_install_message:
|
157
157
|
rdoc_options: []
|
158
158
|
require_paths:
|
159
159
|
- lib
|
@@ -168,8 +168,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
168
168
|
- !ruby/object:Gem::Version
|
169
169
|
version: '0'
|
170
170
|
requirements: []
|
171
|
-
rubygems_version: 3.
|
172
|
-
signing_key:
|
171
|
+
rubygems_version: 3.3.23
|
172
|
+
signing_key:
|
173
173
|
specification_version: 4
|
174
174
|
summary: Submits bacula information to riemann
|
175
175
|
test_files: []
|