Skip to main content

MemoryDelaySmtpHandler will create a bundle of events in an 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 an 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 an 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

memorydelaysmtphandler-1.0.1.tar.gz (14.3 kB view details)

Uploaded Source

Built Distribution

memorydelaysmtphandler-1.0.1-py3-none-any.whl (14.4 kB view details)

Uploaded Python 3

File details

Details for the file memorydelaysmtphandler-1.0.1.tar.gz.

File metadata

File hashes

Hashes for memorydelaysmtphandler-1.0.1.tar.gz
Algorithm Hash digest
SHA256 5913babe2db5e3d2270d3bfb7dea61d420ca421f729678da8fc8240ed10def90
MD5 532fdcb992aed2d17f200956c83d8248
BLAKE2b-256 7450b813ba750af6fbf74c31f7b067f80e143dd4c8ac0f8233fbec94a468753b

See more details on using hashes here.

File details

Details for the file memorydelaysmtphandler-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for memorydelaysmtphandler-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1ffefb0fec44c10ed386f6f598993d5af59649d40ad154d08e1730ff73305387
MD5 1d54f9728e22442d25ef9795496e3fe8
BLAKE2b-256 bad5e9e6dbfe7b1110cc3800114ec93b6f97e1eeb71f896092a8c6237ac67be1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page