bipbip 0.7.19 → 0.7.20

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
  SHA1:
3
- metadata.gz: 1e272fc463e770c79d01fd9e30183d2846142a37
4
- data.tar.gz: 9f3e612b9879b8fda84c5cf737e2301d3d1695a0
3
+ metadata.gz: 90e8c71cebad832f0d96d828e0abefb250dba0ad
4
+ data.tar.gz: 3a2695000f9f91f6b7557bd08e9c2f01611709f9
5
5
  SHA512:
6
- metadata.gz: cadf7109ef21c7b8470081d62fd88d62fd8f1e2b210be002ce39afd9cae05492c51fda824b0a2de84728f15565ef915aa82093e3de8a73a3c772b2fd159162c0
7
- data.tar.gz: a738a759be9fbf930e180fcc8925ef3af9ea23a73f0cbb7afe671999f8c284b91fa1e96144f7b3d5ad194e1e3187b38c98216ba45c45c1433d3b3a423ddbc0dd
6
+ metadata.gz: 1bb14231582c6e2a176df2ff1de446ca9df55cda5084b0aa973e72c07518aa09521aa03676758c3da15101b78d4e3859e019dd70f386750cd6092d8bda507f35
7
+ data.tar.gz: 4648dcc12942ba1f5f0532440a18a39751abf981533333aa56ed2080d4c6e09b7b0f7f4bb31ab98bde6867e2acad680ce0bd38c437eb40ba9c8ad01b95ad0258
@@ -6,13 +6,39 @@ module Bipbip
6
6
  class Plugin::SystemdUnit < Plugin
7
7
  def metrics_schema
8
8
  [
9
- { name: 'all_units_running', type: 'gauge', unit: 'Boolean' }
9
+ { name: 'all_units_active', type: 'gauge', unit: 'Boolean' },
10
+ { name: 'any_unit_failed', type: 'gauge', unit: 'Boolean' },
11
+ { name: 'any_unit_stopped', type: 'gauge', unit: 'Boolean' }
10
12
  ]
11
13
  end
12
14
 
13
15
  def monitor
14
16
  main_unit = config['unit_name']
15
- { 'all_units_running' => unit_dependencies(main_unit).all? { |unit| unit_is_active(unit) } ? 1 : 0 }
17
+ failed_units = []
18
+ stopped_units = []
19
+ status_list = unit_dependencies(main_unit).map do |unit|
20
+ is_active = unit_is_active(unit)
21
+ is_failed = unit_is_failed(unit)
22
+ is_stopped = !is_active && !is_failed
23
+
24
+ failed_units.push(unit) if is_failed
25
+ stopped_units.push(unit) if is_stopped
26
+ {
27
+ name: unit,
28
+ is_active: is_active,
29
+ is_failed: is_failed,
30
+ is_stopped: is_stopped
31
+ }
32
+ end
33
+
34
+ log(Logger::WARN, "#{main_unit} unit failed: #{failed_units.join(', ')}") unless failed_units.empty?
35
+ log(Logger::WARN, "#{main_unit} unit stopped: #{stopped_units.join(', ')}") unless stopped_units.empty?
36
+
37
+ {
38
+ 'all_units_active' => (status_list.all? { |status| status[:is_active] } ? 1 : 0),
39
+ 'any_unit_failed' => (status_list.any? { |status| status[:is_failed] } ? 1 : 0),
40
+ 'any_unit_stopped' => (status_list.any? { |status| status[:is_stopped] } ? 1 : 0)
41
+ }
16
42
  end
17
43
 
18
44
  # @param [String] main_unit
@@ -29,5 +55,11 @@ module Bipbip
29
55
  def unit_is_active(unit)
30
56
  Komenda.run(['systemctl', 'is-active', unit]).success?
31
57
  end
58
+
59
+ # @param [String] unit
60
+ # @return [TrueClass, FalseClass]
61
+ def unit_is_failed(unit)
62
+ Komenda.run(['systemctl', 'is-failed', unit]).success?
63
+ end
32
64
  end
33
65
  end
@@ -1,3 +1,3 @@
1
1
  module Bipbip
2
- VERSION = '0.7.19'.freeze
2
+ VERSION = '0.7.20'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bipbip
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.19
4
+ version: 0.7.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cargo Media
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-07-12 00:00:00.000000000 Z
13
+ date: 2017-09-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: copperegg-revealmetrics
@@ -358,7 +358,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
358
358
  version: '0'
359
359
  requirements: []
360
360
  rubyforge_project:
361
- rubygems_version: 2.2.2
361
+ rubygems_version: 2.6.12
362
362
  signing_key:
363
363
  specification_version: 4
364
364
  summary: Gather services data and store in CopperEgg