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.