riemann-nut 1.0.0 → 1.0.2

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: f61ed52eeeb5f1be97e103f3637e2b7a176badd16efbde71431ae3bfce608338
4
- data.tar.gz: eb1e03ef41684f4e651c65fe5c66582e6969c72de0d54ede0642968e406b035e
3
+ metadata.gz: 38e773d99ac3d388b014f3c2bb483d4e2582f0c294b0d33e24d2a55ef20cf777
4
+ data.tar.gz: cac19ed5db214ee4f4fd999018713a6250f2dee7bdde61450590867842d817c0
5
5
  SHA512:
6
- metadata.gz: e4457b8cbd057b69f8f78e760b33843f24804d670ed499afac16ffe6ca21fa465f8c092031b0ffa8ab78ebe024c057e04dee44e9e395fc5607cbc7d411728fc0
7
- data.tar.gz: da71e8f350b87e68722f224f20323f102ea1ca668dbd1f6a1e263cb1748ade1096647edcd6e8d96497aedc4d50aa7a3f0411c5609f0938a3c6769ff44b35b72c
6
+ metadata.gz: 7d0285346f4b29052b7565e0e44cac861566ae877d958043a787b32de11f5c204deb64d542eda53728bae7be9a082908a7e6ffe7156d76e0b4d7d43320b2297c
7
+ data.tar.gz: a190a474838c2ed13e40f88944ab7762795fc9e6ee4389d92360766f783ef22fc871bca56c6e209bf60d641135f5400993a77e51ebe280c949360d05629ae2b7
@@ -0,0 +1,4 @@
1
+ # DO NOT EDIT THIS FILE!
2
+ # This file is managed by ModuleSync.
3
+
4
+ * @opus-codium/core
@@ -10,33 +10,42 @@ on:
10
10
  - main
11
11
 
12
12
  jobs:
13
- lint:
13
+ rubocop:
14
14
  runs-on: ubuntu-latest
15
15
  steps:
16
16
  - uses: actions/checkout@v2
17
17
  - name: Setup ruby
18
18
  uses: ruby/setup-ruby@v1
19
19
  with:
20
- ruby-version: '2.7'
20
+ ruby-version: 3.0
21
21
  bundler-cache: true
22
- - name: Run rubocop
22
+ - name: Run static code analysis
23
23
  run: bundle exec rubocop
24
- test:
25
- needs: lint
24
+ unit:
26
25
  runs-on: ubuntu-latest
26
+ needs: rubocop
27
27
  strategy:
28
28
  matrix:
29
- ruby-version:
30
- - 2.6
31
- - 2.7
32
- - 3.0
33
- - 3.1
29
+ ruby:
30
+ - "2.6"
31
+ - "2.7"
32
+ - "3.0"
33
+ - "3.1"
34
+ name: Ruby ${{ matrix.ruby }}
34
35
  steps:
35
36
  - uses: actions/checkout@v2
36
- - name: Setup Ruby
37
+ - name: Setup ruby
37
38
  uses: ruby/setup-ruby@v1
38
39
  with:
39
- ruby-version: ${{ matrix.ruby-version }}
40
+ ruby-version: ${{ matrix.ruby }}
40
41
  bundler-cache: true
41
- - name: Run the test suite
42
- run: bundle exec rspec
42
+ - name: Run tests without uploading code coverage
43
+ if: ${{ matrix.ruby != '3.0' }}
44
+ run: bundle exec rake
45
+ - name: Run tests and upload coverage to Code Climate
46
+ if: ${{ matrix.ruby == '3.0' }}
47
+ uses: paambaati/codeclimate-action@v3.0.0
48
+ env:
49
+ CC_TEST_REPORTER_ID: ${{ secrets.CODECLIMATE_TOKEN }}
50
+ with:
51
+ coverageCommand: bundle exec rake
data/.rubocop.yml CHANGED
@@ -1,7 +1,13 @@
1
1
  ---
2
2
  AllCops:
3
+ TargetRubyVersion: '2.6'
4
+ AllowSymlinksInCacheRootDirectory: true
5
+ NewCops: enable
3
6
  Exclude:
4
7
  - vendor/bundle/**/*
