Skip to main content

Paquete para ejecutar comandos y monitorear uso de CPU y memoria

Project description

PyPI Latest Release PyPI - Downloads GitHub Release Date GitHub License

CommandTracker

CommandTracker is a Python tool designed to execute a command and monitor its resource usage in real time. It tracks CPU and memory consumption, providing valuable performance metrics like average CPU load and peak memory usage. This tool is ideal for developers and system administrators looking to optimize the performance of commands or processes.

Features

  • Monitor CPU and memory usage of any command.
  • Real-time resource tracking during command execution.
  • Provides performance statistics, including average CPU usage and peak memory consumption.
  • Generation of graphs to visualize resource usage.
  • Historical logging of command execution.

Installation

You can install CommandTracker via pip:

pip install CommandTracker

Usage

Once installed, you can use ctracker to monitor a command’s resource usage:

ctracker monitor <command>

For example:

ctracker monitor php artisan calc --date=2024-01-01

Example Output:

Starting process with PID 12345...

Output of your command...

Process finished.
Total execution time: 10.25 seconds.

Resource usage statistics:
Average CPU usage: 35.67%
Maximum memory usage: 120.45 MB

Use -g or --graph to generate graphs.

ctracker monitor -g <command>

For example:

ctracker monitor -g php artisan calc --date=2024-01-01

Example Output:

CPU usage graph: cpu usage graph

Memory usage graph: memory usage graph

History logs

Use ctracker history to see the all command history.

ctracker history

Example Output:

  2024-10-02 09:12:30 python3 script.py --input=data.csv --output=result.txt Total execution time: 25.78 seconds. Average CPU usage: 3.12% Maximum memory usage: 75.34 MB
  2024-10-02 09:15:45 php74 artisan migrate --force Total execution time: 12.43 seconds. Average CPU usage: 1.58% Maximum memory usage: 65.12 MB
  2024-10-02 09:20:10 node server.js Total execution time: 50.92 seconds. Average CPU usage: 4.67% Maximum memory usage: 120.87 MB
  2024-10-02 09:25:00 bash backup.sh --full Total execution time: 105.34 seconds. Average CPU usage: 2.87% Maximum memory usage: 200.45 MB
  2024-10-02 09:30:40 ruby script.rb --optimize Total execution time: 30.22 seconds. Average CPU usage: 2.45% Maximum memory usage: 78.65 MB

For find command history:

ctracker history <command>

For example:

ctracker history python3 script.py --input=data.csv --output=result.txt

Example Output:

  2024-10-02 09:12:30 python3 script.py --input=data.csv --output=result.txt Total execution time: 25.78 seconds. Average CPU usage: 3.12% Maximum memory usage: 75.34 MB
  2024-10-02 09:14:15 python3 script.py --input=data.csv --output=result.txt Total execution time: 30.21 seconds. Average CPU usage: 4.10% Maximum memory usage: 80.45 MB
  2024-10-02 09:16:05 python3 script.py --input=data.csv --output=result.txt Total execution time: 22.56 seconds. Average CPU usage: 2.98% Maximum memory usage: 72.15 MB
  2024-10-02 09:18:50 python3 script.py --input=data.csv --output=result.txt Total execution time: 28.90 seconds. Average CPU usage: 3.54% Maximum memory usage: 78.22 MB
  2024-10-02 09:21:33 python3 script.py --input=data.csv --output=result.txt Total execution time: 35.67 seconds. Average CPU usage: 4.75% Maximum memory usage: 82.90 MB
  2024-10-02 09:23:25 python3 script.py --input=data.csv --output=result.txt Total execution time: 18.45 seconds. Average CPU usage: 2.65% Maximum memory usage: 68.12 MB
  2024-10-02 09:25:12 python3 script.py --input=data.csv --output=result.txt Total execution time: 29.88 seconds. Average CPU usage: 3.87% Maximum memory usage: 77.56 MB

Requirements

  • Python 3.6+
  • psutil library

Contributing

Feel free to contribute by submitting issues or pull requests. More features and optimizations will be added in future versions.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Future Enhancements

Planned features for future releases include:

• Automatic alerts if a process exceeds certain CPU or memory thresholds. • Stress testing to simulate intensive workloads.

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

commandtracker-0.1.5.tar.gz (5.9 kB view details)

Uploaded Source

Built Distribution

CommandTracker-0.1.5-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

Details for the file commandtracker-0.1.5.tar.gz.

File metadata

  • Download URL: commandtracker-0.1.5.tar.gz
  • Upload date:
  • Size: 5.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for commandtracker-0.1.5.tar.gz
Algorithm Hash digest
SHA256 201a6b9f6797e1b8011ea5e38c5884c1da862102dafb5dd50fecbd23544e4227
MD5 36e9672344a1ffb736e59a7837f0b615
BLAKE2b-256 37410e793afa9bd19c1fae37a8da92157c79a50a07cbcafc8db6b5dc7e34e398

See more details on using hashes here.

File details

Details for the file CommandTracker-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for CommandTracker-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 768be65dc68b13159ac5e379cfe1dbb0c7935b9f1ed46631de52d764ca981654
MD5 f68dd47c2dc90a869631f522c0c12e40
BLAKE2b-256 216332a2edb42e18f72334df583ab215231fcfd32b54d069e53240763250f5f0

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