Skip to main content

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


Download files

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

Source Distribution

dkrresource-1.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

dkrresource-1.2-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file dkrresource-1.2.tar.gz.

File metadata

  • Download URL: dkrresource-1.2.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

Hashes for dkrresource-1.2.tar.gz
Algorithm Hash digest
SHA256 583aa8c73b78b28efcaffe0b7f84c946ebca6e34216de506bb996d56bb10c4a3
MD5 014c24f1dc9a6c2f18310d846c80e289
BLAKE2b-256 dc2713da5dd0c81fb3ed1c13071c843c45ad809a034289ae538648daabe7b0ed

See more details on using hashes here.

File details

Details for the file dkrresource-1.2-py3-none-any.whl.

File metadata

  • Download URL: dkrresource-1.2-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

Hashes for dkrresource-1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7ad97cdb6c38929e03bea2f1ef979059426910fa062d22a720615da309dcb802
MD5 4e6041617d711af90ea239c2198bb8ac
BLAKE2b-256 f2d0f8d95241e7736d297bcda29fd16d0cbf663a7429804f7e77b7aa1fbc21b0

See more details on using hashes here.

Supported by

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