8
+ require:
9
+ - rubocop-rake
10
+ - rubocop-rspec
5
11
  Layout/HashAlignment:
6
12
  EnforcedHashRocketStyle: table
7
13
  Layout/LineLength:
@@ -20,6 +26,12 @@ Metrics/ParameterLists:
20
26
  Enabled: false
21
27
  Metrics/PerceivedComplexity:
22
28
  Enabled: false
29
+ RSpec/ExampleLength:
30
+ Enabled: false
31
+ RSpec/NamedSubject:
32
+ Enabled: false
33
+ RSpec/SubjectStub:
34
+ Enabled: false
23
35
  Style/Documentation:
24
36
  Enabled: false
25
37
  Style/TrailingCommaInArguments:
data/.simplecov ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # vim:set syntax=ruby:
4
+
5
+ SimpleCov.start do
6
+ add_filter '/spec/'
7
+ end
data/CHANGELOG.md ADDED
@@ -0,0 +1,22 @@
1
+ # Changelog
2
+
3
+ ## [1.0.2](https://github.com/opus-codium/riemann-nut/tree/1.0.2) (2022-09-19)
4
+
5
+ [Full Changelog](https://github.com/opus-codium/riemann-nut/compare/v1.0.1...1.0.2)
6
+
7
+ **Fixed bugs:**
8
+
9
+ - Do not report missing metrics as critical [\#3](https://github.com/opus-codium/riemann-nut/pull/3) ([smortex](https://github.com/smortex))
10
+
11
+ ## [v1.0.1](https://github.com/opus-codium/riemann-nut/tree/v1.0.1) (2022-08-08)
12
+
13
+ [Full Changelog](https://github.com/opus-codium/riemann-nut/compare/v1.0.0...v1.0.1)
14
+
15
+ **Fixed bugs:**
16
+
17
+ - Do not report an alarm if none is set [\#2](https://github.com/opus-codium/riemann-nut/pull/2) ([smortex](https://github.com/smortex))
18
+ - Report charge when no threshold is set [\#1](https://github.com/opus-codium/riemann-nut/pull/1) ([smortex](https://github.com/smortex))
19
+
20
+
21
+
22
+ \* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
data/Rakefile CHANGED
@@ -3,6 +3,11 @@
3
3
  require 'riemann/tools/nut/version'
4
4
 
5
5
  require 'bundler/gem_tasks'
6
+ require 'rspec/core/rake_task'
7
+
8
+ RSpec::Core::RakeTask.new(:spec)
9
+
10
+ task default: :spec
6
11
 
7
12
  require 'github_changelog_generator/task'
8
13
 
@@ -11,4 +16,5 @@ GitHubChangelogGenerator::RakeTask.new :changelog do |config|
11
16
  config.project = 'riemann-nut'
12
17
  config.exclude_labels = ['skip-changelog']
13
18
  config.future_release = Riemann::Tools::Nut::VERSION
19
+ config.since_tag = 'v1.0.0'
14
20
  end
@@ -3,7 +3,7 @@
3
3
  module Riemann
4
4
  module Tools # :nodoc:
5
5
  class Nut
6
- VERSION = '1.0.0'
6
+ VERSION = '1.0.2'
7
7
  end
8
8
  end
9
9
  end
@@ -58,9 +58,9 @@ module Riemann
58
58
  opts[:ups].each do |ups|
59
59
  service = "#{ups} battery charge"
60
60
  battery_charge = Integer(upsc[ups]['battery.charge'])
61
- battery_state = if battery_charge < Integer(upsc[ups]['battery.charge.low'])
61
+ battery_state = if battery_charge < upsc[ups]['battery.charge.low'].to_i
62
62
  'critical'
63
- elsif battery_charge < Integer(upsc[ups]['battery.charge.warning'])
63
+ elsif battery_charge < upsc[ups]['battery.charge.warning'].to_i
64
64
  'warning'
65
65
  else
66
66
  'ok'
@@ -82,6 +82,8 @@ module Riemann
82
82
 
83
83
  def report_battery_voltage
84
84
  opts[:ups].each do |ups|
85
+ next unless upsc[ups]['battery.voltage']
86
+
85
87
  service = "#{ups} battery voltage"
86
88
  battery_voltage = Float(upsc[ups]['battery.voltage'])
87
89
 
@@ -91,16 +93,19 @@ module Riemann
91
93
  state: 'ok',
92
94
  description: "#{battery_voltage} V",
93
95
  )
94
- rescue TypeError
96
+ rescue TypeError => e
95
97
  report(
96
98
  service: service,
97
99
  state: 'critical',
100
+ description: e.message,
98
101
  )
99
102
  end
100
103
  end
101
104
 
102
105
  def report_input_voltage
103
106
  opts[:ups].each do |ups|
107
+ next unless upsc[ups]['input.voltage']
108
+
104
109
  service = "#{ups} input voltage"
105
110
  input_voltage = Float(upsc[ups]['input.voltage'])
106
111
 
@@ -110,16 +115,19 @@ module Riemann
110
115
  state: 'ok',
111
116
  description: "#{input_voltage} V",
112
117
  )
113
- rescue TypeError
118
+ rescue TypeError => e
114
119
  report(
115
120
  service: service,
116
121
  state: 'critical',
122
+ description: e.message,
117
123
  )
118
124
  end
119
125
  end
120
126
 
121
127
  def report_ups_alarm
122
128
  opts[:ups].each do |ups|
129
+ next unless upsc[ups]['ups.alarm']
130
+
123
131
  report(
124
132
  service: "#{ups} ups alarm",
125
133
  state: 'critical',
@@ -146,10 +154,11 @@ module Riemann
146
154
  state: ups_state,
147
155
  description: "#{ups_load} W",
148
156
  )
149
- rescue TypeError
157
+ rescue TypeError => e
150
158
  report(
151
159
  service: service,
152
160
  state: 'critical',
161
+ description: e.message,
153
162
  )
154
163
  end
155
164
  end
data/riemann-nut.gemspec CHANGED
@@ -19,6 +19,8 @@ Gem::Specification.new do |spec|
19
19
  spec.metadata['source_code_uri'] = spec.homepage
20
20
  spec.metadata['changelog_uri'] = spec.homepage
21
21
 
22
+ spec.metadata['rubygems_mfa_required'] = 'true'
23
+
22
24
  # Specify which files should be added to the gem when it is released.
23
25
  # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
24
26
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
@@ -36,4 +38,5 @@ Gem::Specification.new do |spec|
36
38
  spec.add_development_dependency 'rubocop'
37
39
  spec.add_development_dependency 'rubocop-rake'
38
40
  spec.add_development_dependency 'rubocop-rspec'
41
+ spec.add_development_dependency 'simplecov'
39
42
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: riemann-nut
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.2
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-07-26 00:00:00.000000000 Z
11
+ date: 2022-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: riemann-tools
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: simplecov
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  description:
112
126
  email:
113
127
  - romain@blogreen.org
@@ -116,10 +130,13 @@ executables:
116
130
  extensions: []
117
131
  extra_rdoc_files: []
118
132
  files:
133
+ - ".github/CODEOWNERS"
119
134
  - ".github/workflows/ci.yml"
120
135
  - ".gitignore"
121
136
  - ".rspec"
122
137
  - ".rubocop.yml"
138
+ - ".simplecov"
139
+ - CHANGELOG.md
123
140
  - Gemfile
124
141
  - README.md
125
142
  - Rakefile
@@ -135,6 +152,7 @@ metadata:
135
152
  homepage_uri: https://github.com/opus-codium/riemann-nut
136
153
  source_code_uri: https://github.com/opus-codium/riemann-nut
137
154
  changelog_uri: https://github.com/opus-codium/riemann-nut
155
+ rubygems_mfa_required: 'true'
138
156
  post_install_message:
139
157
  rdoc_options: []
140
158
  require_paths:
@@ -150,7 +168,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
150
168
  - !ruby/object:Gem::Version
151
169
  version: '0'
152
170
  requirements: []
153
- rubygems_version: 3.3.17
171
+ rubygems_version: 3.3.22
154
172
  signing_key:
155
173
  specification_version: 4
156
174
  summary: Submits nut information to riemann