Skip to content

Commit

Permalink
Merge pull request #2 from jgnagy/bugfix/alert-on-missing-services
Browse files Browse the repository at this point in the history
Complaining about missing services
  • Loading branch information
mickfeech authored Apr 26, 2017
2 parents cd06be7 + a62fdd1 commit 9487675
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@ require 'yard/rake/yardoc_task'
desc 'Don\'t run Rubocop for unsupported versions'
begin
args = if RUBY_VERSION >= '2.0.0'
[:spec, :make_bin_executable, :yard, :rubocop, :check_binstubs]
%i[spec make_bin_executable yard rubocop check_binstubs]
else
[:spec, :make_bin_executable, :yard]
%i[spec make_bin_executable yard]
end
end

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

RuboCop::RakeTask.new
Expand Down
15 changes: 15 additions & 0 deletions bin/check-systemd.rb
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@ def initialize
@crit_service = []
end

def all_service_names
systemd_output = `systemctl --no-legend`
systemd_output.split("\n").collect do |line|
line.split(' ').first
end
end

def unit_services
systemd_output = `systemctl --failed --no-legend`
service_array = []
Expand All @@ -59,6 +66,10 @@ def unit_services
end

def check_systemd
@services.reject { |service| validate_presence_of(service) }.each do |gone|
@crit_service << "#{gone} - Not Present"
end

unit_services.each do |service|
if service['active'] != 'active'
@crit_service << "#{service['name']} - #{service['active']}"
Expand All @@ -72,6 +83,10 @@ def service_summary
@crit_service.join(', ')
end

def validate_presence_of(service)
all_service_names.include?(service)
end

def run
check_systemd
critical service_summary unless @crit_service.empty?
Expand Down

0 comments on commit 9487675

Please sign in to comment.