Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/monitor log size #104

Merged

Conversation

MEHRSHAD-MIRSHEKARY
Copy link
Collaborator

###logs_size_audit:

Key Features:

  • Size Calculation: The command calculates the total size of the specified log directory by traversing all files within it, ensuring accurate size reporting.
  • Threshold Monitoring: Compares the total log directory size against a pre-defined size limit. If the size exceeds this limit, an email notification is triggered.
  • Email Notifications: Integrates email notification functionality to alert administrators when log directory size thresholds are crossed, using an optional email template for customization.
  • Error Handling: Includes error handling for scenarios where the log directory does not exist, providing clear feedback to the user and logging relevant errors.
  • Logging: Implements logging at various stages of the command execution, capturing information about the log directory size and the email notification process.

This command enhances the logging infrastructure by providing automated monitoring and alerting mechanisms, helping maintain optimal disk usage and system performance.

##MonitorLogSizeMiddleware:

Key Features:

  • Periodic Log Size Monitoring: The middleware runs the logs_size_audit management command if a week has passed since the last log size check. This ensures that large log directories are monitored regularly, preventing excessive disk usage.
  • Synchronous and Asynchronous Compatibility: The middleware is designed to handle both synchronous and asynchronous request flows, making it suitable for a wide range of Django projects.
  • Cache-based Scheduling: Utilizes Django’s caching mechanism to store the last run time of the log size audit, ensuring the task is run only once per week.
  • Error Handling and Logging: Captures any exceptions raised during the execution of the logs_size_audit management command and logs them appropriately, providing visibility into potential issues.
  • Automatic Email Alerts: The underlying management command sends warning emails to administrators if the log directory size exceeds the configured limit, aiding in timely disk space management.

This middleware adds a critical feature for log management, enhancing system reliability by automating regular log directory audits and alerting admins when action is required.

Closes #96

…Warning Emails

This commit introduces a new Django management command that checks the total size of the logs directory and sends an email notification to the administrator if the size exceeds the configured limit. This command is crucial for maintaining log file management and preventing excessive disk usage.

#### Key Features:
- **Size Calculation**: The command calculates the total size of the specified log directory by traversing all files within it, ensuring accurate size reporting.
- **Threshold Monitoring**: Compares the total log directory size against a pre-defined size limit. If the size exceeds this limit, an email notification is triggered.
- **Email Notifications**: Integrates email notification functionality to alert administrators when log directory size thresholds are crossed, using an optional email template for customization.
- **Error Handling**: Includes error handling for scenarios where the log directory does not exist, providing clear feedback to the user and logging relevant errors.
- **Logging**: Implements logging at various stages of the command execution, capturing information about the log directory size and the email notification process.

This command enhances the logging infrastructure by providing automated monitoring and alerting mechanisms, helping maintain optimal disk usage and system performance.
#### Description:
This commit introduces the MonitorLogSizeMiddleware, which periodically checks the size of the log directory and ensures administrators are notified when it exceeds a configured limit. The middleware supports both synchronous and asynchronous request processing, making it adaptable to various application setups.

#### Key Features:
- **Periodic Log Size Monitoring**: The middleware runs the logs_size_audit management command if a week has passed since the last log size check. This ensures that large log directories are monitored regularly, preventing excessive disk usage.
- **Synchronous and Asynchronous Compatibility**: The middleware is designed to handle both synchronous and asynchronous request flows, making it suitable for a wide range of Django projects.
- **Cache-based Scheduling**: Utilizes Django’s caching mechanism to store the last run time of the log size audit, ensuring the task is run only once per week.
- **Error Handling and Logging**: Captures any exceptions raised during the execution of the logs_size_audit management command and logs them appropriately, providing visibility into potential issues.
- **Automatic Email Alerts**: The underlying management command sends warning emails to administrators if the log directory size exceeds the configured limit, aiding in timely disk space management.

This middleware adds a critical feature for log management, enhancing system reliability by automating regular log directory audits and alerting admins when action is required.

Closes Lazarus-org#96
Copy link
Collaborator

@ARYAN-NIKNEZHAD ARYAN-NIKNEZHAD left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved 👌

@ARYAN-NIKNEZHAD ARYAN-NIKNEZHAD merged commit 66a4d0f into Lazarus-org:main Oct 4, 2024
5 checks passed
@MEHRSHAD-MIRSHEKARY MEHRSHAD-MIRSHEKARY deleted the feat/monitor-log-size branch October 11, 2024 20:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Log Directory Management and Admin Warning Feature
2 participants