• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Monit (similar to watchdog) doesn't send email warnings

Alan_SP

Basic Pleskian
I installed monit to monitor my server. Monit is pretty similar to watchdog, but I can control it completely.

But, problem is, I can't receive email alerts.

Setting for mail server I use is:

set mailserver localhost

This uses default port. I use qmail on my server. Error in monit log is this:

Mail: 553 sorry, that domain isn't in my list of allowed rcpthosts (#5.7.1)
Alert handler failed, retry scheduled for next cycle

I checked document here: http://kb.odin.com/en/168 I have localhost where it should be. I also tried using different port (587, as I use server for sending my mails).

Whatever I tried so far I don't receive emails. I see that there are events that should triggered email sending (as evident from mail log), like PID or Monit restart.

I don't know if watchdog sends emails on PID change, but I don't receive them neither. Before I received emails from watchdog for sure, some services (BIND, php-fpm) needed restart.

Any suggestions why monit doesn't send emails?
 
I see that I don't receive emails even from watchdog (there are some events that should trigger emails I know of), so this is probably some problem with qmail.

As I have live sites on the server and can't start from scratch, what is the best strategy to use? Try to detect what blocks using localhost setting in monit and watchdog configuration? Or just to change mail program? And try to get back to qmail? Hoping this wouldn't completely break mails I should receive from server?

Now I'm sure that something is wrong with qmail settings, but can't found out what. And how to try to repair it.

Any ideas?
 
@Alan_SP,

I will keep it short, for many reasons, one of them being that the issues are very likely to be related to the hostname.

In fact, you would have to define:

set mailserver <hostname>
set mail-format { from: <monit>@<domain>.<tld> }
set alert <relevant account>@<domain>.<com>

and note that the <monit>@<domain>.<tld> can be anything, but it is adviceable to a domain that exists on the server.

Also note that you should verify that <hostname> is present in the rcpthosts file (a qmail file, do not manually edit that file).

If your <hostname> does not occur in rcpthosst OR if <hostname> is not persistent (for example, across reboots), then it is adviceable to

- choose a domain that you own,
- choose a subdomain name for the hostname, instead of the "exotic" hostnames one often sees,
- create an A record to point to the IP used by your server: <subdomain>.<domain>.<tld> A <IP of the server>
- go to Tools & Settings > Server Settings and change the hostname (and press OK)
- optional: check contents of /etc/hostname and/or the rcpthosts file, in order to assure that they contain the proper hostname.

By the way, it can be the case that your error notification is caused by

- a non-existing domain (in set mail-format and/or set alert directives), OR
- general issues (as result of value in the set mailserver directive)

and the above mentioned solutions/work-arounds should work for both cases.

Anyway, it is always good to set the hostname equal to a subdomain name and point an A record to it.

Hope the above helps.

Regards....
 
set alert <relevant account>@<domain>.<com>

- a non-existing domain (in set mail-format and/or set alert directives), OR

@trialotto

Thank you very much, this was what made problem, set alert directive was "wrong", I used my actual main email address, not the one that is "on the server", i.e. one from domains that actually are placed on server. That is a bit strange in my opinion, because on my other server that worked just fine.

But now that I used email address that exist "on the server", i.e. is tied with domain that actually exist on server, I receive emails. Of course, that email gets redirected to my actual email address, so we can say that monit sends email to "bogus email on the server", that gets redirected to "actual email" and I receive email.

Is there a reason why I shouldn't directly send email to my actual email address? It just looks a bit strange?
 
@Alan_SP

Is there a reason why I shouldn't directly send email to my actual email address? It just looks a bit strange?

In response to the above, you should be aware that two (potential) problems can be related to "sending mail directly":

a) mails, associated with specific domains and/or the hostname, can be blocked by the receiving mail server, for instance in the case that spam filtering is activated, (and/or)

b) mails, originating from a (mail) script, require some security settings to be less strict and, as a result, your (sending) mail server becomes vulnerable (for instance, to spam relaying).

I am pretty sure that in your case the mail is send directly and that the receiving mail server just blocks the mail, due to spam filtering, spf records etc. etc.

In essence, the problem is resolved, so it is not strictly necessary to test all the combinations of mail addresses in the mail-format and/or set alert directives.

Regards.....
 
Back
Top