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.
  • c_id_exec: Unique execution identifier.
  • 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()
c_id_exec = "exec_12345"
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,
    c_id_exec,
    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.0.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.0-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: dkrresource-1.0.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.0.tar.gz
Algorithm Hash digest
SHA256 d845c11a4b3e42719fc2ec63a01ba0e80362fd1d6cde9d767ba535c385225b3c
MD5 a6b28b918a583730439763d7bc235317
BLAKE2b-256 3b1527d74552a33cd507875636645f863216fe2c15e01b91db100d05b393bfca

See more details on using hashes here.

File details

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

File metadata

  • Download URL: dkrresource-1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.7 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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 2ef893443f60a3b5bc1fd397f356ad82fa1d0303e1a5eb6d81da66fb2af689f7
MD5 e6952e3a9dd36b1cf49d41b0add77eaa
BLAKE2b-256 c176ec496dfaac4f0566cfbdd353f3139f1bacc1fdbc50c39f87684c3dfcac59

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