...
Table of Contents |
---|
Step-by-step guide
WATO - CONFIGURATION → Host & Service Parameters → Active checks → Check Email
CHECK EMAIL
Service description
Here you can type in a service description. Please make sure that this is unique per host and does not collide with other services.
Mail Receiving
Here you can select if you want to check your IMAP or POP3 login. You need your login credentials for your E-Mail Mailbox.
Info
Forward mails as events to Event Console
.Forwarding Method
:Here you can select if you want to send the events either to the EC or to a remote syslog host. If you want to send the events to the local EC, we would recommend using the spooling mechanism.
By using the spooling mechanism, the check will store all collected eventsin one file in ~/var/mkeventd/spool.Code Block linenumbers true OMD[nagnis_master]:~$ ll ~/var/mkeventd/spool/ total 3600 -rw-rw---- 1 nagnis_master nagnis_master 79124 Dec 7 15:36 localhost_407343_1607351778 -rw-rw---- 1 nagnis_master nagnis_master 79124 Dec 7 15:37 localhost_408329_1607351841
Only process mails with matching subject
Use this option to not process all messages found in the inbox, but only the those whose subject matches the given regular expression. The text entered here is handled as a regular expression pattern. The pattern is matched from the beginning. Add a tailing $ to change it to a whole text match. The match is performed case sensitive. Read more about regular expression matching in Checkmk in our user manual.
You need to be aware that a subject field could contain line breaks. This is depending on your mail client and mail gateway. To find out how many line breaks you have, you could check the raw email
Info Now you can use regex101.com to create a regex
Info - For advanced debuging
Copy the plugin to the local path
Code Block OMD[mysite]:~/lib/nagios/plugins$ cp check_mail ~/local/lib/nagios/plugins/
Add a print for the subject
Code Block 104 for index, msg in sorted(mails.items()): 105 subject = msg.get('Subject', 'None') 106 print(subject)
Run the script manually
Code Block OMD[jph2]:~/lib/nagios/plugins$ ./check_mail --pwstore=6@17@password_1 '--fetch-protocol=IMAP' '--fetch-server=imap.strato.de' '--fetch-tls' '--fetch-port=993' '--fetch-username=mail@anastasios-thomaidis.de' '--fetch-password=*************' '--connect-timeout=10' '--forward-ec' '--match-subject=.*Incident.*\n.*assigned' =?utf-8?Q?Incident_INC000000041690_has_bee?= =?utf-8?Q?n_assigned_to_your_group_'SD_Seco?= =?utf-8?Q?ndo_Livello_DC'_=E2=80=93_Object:_Comuni?= =?utf-8?Q?cazione_Proattiva_-_Priority:_Low?= =?utf-8?Q?Incident_INC000000041690_has_bee?= =?utf-8?Q?n_assigned_to_your_group_'SD_Seco?= =?utf-8?Q?ndo_Livello_DC'_=E2=80=93_Object:_Comuni?= =?utf-8?Q?cazione_Proattiva_-_Priority:_Low?= Forwarded 2 messages to event console | messages=2
Events: Syslog facility
Use this syslog facility for all created events
Events: Hostname
Use this hostname for all created events instead of the name of the mailserver
Limit length of mail body
When forwarding mails from the mailbox to the event console, the body of the mail is limited to the given number of characters.
Cleanup messages
The handled messages (see subject matching) can be cleaned up by either deleting them or moving them to a subfolder. By default nothing is cleaned up.
Info
...