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 +4 -4
- data/lib/bipbip/plugin/systemd_unit.rb +34 -2
- data/lib/bipbip/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90e8c71cebad832f0d96d828e0abefb250dba0ad
|
4
|
+
data.tar.gz: 3a2695000f9f91f6b7557bd08e9c2f01611709f9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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: '
|
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
|
-
|
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
|
data/lib/bipbip/version.rb
CHANGED
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.
|
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-
|
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.
|
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
|