This library standardizes logs and exceptions, ensuring consistent error handling and tracking.
Project description
Dkr Resource
This Python library is designed to monitor and log system resource usage (CPU and RAM) during the execution of a routine. It collects data periodically and stores it in a database, allowing users to track the resource consumption of their applications.
Installation
pip install dkrresource
Configuration
To use ResourceManager, configure the following parameters:
- routine_name: Name of the routine being monitored.
- start_date: Start time of the routine.
- routine_path: Path where the routine is running.
- db_str: Database connection string.
- t_channel: Teams channel for error reporting.
- t_url: Teams webhook URL for reporting errors.
Usage
from datetime import datetime as dt
from resourcemanager import ResourceManager
routine_name = "DataPipeline"
start_date = dt.now()
routine_path = "/path/to/routine"
db_str = "postgresql://user:password@localhost/dbname"
t_channel = "resource-alerts"
t_url = "https://teams.webhook.url"
# Initialize the ResourceManager
rm = ResourceManager(
routine_name,
start_date,
routine_path,
db_str,
t_channel,
t_url
)
# Start resource monitoring
rm.start_collection()
# Execute some processing...
# Stop collecting and log final data
rm.finish_collection()
Database Logging
The library logs the following resource metrics in a database:
- Maximum CPU usage
- Average CPU usage
- Maximum RAM usage
- Average RAM usage
Error Reporting
If an issue occurs during execution, ResourceManager sends an error notification to a Microsoft Teams channel using the provided webhook.
License
This project is licensed under the MIT License.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dkrresource-1.1.tar.gz.
File metadata
- Download URL: dkrresource-1.1.tar.gz
- Upload date:
- Size: 5.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2f5ea4c23deabe74a07613bec4fe70c2c1e6417e6c805bde0b6a5a68d5fe116
|
|
| MD5 |
cc593d76e7792f03f77a6e5abdb949e5
|
|
| BLAKE2b-256 |
c71e323a8d965951321b49249fe3ddd19288f640a1abe5cb3d3a4746e9343b8a
|
File details
Details for the file dkrresource-1.1-py3-none-any.whl.
File metadata
- Download URL: dkrresource-1.1-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
69555b90c8fd9e952949232841c4af67e044235e2744ade293eb3a1310ef5aa1
|
|
| MD5 |
6ee2908d87f760b64d3de1c5a4362a97
|
|
| BLAKE2b-256 |
1e507a6e9acf5618fbbfdc382601c9c0d3ffc9a18177a6ca1bcc193326f34e90
|