riemann-bacula 1.0.0 → 1.2.0

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: 8259d6fb194ccf10cd5acb756a66b2a22e1f310ed75a081f54cadcf8f7e80e99
4
- data.tar.gz: 7ea103923b9966074450861224946190f52cdabc766f0dcb2a4fd76f5f3c8de1
3
+ metadata.gz: d6352841033d7fa669793cba957a59cc4fa35369d2866914dbb782bb3b507f97
4
+ data.tar.gz: 66826e73f558d5f2c788d0a5b3b60a413b420f76e47957a517727f51ae7ec15c
5
5
  SHA512:
6
- metadata.gz: c8dff17ef2cb421f7a799755247190edfdfe39242bd55a0ce9f268109f157b7a94acc138252ea0a3e20c00d7f8b9e9be9f212e5708a0ba5464087e1aa457fb25
7
- data.tar.gz: 03b0c38ded3a57c297435ec6f16c1b766303eee451311b3c29c141d81b70d184ac616fe8f91171663a0f1b3cfbe753e439e1044123cf4fd5ee99d76f36a04633
6
+ metadata.gz: 3d1888b9a7920c0dab4b5c3c30ae8b06acf5ed8e54eaa70e6e848db3ff1dd1087282b42b2a0be1a857935e6497ff662e445383c2be07276a033d7a1ce84fb042
7
+ data.tar.gz: 74117f74b1181b5d619e27d04f888627ee1d212a9fc66aa78a657374847f8fad9a3b1c999976126db5fab600ef5698a9b699b4d562997a39bbc6940bd3850acb
@@ -44,7 +44,7 @@ jobs:
44
44
  run: bundle exec rake
45
45
  - name: Run tests and upload coverage to Code Climate
46
46
  if: ${{ matrix.ruby == '3.0' }}
47
- uses: paambaati/codeclimate-action@v3.0.0
47
+ uses: paambaati/codeclimate-action@v3.1.1
48
48
  env:
49
49
  CC_TEST_REPORTER_ID: ${{ secrets.CODECLIMATE_TOKEN }}
50
50
  with:
data/CHANGELOG.md ADDED
@@ -0,0 +1,26 @@
1
+ # Changelog
2
+
3
+ ## [v1.2.0](https://github.com/opus-codium/riemann-bacula/tree/v1.2.0) (2022-10-27)
4
+
5
+ [Full Changelog](https://github.com/opus-codium/riemann-bacula/compare/v1.1.0...v1.2.0)
6
+
7
+ **Implemented enhancements:**
8
+
9
+ - Embed more metadata in events [\#5](https://github.com/opus-codium/riemann-bacula/pull/5) ([smortex](https://github.com/smortex))
10
+
11
+ ## [v1.1.0](https://github.com/opus-codium/riemann-bacula/tree/v1.1.0) (2022-10-20)
12
+
13
+ [Full Changelog](https://github.com/opus-codium/riemann-bacula/compare/v1.0.0...v1.1.0)
14
+
15
+ **Implemented enhancements:**
16
+
17
+ - Join wrapped lines [\#3](https://github.com/opus-codium/riemann-bacula/pull/3) ([smortex](https://github.com/smortex))
18
+ - Add support for parsing restore reports [\#1](https://github.com/opus-codium/riemann-bacula/pull/1) ([smortex](https://github.com/smortex))
19
+
20
+ **Fixed bugs:**
21
+
22
+ - Fix parsing of backups of TB of data [\#2](https://github.com/opus-codium/riemann-bacula/pull/2) ([smortex](https://github.com/smortex))
23
+
24
+
25
+
26
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/README.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # riemann-bacula
2
2
 
3
+ [![CI](https://github.com/opus-codium/riemann-bacula/actions/workflows/ci.yml/badge.svg)](https://github.com/opus-codium/riemann-bacula/actions/workflows/ci.yml)
4
+ [![Maintainability](https://api.codeclimate.com/v1/badges/d4206bbc680dc822194b/maintainability)](https://codeclimate.com/github/opus-codium/riemann-bacula/maintainability)
5
+ [![Test Coverage](https://api.codeclimate.com/v1/badges/d4206bbc680dc822194b/test_coverage)](https://codeclimate.com/github/opus-codium/riemann-bacula/test_coverage)
6
+
3
7
  Submits bacula information to riemann.
4
8
 
5
9
  ## Get started
data/Rakefile CHANGED
@@ -15,5 +15,6 @@ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
15
15
  config.user = 'opus-codium'
16
16
  config.project = 'riemann-bacula'
17
17
  config.exclude_labels = ['skip-changelog']
18
- config.future_release = Riemann::Tools::Bacula::VERSION
18
+ config.future_release = "v#{Riemann::Tools::Bacula::VERSION}"
19
+ config.since_tag = 'v1.0.0'
19
20
  end
@@ -3,7 +3,7 @@
3
3
  module Riemann
4
4
  module Tools # :nodoc:
5
5
  class Bacula
6
- VERSION = '1.0.0'
6
+ VERSION = '1.2.0'
7
7
  end
8
8
  end
9
9
  end
@@ -23,16 +23,24 @@ module Riemann
23
23
 
24
24
  def parse(text)
25
25
  data = {}
26
+ line_continuation = nil
26
27
 
27
28
  text.each_line do |line|
28
29
  line.chomp!
29
30
 
30
- next unless line =~ /\A ([^:]+):[[:blank:]]+(.*)/
31
+ if line =~ /\A ([^:]+):[[:blank:]]+(.*)/
32
+ key = Regexp.last_match(1)
33
+ raw_value = Regexp.last_match(2)
31
34
 
32
- key = Regexp.last_match(1)
33
- raw_value = Regexp.last_match(2)
35
+ data[key] = raw_value
36
+ elsif line_continuation
37
+ key = line_continuation
38
+ data[key] += ".#{line}"
39
+ else
40
+ next
41
+ end
34
42
 
35
- data[key] = raw_value
43
+ line_continuation = (key if line.length == 998)
36
44
  end
37
45
 
38
46
  return nil unless valid?(data)
@@ -53,16 +61,20 @@ module Riemann
53
61
  'FD Bytes Written',
54
62
  'SD Bytes Written',
55
63
  'Last Volume Bytes',
64
+ 'Bytes Restored',
56
65
  ],
57
66
  parse_integer: [
58
67
  'JobId',
59
68
  'Priority',
60
69
  'Non-fatal FD errors',
61
70
  'FD Files Written',
71
+ 'FD Errors',
62
72
  'SD Files Written',
63
73
  'SD Errors',
64
74
  'Volume Session Id',
65
75
  'Volume Session Time',
76
+ 'Files Expected',
77
+ 'Files Restored',
66
78
  ],
67
79
  parse_duration: [
68
80
  'Elapsed time',
@@ -108,7 +120,7 @@ module Riemann
108
120
  end
109
121
 
110
122
  def extract_client_info(data)
111
- /\A"([^"]+)" ([^ ]+)/.match(data['Client'])
123
+ return unless /\A"([^"]+)" ([^ ]+)/.match(data['Client'])
112
124
 
113
125
  data['Client'] = Regexp.last_match(1)
114
126
  data['Client Version'] = Regexp.last_match(2)
@@ -119,14 +131,14 @@ module Riemann
119
131
  end
120
132
 
121
133
  def extract_source(item, data)
122
- /\A"([^"]+)" \(From (Client|Job|Pool) resource\)\z/.match(data[item])
134
+ return unless /\A"([^"]+)" \(From (Client|Job|Pool) resource\)\z/.match(data[item])
123
135
 
124
136
  data[item] = Regexp.last_match(1)
125
137
  data["#{item} Source"] = Regexp.last_match(2)
126
138
  end
127
139
 
128
140
  def extract_time(item, data)
129
- /\A"([^"]+)" (.*)\z/.match(data[item])
141
+ return unless /\A"([^"]+)" (.*)\z/.match(data[item])
130
142
 
