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

sendmail support #29

Open
LevitatingBusinessMan opened this issue Feb 18, 2025 · 6 comments
Open

sendmail support #29

LevitatingBusinessMan opened this issue Feb 18, 2025 · 6 comments

Comments

@LevitatingBusinessMan
Copy link

Currently telem is supported for logging, but there's no support for sending mail with sendmail.

This should be trivial to implement.

@thkukuk
Copy link
Contributor

thkukuk commented Feb 18, 2025

For sending mails we have systemd-status-mail.

@LevitatingBusinessMan
Copy link
Author

LevitatingBusinessMan commented Feb 18, 2025

I already employ a very similar homegrown solution1. (for some reason systemd-user-mail requires postfix?)

But when health-checker fails, is there actually any guarantee that a systemd service has failed? And thus an email sent?

As far as I can tell from reading the logic, health-checker either reboots or isolates to emergency.target when a plugin fails.

@LevitatingBusinessMan
Copy link
Author

LevitatingBusinessMan commented Feb 18, 2025

My solution would be to implicitly call sendmail, which could provide more details like what plugin failed, what the BTRFS snapshots are and in what stage of recovery health-checker is.

As for the choice of sendmail over solutions like mailx. Mailx is a simple SMTP client but there are other SMTP clients that provide compatible sendmail binaries like msmtp.

By using sendmail the sysadmin can use any MTA or a thin wrapper to an SMTP client like with msmtp. Mail should be globally configured anyway.

If a user would choose msmtp via sendmail to use with systemd-status-mail the same configuration would work for health-checker.

If you think this is a good idea I can just make an experimental PR.

@thkukuk
Copy link
Contributor

thkukuk commented Feb 18, 2025

But when health-checker fails, is there actually any guarantee that a systemd service has failed? And thus an email sent?

No, if health-checker fails the system is not in an healthy state and thus sending emails will most likely also fail.

My solution would be to implicitly call sendmail, which could provide more details like what plugin failed, what the BTRFS snapshots are and in what stage of recovery health-checker is.

Make sure that health-checker logs this all to the journal and it will be in the mail send to you. This are no information which we should try to send by mail (which will most likely fail), but where we should try to log them on local disk. The chances that this works are higher.

Else I don't understand your comments about sendmail and mailx. systemd-status-mail uses sendmail if available, but most systems today don't have a configured/working sendmail/postfix/..., so using mailx to send the mail to the next relay is what people are doing and using out there.

@thkukuk
Copy link
Contributor

thkukuk commented Feb 18, 2025

If a user would choose msmtp via sendmail to use with systemd-status-mail the same configuration would work for health-checker.
If you think this is a good idea I can just make an experimental PR.

You can add something generic as systemd-status-mail has, but in most cases I'm aware of there would be no way to send emails from health-checker since the system is not working and most of the time network not available.

@LevitatingBusinessMan
Copy link
Author

LevitatingBusinessMan commented Feb 18, 2025

Make sure that health-checker logs this all to the journal and it will be in the mail send to you

What would then trigger that to be sent? ie. when using systemd-status-mail?

No, if health-checker fails the system is not in an healthy state and thus sending emails will most likely also fail.

I agree that when the health-checker fails with the default plugins it is unlikely that emails get sent.

However I use MicroOS as a database server, and I would like the health-checker to verify that the postgres database is up. If it isn't then I would like it to rollback, I am not sure if this is the intended usecase for health-checker though. However it seems competent enough to verify higher-level services are running. In this scenario I would receive an email of the postgres service failing only if health-checker doesn't reboot before the email is sent.

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

2 participants