MemoryDelaySmtpHandler will create a bundle of events in a single email and sent it after a delay.
Project description
memorydelaysmtphandler
Overview
memorydelaysmtphandler adds new handlers for the Python logging package.
Issue : SMTPHandler sends one email after each event. Multiple emails can be received in a short time.
Improvement : MemoryDelaySmtpHandler will create a bundle of events in a single email and sent it after a delay.
Features
MemoryDelayHandler class adds an auto-flush delay to logging.handlers.MemoryHandler.
MemoryDelaySmtpHandler class adds an auto-flush delay to logging.handlers.SMTPHandler.
The handler is flushed when:
- the number of events is equal to the capacity
- the event of a certain severity occurs
- after a first event, the delay is reached
New parameters
- Initializes the handler with a buffer of the specified capacity. Here, capacity means the number of events records buffered.
- A delay in seconds to automatically flush the buffer after a first event. When the delay argument is not present or None, no automatic flushed is provided.
Installation
$ python3 -m pip install memorydelaysmtphandler
Using with OpenCanary
logging.handlers.SMTPHandler sends one email after each alert. Multiple emails can be received in a short time.
MemoryDelaySmtpHandler will create a bundle of alerts in a single email and sent it after a delay.
Installation for OpenCanary
Install memorydelaysmtphandler in the OpenCanary environment.
Edit /etc/opencanaryd/opencanary.conf
Change "class": "logging.handlers.SMTPHandler"
by "class": "memorydelaysmtphandler.memorydelaysmtphandler.MemoryDelaySmtpHandler"
add these parameters:
"capacity" : your capacity,
"delay" : your delay
Example:
// [..] # Services configuration
"logger": {
"class" : "PyLogger",
"kwargs" : {
"handlers": {
"SMTP": {
"class": "memorydelaysmtphandler.memorydelaysmtphandler.MemoryDelaySmtpHandler",
"mailhost": ["smtp.gmail.com", 587],
"fromaddr": "noreply@yourdomain.com",
"toaddrs" : ["youraddress@gmail.com"],
"subject" : "OpenCanary Alert",
"credentials" : ["youraddress", "abcdefghijklmnop"],
"secure" : [],
"capacity" : 128,
"delay" : 60
}
}
}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file memorydelaysmtphandler-1.0.2.tar.gz
.
File metadata
- Download URL: memorydelaysmtphandler-1.0.2.tar.gz
- Upload date:
- Size: 14.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6f9daef61e6eb949e7a71f355861be894a8c485531804b121fa68d80dca898e7 |
|
MD5 | bcd01ba5ffc972b2be918a32c36da0eb |
|
BLAKE2b-256 | 1151703b49acab9ceddfaabed4f28ddc90ce0c7f236c6b76e07abdd91091b5a9 |
File details
Details for the file memorydelaysmtphandler-1.0.2-py3-none-any.whl
.
File metadata
- Download URL: memorydelaysmtphandler-1.0.2-py3-none-any.whl
- Upload date:
- Size: 14.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7e2f7963e1e8b7eef6943362bc666d2e938a8620eadeae74ff9b4c183ca1c97d |
|
MD5 | 1d4c8a473f2dfe0e5e4f2119b1cb5efb |
|
BLAKE2b-256 | a09a9bacb2ce99ff7a655fe21b13c8e0df0a1628c9cfd985999caba92c0a4afc |