131
143
  data[item] = Regexp.last_match(1)
132
144
  data["#{item} time"] = Regexp.last_match(2)
@@ -168,7 +180,8 @@ module Riemann
168
180
  end
169
181
 
170
182
  def parse_size(value)
171
- /\A([\d,]+) \([\d.]+ [KMG]?B\)\z/.match(value)
183
+ raise ArgumentError, %(Cannot parse size "#{value}") unless /\A([\d,]+) \([\d.]+ [KMGT]?B\)\z/.match(value)
184
+
172
185
  parse_integer(Regexp.last_match(1))
173
186
  end
174
187
 
@@ -180,12 +193,14 @@ module Riemann
180
193
  event = {}
181
194
  event[:service] = "bacula backup #{data['Job Name']}"
182
195
  event[:state] = case data['Termination']
183
- when 'Backup OK' then 'ok'
196
+ when /\A(Backup|Restore) OK\z/ then 'ok'
184
197
  when 'Backup OK -- with warnings' then 'warning'
185
198
  else
186
199
  'critical'
187
200
  end
188
201
  event[:description] = data['Termination']
202
+ event[:job_name] = data['Job Name']
203
+ event[:backup_level] = data['Backup Level']
189
204
  report(event)
190
205
 
191
206
  return unless options[:details]
@@ -205,6 +220,8 @@ module Riemann
205
220
  event = {}
206
221
  event[:service] = "bacula backup #{data['Job Name']} #{data['Backup Level'].downcase} #{metric.downcase}"
207
222
  event[:metric] = data[metric]
223
+ event[:job_name] = data['Job Name']
224
+ event[:backup_level] = data['Backup Level']
208
225
  report(event)
209
226
  end
210
227
  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: 1.0.0
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Romain Tartière
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-14 00:00:00.000000000 Z
11
+ date: 2022-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: riemann-tools
@@ -136,6 +136,7 @@ files:
136
136
  - ".rspec"
137
137
  - ".rubocop.yml"
138
138
  - ".simplecov"
139
+ - CHANGELOG.md
139
140
  - Gemfile
140
141
  - README.md
141
142
  - Rakefile