Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Feature: Failed Mode #7

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

New Feature: Failed Mode #7

wants to merge 8 commits into from

Conversation

Seji64
Copy link

@Seji64 Seji64 commented Jun 18, 2018

Added 'failed' Mode. This Mode checks all systemd service and reports only CRITICAL if any service has state "failed". I added the cause i wanted to monitor all my services on my linux (EL7) Hosts.

The name "failed mode" may not be the best - but I couldn't think of anything better. Maybe someone's got a better idea.

This is my first modification of a Ruby Script - hope my code is not too ugly....

Pull Request Checklist

Is this in reference to an existing issue?
No

General

  • Update Changelog following the conventions laid out here

  • Update README with any necessary configuration snippets

- [] Binstubs are created if needed

  • RuboCop passes

- [] Existing tests pass

Purpose

Known Compatibility Issues

… only CRITICAL if any service has state "failed"

This mode can be combined with '-i' to set services which should be ignored.

Example:
check-systemd.rb -f -i kdump.service
@majormoses
Copy link
Member

Thanks for your contribution to Sensu plugins! Without people like you submitting PRs we couldn't run the project. I will review it shortly.

Copy link
Member

@majormoses majormoses left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks pretty sane, can you please include a manual or automated testing artifact?

I appeased the cops for you.

@Seji64
Copy link
Author

Seji64 commented Jun 22, 2018

Thanks for fixing the cops.
I wrote a manual test artifact...did this the first time - hope its ok.
https://gist.github.com/Seji64/748548f1a47d5baf583533bfe3a83081

While writing this gist i also noticed that the 3rd test fails. I will have a look at that.

@Seji64
Copy link
Author

Seji64 commented Jun 22, 2018

I can't get the 'next if' clause. it seems like the condition after the OR is not evaluated.

next if !( @services.any? { |service| line_array[0].include?(service) } ) || ( @failed_ignore.any? { |service| line_array[0].include?(service) } && @failed == true )
      service_hash = {}
      service_hash['name'] = line_array[0]
      service_hash['load'] = line_array[1]
      service_hash['active'] = line_array[2]
      service_hash['sub'] = line_array[3]
      service_hash['description'] = line_array[4]
      service_array.push(service_hash)
    end

Maybe you could help?

@majormoses
Copy link
Member

I wrote a manual test artifact...did this the first time - hope its ok.

This is perfect.

While writing this gist i also noticed that the 3rd test fails. I will have a look at that.

If I look at the next test it shows they are not present, which matches what I have locally, if the service does indeed exist can you include the output of service pdns status?

I can't get the 'next if' clause. it seems like the condition after the OR is not evaluated.

I will take a look.

@majormoses
Copy link
Member

I am confused why is there a patch file in the PR and did you still need my help figuring the code? In the actual check I dont see that line of code which it looks like you deleted here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants