Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- # -*- coding: utf-8 -*-
- # Filename: pico_mem_monitor.py
- # Author: Jeoi Reqi
- """
- Pico Mem Monitor: Raspberry Pi Pico Memory Monitoring Script
- Description:
- This script monitors and displays the real-time usage of CPU and memory on a Raspberry Pi Pico. It provides a visual representation of the usage percentages using ASCII bars, making it easy for users to gauge system resource utilization.
- Usage:
- 1. Ensure you have the necessary dependencies installed (psutil library).
- 2. Run the script on your Raspberry Pi Pico.
- 3. Observe the dynamic updates of CPU and memory usage with corresponding ASCII bars.
- Features:
- - Real-time monitoring of CPU and memory usage.
- - Visual representation with ASCII bars for quick interpretation.
- - Continuously updates every 0.5 seconds to provide live feedback.
- Requirements:
- - psutil library. Install using 'pip install psutil'.
- Note: This script is specifically designed for Raspberry Pi Pico. Ensure dependencies are met before execution.
- Enjoy monitoring the resource utilization of your Raspberry Pi Pico with this simple and informative script!
- """
- import time
- import psutil
- def display_usage(cpu_usage, mem_usage, bars=50):
- cpu_percent = (cpu_usage / 100.0)
- cpu_bar = '█' * int(cpu_percent * bars) + '-' * (bars - int(cpu_percent * bars))
- mem_percent = (mem_usage / 100.0)
- mem_bar = '█' * int(mem_percent * bars) + '-' * (bars - int(mem_percent * bars))
- print(f"\rCPU USAGE: |{cpu_bar}| {cpu_usage:.2f}% ", end="")
- print(f"\MEM USAGE: |{mem_bar}| {mem_usage:.2f}% ", end="\r")
- while True:
- display_usage(psutil.cpu_percent(), psutil.virtual_memory().percent, 30)
- time.sleep(0.5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement