Skip to content

Commit 9487675

Browse files
authored
Merge pull request #2 from jgnagy/bugfix/alert-on-missing-services
Complaining about missing services
2 parents cd06be7 + a62fdd1 commit 9487675

2 files changed

Lines changed: 19 additions & 4 deletions

File tree

Rakefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@ require 'yard/rake/yardoc_task'
99
desc 'Don\'t run Rubocop for unsupported versions'
1010
begin
1111
args = if RUBY_VERSION >= '2.0.0'
12-
[:spec, :make_bin_executable, :yard, :rubocop, :check_binstubs]
12+
%i[spec make_bin_executable yard rubocop check_binstubs]
1313
else
14-
[:spec, :make_bin_executable, :yard]
14+
%i[spec make_bin_executable yard]
1515
end
1616
end
1717

1818
YARD::Rake::YardocTask.new do |t|
19-
OTHER_PATHS = %w().freeze
19+
OTHER_PATHS = %w[].freeze
2020
t.files = ['lib/**/*.rb', 'bin/**/*.rb', OTHER_PATHS]
21-
t.options = %w(--markup-provider=redcarpet --markup=markdown --main=README.md --files CHANGELOG.md)
21+
t.options = %w[--markup-provider=redcarpet --markup=markdown --main=README.md --files CHANGELOG.md]
2222
end
2323

2424
RuboCop::RakeTask.new

bin/check-systemd.rb

100644100755
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,13 @@ def initialize
4141
@crit_service = []
4242
end
4343

44+
def all_service_names
45+
systemd_output = `systemctl --no-legend`
46+
systemd_output.split("\n").collect do |line|
47+
line.split(' ').first
48+
end
49+
end
50+
4451
def unit_services
4552
systemd_output = `systemctl --failed --no-legend`
4653
service_array = []
@@ -59,6 +66,10 @@ def unit_services
5966
end
6067

6168
def check_systemd
69+
@services.reject { |service| validate_presence_of(service) }.each do |gone|
70+
@crit_service << "#{gone} - Not Present"
71+
end
72+
6273
unit_services.each do |service|
6374
if service['active'] != 'active'
6475
@crit_service << "#{service['name']} - #{service['active']}"
@@ -72,6 +83,10 @@ def service_summary
7283
@crit_service.join(', ')
7384
end
7485

86+
def validate_presence_of(service)
87+
all_service_names.include?(service)
88+
end
89+
7590
def run
7691
check_systemd
7792
critical service_summary unless @crit_service.empty?

0 commit comments

Comments
 (0)