Python Prompts Free Prompt

Python Script to Monitor CPU and Memory Usage

Create a Python script to monitor system CPU and memory usage and log to a file
☆ Save
Prompt
You are a Python developer. Write a script that monitors CPU and memory usage of the system at regular intervals. Use the psutil library. The script must: 1) Log timestamp, CPU percent, memory percent, and top processes to a CSV file, 2) Run continuously with configurable interval, 3) Send alert if usage exceeds threshold, 4) Provide a command-line option to display real-time stats, 5) Plot graphs using matplotlib (optional), 6) Include error handling. Add a requirements.txt.

How to use this prompt

1
Click Copy Prompt above to copy to your clipboard.
2
Open ChatGPT, Claude, Gemini, or any AI assistant and paste the prompt.
3
Replace any [PLACEHOLDER] values with your specific details.
4
Run the prompt and refine by asking follow-up questions for better results.