damicon / zfswatcher

ZFS pool monitoring and notification daemon
GNU General Public License v3.0
188 stars 38 forks source link

Can't send email, or debug email sending attempts #7

Closed scottj97 closed 10 years ago

scottj97 commented 10 years ago

I'm trying to configure a new zfswatcher installation but can't get it to send any emails. I'm sure my config file is faulty, but I can't figure out what. The problem is I cannot find any error messages or even any indication that zfswatcher is attempting to send any email. (I did set enable="true" in that section, then triggered critical events that get picked up correctly in zfswatcher.log.) If there's a way to get such debug info, please consider this a doc request. If not, consider this a feature request.

Zfswatcher looks like exactly the tool I was looking for, but without emails it's not much use!

bentolor commented 10 years ago

Same here. I expected an email but did not receive any and haven't any clue how to debug this issue, too!

Here is my configuration section, mostly untouched. An exim4 is locally running on port 25. 'ben' is a local username.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
; The "email" section(s) define SMTP email based logging destinations. 
; Multiple "email" sections with different parameters may be defined by
; using different profile names (in quotes after the section name).
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[email "main"]
;
; Whether this logging destination should be enabled or not:
enable = true
;
; Which message severity levels to include in this logging destination:
level = notice
;
; The SMTP server name or IP address followed by a column and a port number:
;server = localhost:587
;server = 192.0.2.1:25
server = localhost:25
;
; The username and password if the SMTP server requires them for
; authentication:
;username = exampleuser
;password = supersecret
;
; "From" address for notification messages:
from = zfswatcher@neptun
;
; "To" address(es) for notification messages (several addresses can
; be listed, separated by spaces):
to = ben
;
; The "Subject" of notification messages (the severity level is
; automatically appended at the end):
subject = "zfswatcher notification"  
;
; The time to wait (in seconds) between consecutive e-mail messages
; (prevents flooding too many e-mails if there are many errors within
; a short period of time):
throttle = 600

This is my failure in the syslog (I started a `shred /dev/sdX' by acciddent):

Jul 23 13:17:29 neptun zfswatcher[17400]: pool "zfstank" device "luks-6c309ca3-18c6-4c84-a990-7c20939ff831" cksum errors increased: 0 -> 14
Jul 23 13:17:29 neptun zfswatcher[17400]: pool "zfstank" device "luks-6c309ca3-18c6-4c84-a990-7c20939ff831" new additional info: (repairing)
Jul 23 13:17:29 neptun zfswatcher[17400]: pool "zfstank" new status: One or more devices has experienced an unrecoverable error.  An attempt was made to correct the error.  Applications are unaffected.

And this is how zfswatcher.log looks like:

2014-07-23 13:17:29 [err] pool "zfstank" device "luks-6c309ca3-18c6-4c84-a990-7c20939ff831" cksum errors increased: 0 -> 14
2014-07-23 13:17:29 [notice] pool "zfstank" device "luks-6c309ca3-18c6-4c84-a990-7c20939ff831" new additional info: (repairing)
2014-07-23 13:17:29 [err] pool "zfstank" new status: One or more devices has experienced an unrecoverable error.  An attempt was made to correct the error.  Applications are unaffected.

@snabb Any hints how to tackle this down?

Zfswatcher looks like exactly the tool I was looking for, but without emails it's not much use!

Yes, same for me! The rest of zfswatcher looks great!

snabb commented 10 years ago

Hi,

Unfortunately there is currently not much diagnostics output in case SMTP logger output fails. It is problematic to create log events from the logger itself. It would easily create a loop (the logger would try logging the SMTP error by making another SMTP logging connection).

Have you tried to run zfswatcher from terminal with "-d" option? In case that does not tell anything useful, the best way to debug SMTP connection is probably using tcpdump to see what happens. Have you tried that?

scottj97 commented 10 years ago

I ended up hacking the zfswatcher source to send mail using /usr/bin/mail instead of SMTP. It solved my problem but doesn't really help anybody else.

bentolor commented 10 years ago

Thanks @snabb , this helped!

I reduced the log level of the mail handler to DEBUG so that the mail handler gets triggered off by debug messages. And voila:

2014-07-24 23:17:42 [info] zfswatcher starting
2014-07-24 23:17:42 [NOTIFIER] error sending mail (retrying): 501 <ben>: recipient address must contain a domain

Replacing with user@hostname, saving. Restarting. Works!

Ideally a startup option which releases criticial/warnings/... messages to test the notification system similar to smartmontools -m test would have been convenient.