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

sshd check in redhat 9.X fails even though sshd is running #151

Open
kdalenberg opened this issue Aug 27, 2024 · 5 comments
Open

sshd check in redhat 9.X fails even though sshd is running #151

kdalenberg opened this issue Aug 27, 2024 · 5 comments
Assignees

Comments

@kdalenberg
Copy link

The standard check: * || check_ps_service -u root -S sshd

Fails in redhat 9 when sshd service is enabled and running. Debug shows:

[1724788959] - DEBUG: Checking 67117: "*sshd" vs. "sshd:"
[1724788959] - DEBUG: Glob match check: sshd: does not match *sshd

@mej
Copy link
Owner

mej commented Sep 5, 2024

The check_ps_service() check has an option, -m, which allows you to specify your own match string in lieu of the default behavior (which is to match any command whose argv[0] ends with the name of the specified service -- hence the *sshd it's using in your example above).

You might try check_ps_service -u root -m 'sshd:' -S sshd or check_ps_service -u root -m '/^sshd:?$/' -S sshd

@mej mej self-assigned this Sep 5, 2024
@griznog
Copy link

griznog commented Sep 8, 2024 via email

@kdalenberg
Copy link
Author

kdalenberg commented Sep 10, 2024 via email

@mej
Copy link
Owner

mej commented Sep 12, 2024

I've started doing all my service checks via systemctl, e.g.

 * || check_cmd_output -t 2 -r 0 /usr/bin/systemctl is-active sssd

Having a dozen of these doesn't seem to make a meaningful difference to how long my check runs. I've also been thinking about writing a custom health check function that takes a list of services and checks them all with one call to systemctl if/when it does become an issue to call systemctl many times.

As I'm sure you remember, when check_ps_service() was originally written, SystemD was relatively new, and NHC needed to support systems all the way back to RHEL/CentOS/SL 4.x. Since the traditional LSB /sbin/service utility supported both SystemD and /etc/init.d/ scripts, that seemed the most straightforward approach. Fast-forward to today, and all "officially supported" platforms for the upcoming 1.5 release of NHC use SystemD. So making the move to systemctl might be prudent.

There's a lot I really love about SystemD, and there's a lot about it that drives me bonkers. But the quantity and usefulness of the verbs supported by systemctl is fantastic IMHO. I think there's a lot that could be done -- either in check_ps_service() or an entirely new check -- to take advantage of systemctl's consistency and feature set. I've already committed to some new features for it, as it's one of the most broadly used and most impactful checks in NHC's arsenal, but I'm keeping an open mind to the possibility that the sanest course of action may wind up being an entirely new check.

Regardless, if you do happen to put together a custom check for systemctl and multiple simultaneous unit validations, I hope you'll submit a PR! 😀

This is the string that got things working ok in redhat 9:

check_ps_service -u root -d sshd: -S sshd

Great! Glad you got it working. Just something to keep in mind: -d sshd: is exactly equivalent to -m '*sshd:', and in most cases that's the right choice; using the -m option directly merely gives greater control over exactly which process names will/won't be matched. (For example, my 2nd suggestion above uses a regular expression in order to match the sshd process with or without the trailing :.)

@heitorPB
Copy link

(Same issue as in #99)

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

No branches or pull requests

4 participants