Python-Scripts
Python-Scripts copied to clipboard
New Script Contribution - Python Hardware Resource Monitor with Cross-Platform Support
Description: Hardware Resource Monitor
Overview
This issue requests permission to add a Python-based hardware resource monitoring tool that provides real-time information about the system's hardware specifications and resource usage. The tool is designed to run continuously, similar to the Windows Task Manager, and displays data in a clean and user-friendly format in the console.
Features
-
GPU Monitoring:
- Detects and displays GPU specifications, including:
- GPU name
- Total memory (in GB)
- Used memory (in GB)
- Supports NVIDIA GPUs using the
pynvmllibrary.
- Detects and displays GPU specifications, including:
-
System Monitoring:
- Detects and displays system specifications, including:
- Total and used RAM (in GB)
- Available disk space (in GB)
- Number of CPU cores
- CPU usage percentage
- Detects and displays system specifications, including:
-
Continuous Monitoring:
- Continuously monitors hardware resources with a customizable update interval.
- Clears the console output on each update for a clean display.
-
Cross-Platform Compatibility:
- Works on Windows, macOS, and Linux for CPU, RAM, and disk monitoring.
- GPU monitoring is limited to systems with NVIDIA GPUs and the required drivers.
Changes Made
- Added the
HardwareDetectorclass to handle hardware resource detection and monitoring. - Implemented methods for:
- GPU specifications detection (
get_gpu_specs). - System specifications detection (
get_computer_specs). - Continuous monitoring (
monitor_resources).
- GPU specifications detection (
- Included exception handling for graceful termination using
KeyboardInterrupt. - Updated the
README.mdwith usage instructions and project details. - Added a
requirements.txtfile for dependency management.
How to Use
-
Install the required dependencies:
pip install -r requirements.txt -
Run the script:
python hardware_detector.py -
Press
Ctrl+Cto stop the monitoring process.
Notes
- The GPU detection only works for Nvidia GPUs
- The script clears the console output on each update. This behavior may vary depending on the operating system.
Testing
- Verified functionality on Windows and Linux systems.
- Tested with and without NVIDIA GPUs to ensure proper handling of GPU-related functionality.